Hi there,
I’m quite new to OpenGL programming (started yesterday) and I’m pretty sure this is a common problem. However I could not find a decent resource that explains it in detail. Most tutorial aim at 3D stuff - or as I’m new to this area I simply do not know the right words to feed to google.
So heres my problem. Drawing a 2D sprite at position x, y at the screen using OpenGL works pretty forward. But if I want to draw the same sprite rotated e.g. by angle 30* theres where the hassle starts.
Without rotation I’m using glTranslate to move position x,y and then start drawing stuff.
With rotation I tried using glRotate to rotate my sprite around the Z axis. Then I use glTranslate to move to my desired position and start drawing.
So the problem seems to be, that glRotate rotates the whole coordinate system, so my old position x,y is no longer at the same place on the screen.
This means I would have to transform x, y to new coordinates in the rotated coordinate system that match the old screen position.
This seems a bit awkward to me. So I’m wondering if this is the right thing to do or if there are easier/better ways to achieve this simple task of drawing a sprite at a certain position. How would an experienced OpenGL programmer solve my problem?