Jump to content
  • Advertisement
Sign in to follow this  
Gibble

OpenGL Rotating a model...

This topic is 2583 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all,

I've written an OBJ loader, which imports a model (eg a spaceship) from Blender into a vertex buffer object. I can display it, translate, rotate ok in OpenGL

I'm trying to speed up processing and understand better what I'm doing. One thing that I currently do, is every frame, translate and rotate the object dependant on the direction its facing and distance (also dependant on the starting orientation of the object).

This feels like its the wrong way to do this. It feels like it would be less processing to only apply a rotation once to the Object when its rotated, and then reupload a new Buffer Object in the rotated state ? That way I have only rotated it once, and don't need to redo the rotation every frame.

Does my thinking make sense ? If so, could someone point me in the right direction of how I would start on that, or a better method than what I'm thinking, or why it won't work (my head is starting to go fuzzy, and not sure where to look!).

Tia

Share this post


Link to post
Share on other sites
Advertisement
No it does not make sense:


That way I have only rotated it once, and don't need to redo the rotation every frame.
[/quote]
So each object regardless if this is 1 object or an object like a tree that is used 50 times, you still have to draw it somewhere. You would still call glLoadIdentity() loading a 4x4 matrix. If you apply your transform, you can call glGetDoublev() to get the matrix and instead of glLoadIdentity() just call glLoadMatrixf(). So use the identity matrix or this saved matrix, same cost and math on the GPU. So no you don't want to call glRotate/glTranslate every frame, save that if it never during the game rotates or translates again.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!