I'm in the process of learning OpenGL and I'm writing a simple 2D game and ran into a problem when trying to rotate my bitmap.
It seems to me that I should be able to push the matrix, rotate it then draw the bitmap. Wouldn't that draw the bitmap rotated?
Here's what I'm doing:
glOrtho(0.0f, g_width - 1.0f, 0.0f, g_height - 1.0f, -1.0f, 1.0f);
glRotatef(rotation_angle, 0.0f, 0.0f, 1.0f);
glDrawPixels(bmpInfoHeader.biWidth, bmpInfoHeader.biHeight, GL_RGB, GL_UNSIGNED_BYTE, bitmapData);
Shouldn't that do it?
Or is there something I'm missing?
Any help would be very appreciated.
Edited by - mkaltner on August 18, 2001 12:15:09 AM
Well, if you want to use a "real" coordinate system for where your ship is located, you going to have to know some trig.
If you are doing something like this: EVENT_UPKEYPRESSED: // genaric keypress event ship.y++;
it''s obvoisly going to move your ship upwards, no matter which direction it''s facing.
if you do something like this: EVENT_UPKEYPRESSED: ship.x += MOVEMENT_FACTOR * cos(GetShipAngle()); ship.y += MOVEMENT_FACTOR * sin(GetShipAngle());
it''s going to move your ship in the direction it''s facing. (Note: sin and cos might be switched depending on what the basis for your angles is). Be sure to convert GetShipAngle() into radians, because OpenGL uses degrees.