tags:

views:

862

answers:

3

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 getGL**U**()"

public void reshape(GLAutoDrawable gLDrawable, int x, int y, int width, int height)
{
  final GL gl = gLDrawable.getGL();
  final GLU glu = gLDrawable.getGLU();
}
+2  A: 

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:

final GLU glu = glAutoDrawable.getGLU();

With it, you now just use:

final GLU glu = new GLU();

See here for details on that particular object.

paxdiablo
That worked, thank you.
William
Can you update links they are all 404
@m00st, done, thanks for that.
paxdiablo
A: 

Okay, that worked for getGL(), but now I'm still having problems with "cannot find symbol method getGL**U**()"

public void reshape(GLAutoDrawable gLDrawable, int x, int y, int width, int height)
    {
      final GL gl = gLDrawable.getGL();
      final GLU glu = gLDrawable.getGLU();
    }

William
You may be using a JSR-231 version of the API and using older source code as the basis for your own. Before that spec, you used to get the GLU from "GLAutoDrawable.getGLU()". With it, you now just use "final GLU glu = new GLU()".
paxdiablo
See http://download.java.net/media/jogl/builds/nightly/javadoc_public/javax/media/opengl/glu/GLU.html
paxdiablo
And this should really been a comment to my answer rather than an answer in itself but you're relatively new here so we'll let it go. :-)
paxdiablo
Ah, well thank you very very much, Pax.
William
A: 

It looks like, depending in what version of the API you are using, the getGLU method is not there. You can find out what methods exist by looking at the javadoc that (hopefully) came with the version you downloaded.

What version are you using (a link to where you downloaded it would be great).

TofuBeer