Psychtoolbox OpenGL - draw a line

367 views Asked by At

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).

2

There are 2 answers

1
Steve On BEST ANSWER

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
1
egor.ananyev On

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.