Search code examples
openglpsychtoolbox

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


Solution

  • 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