0

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

genpfault
  • 51,148
  • 11
  • 85
  • 139
egor.ananyev
  • 347
  • 4
  • 9

2 Answers2

3

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
Steve
  • 78
  • 1
  • 8
1

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.

egor.ananyev
  • 347
  • 4
  • 9
  • Same problem happens for me. Subfunctions need to have the GL structure passed. I thought GL was a static variable visible from everywhere. – linello Oct 10 '16 at 11:05