Original Post
For my next game I want to seperate all the graphics code from the engine code itself and store it in a seperate DLL. The main reason is I want to support different API''s for the game (will be 2d), without having to code special functions for each type of API I want to support.
I have run into a problem, and I am not sure about the solution. It is quite clear that DirectDraw, Direct3d and OpenGL are quite different.
My question is this, what is the best way to make generic functions that I can call from the engine to draw stuff, for each API? One of my friends said that my solution lies in a "bridge" design between the engnie and the rendering DLL.
I was fooling around a couple nights ago and I made simple DLL for DirectDraw and OpenGL, that had three simple functions.
I was able to get the DirectDraw DLL as well as the OpenGL renderer to work, but it was sloppy and I didn''t see how to allow passing certain parameters to each function. For example, I have a DirectDraw lib that has a class, SurfaceObject, that has a bunch of funcitons that allow me to manipulate that direct draw surface and such, but if I made a function that had a SurfaceObject parameter, how would I do this for the OpenGL renderer?
Sorry for the long babble, but I am curious if any of you have a solution to this, know of any tutorials that explain this, or can offer some suggestions.
Thanks
------------------------------
"I''m a decorated astronaut, I don''t make those kind of mistakes."
"Oh now wait a minute. Look I''ll show ya. I''ll enter the same calculations using what we like to call ''The Right Way''."
-Rem
ApiStart(char szName[], int iWidth, int iHeight, bool bFullscreen, int iBitDepth); ApiUpdate(); ApiDisplay(); |