Am I crazy or is this a bug in jogl? I’m unable to enable/disable lighting in a method external to init() or display().
For example, I tried to put the following code into my keyPressed() method:
public void keyPressed(KeyEvent e)
{
switch (e.getKeyCode())
{
case KeyEvent.VK_L:
this.light = !this.light;
if (light)
gl.glEnable(GL.GL_LIGHTING);
else
gl.glDisable(GL.GL_LIGHTING);
break;
}
}
(Sorry for the crazy indending, but that isn’t working right for me now, either.)
This did not function correctly. Lighting could not be toggled. But if I move the test condition into display, everything works as it should.
It’s been some years since I did OpenGL coding under C++, but I’m reasonably sure that setting states should not be limited to certain functions. It doesn’t make sense to have to enable lighting each and every frame.