How shall i code my renderer

Started by
1 comment, last by Basiror 20 years ago
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?
http://www.8ung.at/basiror/theironcross.html
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.
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
http://www.8ung.at/basiror/theironcross.html

This topic is closed to new replies.

Advertisement