Can not control the color in JOGL
I am a beginner to use JOGL.
I find that I can not control the color, both background and foreground. The background is always Black, and foreground is always Red.
I use canvas.setBackground(Color),
gl.glColor3*(), trying to change the color. But it does not work.
What is the problem?
Thanks.
Toby
[344 byte] By [
tobyintera] at [2007-11-26 22:39:11]

# 1
A big help for learning JOGL is reading the Red Book from OpenGL, which can be downloaded in pdf. Since JOGL is almost a direct wrapper, the function calls are identical.
To set the background color, you need to add a GLEventListener to the GLCanvas that you're using. To set the background color, in your init() method for GLEventListener do:
public void init(GLAutoDrawable glad) {
GL gl=glad.getGL();
gl.glClearColor(r,g,b);
}
or something similar, I'm not on my normal computer so this was all from memory. Check the JOGL API for the exact method name for glClearColor. To change the foreground color, there are a bunch of various methods that are all similar to glColor3f(float r,float g,float b).
Calling this on the GL object in the display() method will set the foreground color and everything drawn that isn't using lighting will use this color.