Advertisement

Rotating...

Started by June 22, 2003 01:13 PM
3 comments, last by ECHOGamer 21 years, 8 months ago
Hi... I just started to learn OpenGL programming and I stumbled on a problem. When I use glRotatef() function, it rotates ALL objects that I make later. I have a solution, use glRotatef() with opposite parameters, but that''s a waste of time and resources. Isn''t there a simplier way??? Just to make things clear here is an example: glRotatef(...); creating triangle; creating square; I want to rotate only the triangle, but the square is rotated also... Help? -=*ECHO*=-
-=*ECHO*=-
try glLoadIdentity(); between independant draw''s...
Advertisement
glPushMatrix();
glRotatef(...);
creating triangle;
glPopMatrix();

creating square;

Learn to push and pop matrix's, it makes life much easier when trying to establish complex movement with objects. (IE 2 things moving independently with-in a movement that they both have)



[edited by - skow on June 22, 2003 8:40:25 PM]
Gee, thank you, guys. Your methods work, but I will probably go with skow''s method, but wamingo, thank you too.


-=*ECHO*=-
-=*ECHO*=-
skow''s solution is MUCH more desirable. If you say translate -30.0f before each frame, and want the whole scene to be drawn there, then calling LoadIdentity() will bring u back to the very origin, so you''ll have to do your world translations again. push and pop matrix are the way to go.
GSACP: GameDev Society Against Crap PostingTo join: Put these lines in your signature and don't post crap!

This topic is closed to new replies.

Advertisement