PDA

View Full Version : Converting matrix coordinates?



SkyAphid
05-31-2012, 06:43 AM
So, I'm working on this project, and it's isometric 2D. So naturally, I render the terrain like this:


glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(Display.getWidth()/2, Display.getHeight()/2, 0);
glScalef(1, 0.5f, 1);
glRotatef(45, 0, 0, 1);
glTranslate(-camX, -camY, 0);
//Render Tilemap


Problem is, the rotation and scaling happens to the currently a white 16x16 quad player. So, I figured I'd push the matrix before transformation and pop it afterwards, but now the player is no where to be seen, but the screen still stays where he should be; which means he's just being drawn at the wrong place.

So, I need to draw him in the right place, but I don't know how to go about it. I'm still new to OpenGL, so I don't know if there's a way to use the difference in the Matrices to convert the coordinates somehow so that his "Drawing Coordinates" are as they would be if he was still being rendered isometrically, or if I should go about this another way.

Thanks.