Jump to content

  • Log In with Google      Sign In   
  • Create Account


How can I move models if glTranslate is deprecated?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 TRONJon   Members   -  Reputation: 218

Like
0Likes
Like

Posted 14 April 2014 - 10:26 AM

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



Sponsor:

#2 mhagain   Crossbones+   -  Reputation: 7865

Like
3Likes
Like

Posted 14 April 2014 - 11:05 AM

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, 14 April 2014 - 11:06 AM.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#3 TRONJon   Members   -  Reputation: 218

Like
0Likes
Like

Posted 15 April 2014 - 02:37 AM

Thank you! I had a feeling someone would say this :)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS