   Saving global scene transform?
  Hi,I'm drawing some textures to my 2D scene. They each have a draw function like:void Sprite::draw(){    // Rotate and translate scene to where we need to be drawn.    glTranslatef(m_location.x, m_location.y, 0.0f);    glRotatef(m_rotation, 0, 0, 1);// Put texture on screen// ...// Restore scene to previous rotation and translate.    glRotatef(-m_rotation, 0, 0, 1);    glTranslatef(-m_location.x, -m_location.y, 0.0f);}It works, but my scene starts to jitter a little bit as more sprites are drawn - I think it's because of the floating point accuracy in the two rotations above. For example, I comment out the rotate part, then no more jitters.Is there an opengl method to store the current global transforms, then restore it, instead of doing it manually like I'm doing?And is this method of drawing really inefficient - I thought it would be ok because I'm letting opengl compute the transformation matrix - but I don't know if doing it on the whole scene has some really bad performance hit,Thanks   
glPushMatrixAbout efficiency: What realy is inefficient here is that your drawing every textured quad by itself (using imidiate mode I suppose? i.e. using glVertex3f?). A more efficient way would be to transform the quads yourself and use vertex arrays or vbos.   ;  Ok using glPushMatrix() and glPopMatrix() seems to do what I want, but is it wildly inefficient to do this for each sprite:void Sprite::draw(){    // Rotate and translate scene to where we need to be drawn.    glPushMatrix();    glTranslatef(m_location.x, m_location.y, 0.0f);    glRotatef(m_rotation, 0, 0, 1);// Put texture on screen// ...    // Restore scene to previous rotation and translate.    glPopMatrix();};I mean, I might have 1000 sprites to draw or something - is calling glPushMatrix() / glPopMatrix() for each of them going to be efficient?Thank you   ;  Ah hi sebbitt, sorry I just saw your post after I sent my second one. Yeah glPush/PopMatrix works well, thanks.I'm probably using a horribly inefficient method for drawing the textures, this is it:GLfloat width  = (GLfloat)_width * _maxS;GLfloat height = (GLfloat)_height * _maxT;const GLfloat squareVertices[] = {    -width / 2, -height / 2,0.0,width / 2, -height / 2,0.0,    -width / 2, height / 2,0.0,    width / 2, height / 2,0.0 };const GLfloat squareTexCoords[] = { // _maxS, _maxT = 1.0f    0, _maxT,    _maxS, _maxT,    0, 0,    _maxS, 0 };glVertexPointer(3, GL_FLOAT, 0, squareVertices);glEnableClientState(GL_VERTEX_ARRAY);glTexCoordPointer(2, GL_FLOAT, 0, squareTexCoords);glEnableClientState(GL_TEXTURE_COORD_ARRAY);    glEnable(GL_TEXTURE_2D);glBindTexture(GL_TEXTURE_2D, _name);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);glDisable(GL_TEXTURE_2D);I lifted this from somewhere and it works, I was going to revisit this later - I just wanted to get a proof of concept working. So you say I should be looking up textures + transforming the quads myself and use vertex arrays or vbos?Thanks   ;  Well, it's always best to draw geometry in as large a batch as possible and get state chages (i.e. setting matrices, textures and so on) down to a minimum.So, the first step to get more performance out of your drawing code I would try to get rid of the state changes per sprite. So, transform the sprites manually and maybe try sorting them by texture (and change the texture only as needed). Next step could be to batch all the sprites that get drawn per frame into a single vertex array (instead of one per quad as you have it right now) and again try to draw as match of them on one go as possible.Oh, and you don't have to set filtering and so on (all the glTexParameter* stuff) every time you use the texture. It's enough to set them once when the texture gets loaded.   