Sign in to follow this  
tommy-t

Rendering structure

Recommended Posts

tommy-t    392
Hi, my question is, "What is the best way to structure rendering code".
Is it better to make a class with a render function that iterates through all game objects
based on there name or type and have no state manager or is it better 
to make a class with functions like drawpolygon, drawmesh, drawline and use it in a state class
or is there something else that works better?
Thank you in advance.

Share this post


Link to post
Share on other sites
Jason Z    6434

It totally depends on what you want to do with your rendering code.  The best way to structure your code is to make it flexible so you can choose the right tool for the job at hand.  My engine allows for both of the mechanisms that you mentioned, but in my case each object carries around its own material information.  The 'state manager' then ensures that there aren't multiple API calls made to set the same data more than once.

 

The latter of your two ideas is usually called an immediate renderer or something similar.  It is generally a higher level object that simplifies the usage of the graphics hardware at the cost of performance.

Share this post


Link to post
Share on other sites
Burnt_Fyr    1665

+1 to what Jason said and or did. Having access to both a typical retained mode , where data is loaded into buffers created and destroyed by the renderer itself, as well as an immediate mode, where you can supply geometry on the fly,is a great boon to debugging("why is this model's lighting not working?, lets draw some normals quick and find out")

 

Every time I poke through Hieroglyphs source I learn something. Most recently it was how nice creating vertex layouts procedurally from user supplied data is, whereas before I had always had predefined Vertex types defined in the graphics lib that my app had to use. When I'm done, I will have the flexibility to complete define data from outside the graphics lib.

Share this post


Link to post
Share on other sites
Jason Z    6434

Every time I poke through Hieroglyphs source I learn something.

That is really great to hear - it makes me happy to know someone is getting some benefit from the engine :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this