snakile
snakile

Reputation: 54521

How to rotate a specific object in openGL?

I have some objects on the screen and would like to rotate only one of them. I tried using the glRotatef(...) function but turns out glRotatef(...) rotates all my objects (rotates the camera, maybe?). How can I rotate only one?

I use openGL ES 1.1

Upvotes: 16

Views: 77513

Answers (2)

karlphillip
karlphillip

Reputation: 93410

Tutorial #4 from NeHe shows how to do that precisely.

Also, you might want to take a look at this:

OpenGL Rotation

Upvotes: 4

Jay Kominek
Jay Kominek

Reputation: 8783

You need the rotation to be in effect only when the geometry you're interested in is being drawn.

... draw stuff ...
glPushMatrix();
glRotatef(angle, 0, 1, 0);
... draw rotated stuff ...
glPopMatrix();
... draw more stuff ...

Upvotes: 33

Related Questions