Hello everyone,
I discover jogl and it a pleasure for me to use openGL with Java. I tried with C++ and I was quickly blocked because of my knowledge lack with this language.
Now I face another problem, that I will expose here. It seems very easy to resolve.
I draw a triangle with glBegin(GL_Triangle) and glEnd()
gl.glBegin(GL.GL_TRIANGLES);
if (changeColor) SetRandomColor(gl);
gl.glVertex3f( 0.0f, 1.5f,0.0f);
if (changeColor) SetRandomColor(gl);
gl.glVertex3f(-1.0f,-1.0f,0.0f);
if (changeColor) SetRandomColor(gl);
gl.glVertex3f( 1.0f,-1.0f,0.0f);
gl.glEnd();
and I change the color with the simple following function:
public void SetRandomColor(GL gl){
float c1, c2, c3;
c1 = new Float(Math.random()).floatValue();
c2 = new Float(Math.random()).floatValue();
c3 = new Float(Math.random()).floatValue();
gl.glColor3f(c1,c2,c3);
System.out.println(c1 +" "+c2+" "+c3);
}
The boolean changeColor is set to True in the resize function and set to false at the end of the draw function. So I guess that every vertex of the triangle would have a different color each time I resize de window. But in fact, each vertex change color well at resizeing but they have all the same color even if in the System.out.println() the values are differents ???
Where is the problem ?
Thx in advance, Machiiine