Jump to content
  • Advertisement
Sign in to follow this  
Khaos Dragon

OpenGL question on best way to store keyframe models

This topic is 5116 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

I just started using direct3D (used to openGL) and am now implementing a model loader into my code. While I usually highly optimized code for my terrain, sky, static models, and other geometry, I usually defaulted to immediate mode for animated models so that I wouldn't have to store each frame in memory. However, in direct3D there doesn't seem to be an immediate mode (I guess the closest analogy would be to create a new vertex buffer each frame, render from it, and then release it). I am wondering if when I load in my models, if I should create a separate vertex buffer for each frame, or simply load up the current frame during a game loop into a vertex buffer and then release it afterwards.

Share this post


Link to post
Share on other sites
Advertisement
I think you need a dynamic vertex buffer, that is, a vertex buffer optimized to be locked/changed/unlocked every frame.
To create it, use CreateVertexBuffer() passing D3DUSAGE_DYNAMIC to the second parameter.
Now every frame you Lock() the vertex buffer getting a pointer to the memory, modify the vertices (for example you can do time-based interpolation between two key-frames), Unlock() it and finally draw.
You can keep the key-frame information in your own structures, they don't need to be in a vertex buffer as they are not directly drawn, they are just used to create the real vertex buffer.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!