Jump to content
  • Advertisement
Sign in to follow this  
TRONJon

OpenGL How can I move models if glTranslate is deprecated?

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

My project I'm working on currently uses features such as Shadow mapping & Skeletal animation... and I'm using alot of OpenGL 4.X commands. I figure it's about time I move on with newer standards and start passing my own matrices to my GLSL shaders instead of using GL_MODELVIEW and such.. this works for situations in which I position my camera.. generate the matrix... upload to the GPU via a GLSL uniform and then draw my scene.

 

But what if i'm drawing particles or lots of objects moving about?

 

Usually I'd do something like:
for(Entity e: somelist)

{

    glTranslate(e.x, e.y, e.z);
   e.drawModel();

}

 

but How would I do this using opengl 4.X standards? Would I have to upload a new matrix before drawing every entity instance?

 

Thanks, Jon

Share this post


Link to post
Share on other sites
Advertisement

Yes, you would have to upload a new matrix, but that's just what a glTranslatef call does.  The only difference is that instead of relying on an OpenGL call to calculate a translation matrix, multiply it by the current matrix, and upload that to the GPU, you get to do it all yourself.

 

It's worth noting here that glTranslatef and friends, despite being OpenGL calls, are not hardware accelerated (the OpenGL spec doesn't actually promise or guarantee that anything will be hardware accelerated).  The GL matrix stack is just a software matrix library that calculates everything on the CPU and uploads the result to the GPU, so you can quite easily replace it with your own choice of software matrix library.

Edited by mhagain

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!