I’m trying to learn how to use JoGL, and for some reason I’m getting this error despite having all of these imported:
import javax.media.opengl.*; import javax.media.opengl.glu.*; import com.sun.opengl.util.*; import com.sun.opengl.util.j2d.*;
public void display(javax.media.opengl.GLDrawable gLDrawable) { final GL gl = gLDrawable.getGL(); }
nor
public void display(GLDrawable gLDrawable) { final GL gl = gLDrawable.getGL(); }
work.
How do I fix this?
(edit: moved the next question up to here… you can edit your question or make a new question if things change with the answers you get)
Okay, that worked for getGL(), but now I’m still having problems with ‘cannot find symbol method getGLU()’
public void reshape(GLAutoDrawable gLDrawable, int x, int y, int width, int height) { final GL gl = gLDrawable.getGL(); final GLU glu = gLDrawable.getGLU(); }
It’s because GLDrawable actually doesn’t have such a method – see here.
It’s an interface which is implemented by GLCanvas and GLJPanel, both of which do have such a method.
I think what you need to do is pass in a GLAutoDrawable and use its getGL method. See here.
This wikipedia article has some sample source which shows how it’s done.
In answer to your further query where you ask why
final GLU glu = gLDrawable.getGLU();doesn’t work, you’re probably using the latest JSR-231 version of the API but basing your own code on older source code samples.Before that spec, you used to get the GLU from:
With it, you now just use:
See here for details on that particular object.