Original Post
I''m thinking of ways to implement multiple renderers in my game. The engine has thus far been written using Direct3D, but I am adding OpenGL (and eventually Glide support when I get my blasted Banshee to work) support.
The graphics class layout before was as follows:
CGraphics - a class, accessed Direct3D directly, handles renderstates and page flips / updates.
CSprite3D - also a class, also used the D3D renderer directly, but used managed textures and stored colors, positions, alpha, etc. Also renders triangles / quads.
CTexture - a texture class and texture-manager linked list that (again) used D3D.
What I''m trying to figure out is the best way to support multiple renderers using higher-level code. What I''ve come up with:
CGraphics - takes on the ability to render quads and polys (from CSprite3D), as well as manage textures in a dynamic array or linked list.
CSprite3D - only manage sprite coordinates and "texture references" (name or index or serial code or something similar). Makes calls to CGraphics to render quads, set renderstates, etc.
CTexture - manages higher-level access to textures, such as name, file size, and void pointers to CGraphics texture data.
In addition, a pair of .cpp/.h files per renderer, that manage how function calls are made. Methods stored in CGraphics are actually function pointers, that are initialized when the CGraphics object is allocated, and are called at a higher-level. All API-specific functions and object accesses are stored herein.
Comments? Ideas?
MatrixCubed
http://MatrixCubed.org
http://MatrixCubed.org