# Opengl Rotation Doubt

Page 1 of 1

## 2 Replies - 749 Views - Last Post: 29 September 2012 - 10:07 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=292431&amp;s=15119f951b7acf2b8956ee9eeea02384&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 el_pancho

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

# Opengl Rotation Doubt

Posted 18 September 2012 - 10:44 PM

hi guys,

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

• フカユ

Reputation: 1037
• Posts: 4,305
• 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.

### #3 mmakrzem

Reputation: 5
• 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