Jump to content
  • Advertisement
Sign in to follow this  
juglar

OpenGL Object::Render() or not

This topic is 3670 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!! until now i had in my engine a lot of classes representing a 3d Shapes an all the hierarchical repesentation, each one of this calsses had a render method to perform the draw using opengl command, so far so good, but i asking it's better(in terms of performace) avoid the render method in each one of the classes and put a new one called, for instance... getObjVertexs(), and a "main" render class going throw a scenegraph, calling getObjVertexs() of each object and rendering it?? thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
If your render function is not part of your renderable object, you will have more flexibility. For instance, you can batch stuff by state and only set OpenGL state once for a set of objects rendered with the same state, or sort the objects front-to-back and back-to-front before drawing them, which is a bit more difficult to do if you just iterate over all objects and call Object::Render() (but you could still do that if you add them to a list and sort them before calling render() on each one)

I find that, since I am already grabbing geometry chunks from objects and sorting them, it makes more sense to me conceptually to keep the rendering stuff separate, too.

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!