You want to call glLoadIdentity before anything else, and remember that the commands are on a stack, so are processed in "reverse" order.
The glLoadIdentity will reset everything, so your matrix will be at 0,0. This means you draw, rotate, then translate; but you push the commands to do this onto the stack in reverse order. Here's what I do: // Load the identity matrix so we always start from 0,0 gl.glLoadIdentity(); // push a copy of the matrix on the stack to manipulate gl.glPushMatrix(); // translate to target coordinates. gl.glTranslatef(x, y, 0.0f); // Scale if needed // gl.glScalef(scaleX, scaleY, 1.0f); // Rotate (must be in degrees) gl.glRotatef((float)Math.toDegrees(angle), 0, 0, 1.0f); // push the draw command last grid.draw(gl); // finally pop the matrix gl.glPopMatrix(); There is NO need to re-translate back anywhere.. and certainly no need to perform an additional rotation as suggested. On Oct 15, 8:42 am, Kostya Vasilyev <[email protected]> wrote: > Add another rotate call before the non-working translate, with the inverse > angle (in your case, the value in 'angle' without the '-'). > > This will reverse the rotation so the translate call can undo the > translation. > > -- > Kostya Vasilyev --http://kmansoft.wordpress.com > > 15.10.2010 1:30 пользователь "Alistair." <[email protected]> > написал: > > Alas, that had no effect. I have _something_ sort of working > > surface.glMatrixMode(GL10.GL_MODELVIEW); > > surface.glEnable(GL10.GL_TEXTURE_2D); > > surface.glBindTexture(GL10.GL_TEXTUR... > Grid.beginDrawing(surface, true, false); > > surface.glPushMatrix(); > > // Draw using the DrawTexture extension. > int drawHeight = texture.getDrawHeight(); > int drawWidth = texture.getDrawWidth(); > float ypos = screenHeight - drawHeight- y; > > surface.glLoadIdentity(); > > surface.glTranslatef(x, ypos, 0); > > surface.glRotatef(-angle, 0.0f, 0.0f, 1.0f); > surface.glTranslatef(-x, -ypos, 0); // THIS NOT DOING WHAT > I THOUGHT WOULD > > texture.getGrid().draw(surface, true, false); > > surface.glPopMatrix(); > > Grid.endDrawing(surface); > > surface.glDisable(GL10.GL_TEXTURE_2D); > What I can't seem to get working now it the re-translate back to the > original point after the rotation. > > On Oct 12, 6:02 am, Kunal Kant <[email protected]> wrote: > > > remove that line " surface.glLoad... > > <[email protected]>wrote: > > > > I am trying to rotate a bitmap in OpenGL. I have searched around and > > > come up w... > > > [email protected]<android-developers%2Bunsubs > > > [email protected]><android-developers%2Bunsubs > > [email protected]> > > > > > > For more options, visit this group at > > >http://groups.google.com/group/android-developers?hl=en... -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

