hi,
I recently started tyring to learn OpenGL but i think I am a bit confused about the push and pop matrix commands. I want to turn an object that I have drawn, but when I use the glrotate command the light source turns with the object. I want to turn the object independantly of the light source. Am I right in thinking that I should be able to do this with appropriate use of the pushMatrix and popMatrix commands.
I hate to admit this - but I don’t program in C or C++ and i’m using GL4Java (www.jausoft.com/products/gl4java). The code I’m using to draw the display looks like this -
//Clear The Screen And The Depth Buffer
gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//Reset The View
gl.glLoadIdentity();
//Move into the screen
gl.glTranslatef(0.0f, 0.0f, -8.0f);
//rotate on x-axis
gl.glRotatef(35,1,0,0);
//position light
gl.glLightfv(GL_LIGHT0, GL_POSITION, LightPosition);
gl.glPushMatrix();
//rotate on y-axis
gl.glRotatef(yrot, 0.0f, 1.0f, 0.0f);
//draw lumpy bits
gl.glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
gl.glBegin(GL_QUADS);
// i draw the object in here
gl.glEnd();
gl.glPopMatrix();
yrot += 0.4f;
//Swap buffers
glj.gljSwap();
//glj.gljCheckGL();
glj.gljFree();
Can something like this do what I want or have I got the wrong idea about all this?
thanks,
colin