egor.ananyev
egor.ananyev

Reputation: 377

Psychtoolbox OpenGL - draw a line

I need is a single line rendered from within PsychToolBox in Matlab. So:

glBegin(GL.LINES);
glVertex3f(0, 0, 0);
glVertex3f(1, 1, 1);
glEnd;

Returns:

??? The class "GL" is undefined. Perhaps Java is not running.

I'm using the code provided here.

However, I substituted GL_LINES with GL.LINES to fit psychtoolbox convention (naturally, tried it both ways).

Upvotes: 0

Views: 373

Answers (2)

Steve
Steve

Reputation: 78

I had a similar issue when I added a subfunction that was fixed by making GL a global variable:

function parent()
    global GL
    InitializeMatlabOpenGL(0);
    ...
    function child()
        ...
    end
end

Upvotes: 3

egor.ananyev
egor.ananyev

Reputation: 377

I neglected to mention that the above lines were run from a subfunction. Whenever this is done, apparently I need to explicitly pass the "GL" structure from the function that runs Screen('BeginOpenGL'). Let me know if anyone else experiences the above issue, and if you need more details about this answer.

Upvotes: 1

Related Questions