Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
475 views
in Technique[技术] by (71.8m points)

rotation - 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 ...

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...