Reputation:
I want to rotate a Quad along 360 degrees with the code below). I am varying "input" on another procedure (Range = 0 to 1).
Despite "input" changing correctly, I can not seem to update rotation of a quad on screen - It remains stuck at the first angle, e.g. 180 if input is 0.5.
@Override
public void onDrawFrame(GL10 gl) {
gl.glLoadIdentity();
GLU.gluOrtho2D(gl, 0, width, height, 0);
gl.glClearColor(0.f, 0.f, 0.f, 1f);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glColor4f(1f, 1f, 1f, 1f);
gl.glPushMatrix();
gl.glTranslatef(width/2, height/2, 0.0f);
gl.glRotatef(360 * input, 0.0f, 0.0f, 1.0f);
gl.glPopMatrix();
bgQuad.setX(0);
bgQuad.setY(0);
bgQuad.draw(gl);
}
Any suggestions?
Upvotes: 0
Views: 176
Reputation: 48186
move popMatrix
to after bgQuad.draw(gl);
:
@Override
public void onDrawFrame(GL10 gl) {
gl.glLoadIdentity();
GLU.gluOrtho2D(gl, 0, width, height, 0);
gl.glClearColor(0.f, 0.f, 0.f, 1f);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glColor4f(1f, 1f, 1f, 1f);
gl.glPushMatrix();
gl.glTranslatef(width/2, height/2, 0.0f);
gl.glRotatef(360 * input, 0.0f, 0.0f, 1.0f);
bgQuad.setX(0);
bgQuad.setY(0);
bgQuad.draw(gl);
gl.glPopMatrix();
}
glPopMatrix
resets the matrix back to the most recent saved matrix and throws away the current matrix.
Upvotes: 1