How to rotate a specific object in openGL?

前端 未结 2 1730
独厮守ぢ
独厮守ぢ 2020-12-14 11:01

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 (r

相关标签:
2条回答
  • 2020-12-14 11:27

    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 ...
    
    0 讨论(0)
  • 2020-12-14 11:30

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

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

    OpenGL Rotation

    0 讨论(0)
提交回复
热议问题