How do I rotate or translate individual object instances in OPENGL?
Lets say i have a scene with four cubes. How do开发者_开发知识库 I say rotate/translate only two of these cubes in OpenGL without changing the others using glrotatef anf gltranslate? I dont wanna define my own homogeneous co-ordinates.
- You draw your first two cubes as usual
- Push the view-model matrix (
glPushMatrix(GL_MODELVIEW_MATRIX)
) - Call glRotate/glTranslate to setup the rotation of the two cubes which you want to draw in a different way
- Draw the other two cubes
- Pop the original view-model matrix (
glPopMatrix(GL_MODELVIEW_MATRIX)
)
精彩评论