Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Basiror

How shall i code my renderer

This topic is 5244 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, I have a little question, about how i should code my renderer So far I have created independant classes to hold data and so on and now i am at the point where i need to start coding the renderer I thought about 2 ways to do it 1. create a class CRenderer which holds functions to which i pass for example a list of polygons clipped against the frustrum, passed through a octree and sorted by texture and let the renderer do all the work -inlining of small often used functions 2. create a namespace and inline all the small functions to avoid function call overhead 1. & 2. contain functions like this to reduce the amount of code you have to write [SRC] inline void AlphaBlend(BOOL bBlend) { if( bBlend == TRUE ) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); } else glDisable(GL_BLEND); }; [/SRC] yes i know both ways are very similar, on the second way i just have a few main render functions that execute the inlined subfunctions in order Which ways do you think is best?

Share this post


Link to post
Share on other sites
Advertisement
in our engine, we have a BaseRenderer class that is API independent. then derived off of that, we have a GLRenderer and a DXRenderer. all common functions between the 2 APIs are virtually declared in the base class (states, flags, etc.)

we have some routines for rendering primitive lists (points, triangles, quads) but we mainly use functions for rendering Mesh objects.

Share this post


Link to post
Share on other sites
my engine used SDL SDL_net OpenGL and OpenAL, so its more or less cross platform, although i develop it for windows

does using a class result in a performance decrease? a little one?

using a namespace to encapsulate all the render functions gives me the possibility to pass pointers of them to a dll so modders can use them to do some custom rendering stuff

Share this post


Link to post
Share on other sites

  • 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!