ask for help about glut

Hi guys:

I am a rookie in JOGL and just started 1weeks ago,
I just want to use “glut.glutSolidCube(gl, 3);” to draw a torus,
and my code is:
GL gl = GLDrawable.getGL(gl);
GLUT glut = new GLUT();
glut.glutSolidCube(gl, 3);

but the compiler always told me the following error information:
“non-static method getGL() cannot be referenced from a static contex”

so, how can I anounce and initial gl,
Could you give me some help?
Thanks a lot.

sorry , not to draw a torus but a cube.

If the calling method is static, any variables used inside that method needs to be declared static also.

GL gl = GLDrawable.getGL(gl);
GLUT glut = new GLUT();
glut.glutSolidCube(gl, 3);

It’s more helpful if you paste more code here.
AK77

you’re calling GLDrawable.getGL(). I imagine what you really want is drawable.getGL(). From whatever method you’re working inside of, you’ve probably been passed the parameter “GLDrawable drawable”. Make sure you use the object it gave you, and not the class name by mistake.