2 Replies - 607 Views - Last Post: 29 September 2012 - 10:07 AM Rate Topic: -----

#1 el_pancho  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 88
  • Joined: 26-April 12

Opengl Rotation Doubt

Posted 18 September 2012 - 10:44 PM

hi guys,

i was wondering about a "issue" that i had.

if i draw 3 cubes like

running = true;

while(running)
{
 drawCube1();
 drawCube2();
 drawCube3();
}




how do i do to make JUST the cube 2 to rotate?

Because doesn´t matter where i put
glRotatef(rotation, 1f, 1f, 0f);



all the cubes rotate.

Is This A Good Question/Topic? 0
  • +

Replies To: Opengl Rotation Doubt

#2 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1000
  • View blog
  • Posts: 4,181
  • Joined: 14-February 08

Re: Opengl Rotation Doubt

Posted 19 September 2012 - 01:16 AM

You need to use your good friends glPushMatrix and glPopMatrix around your drawing of cube 2.
Was This Post Helpful? 0
  • +
  • -

#3 mmakrzem  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 56
  • Joined: 11-January 08

Re: Opengl Rotation Doubt

Posted 29 September 2012 - 10:07 AM

The general idea is you rotate (+X) degrees, render, and then rotate (-X) degrees to reset and then render the rest of your stuff. That is basically what glPushMatrix and glPopMatrix will do for you. You reset your matrix back to what it was before you changed it with glRotate
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1