Hi Everyone,
I'm currently writing my own game/engine, which works in a pretty similar way to the GCC4 code, except that I'm making it cross-platform since I spend a lot of time switching between Linux and Windows. As a result I'm currently using SDL(and thus OpenGL) for my graphics rendering, but I'm not sure if it'll give me the kind of flexibility I'm looking for. Right now I just want "Something to render 3d graphics easily", but at a later point I may want to dig more into the graphics side, and use raw OpenGL, or somthing more established like Ogre3D.
What I'm looking to do therefore is add an abstraction layer for graphics rendering, so that I can plug in which ever renderer I like. I read about GCC4's IRenderer interface for abstracting graphics, and decided to take a look at the code, but it doesn't seem to be quite how I expected. I was expecting to see IRenderer implement functions like DrawLine(), DrawMesh(), DrawTriangleStrip(), ToggleFullscreen() etc. so that I could pass the interface my game data, and the implementations of IRenderer would determine how to perform that action. Thus allowing the rest of the code to only care about IRenderer.
However there seems to be quite a lot of other parts of the code in GCC4 that hook directly in to the current renderer. For example creation of the D3D device is done directly in GameCodeApp::InitInstance(). Similarly there are indicidual scene nodes for both D3D 9 and 11, and multiple places in RenderComponent.cpp where it has to test which renderer is being used and perform different actions.
My question is whether there is a better way to abstract the renderer? Is the GCC4 code this way, because there is a fundamental flaw in the approach I described, or is it simply because the engine wasn't expected to use anything other than directX? It'd be great to get opinions before I program my way into a dead end.
Thanks!
I'm currently writing my own game/engine, which works in a pretty similar way to the GCC4 code, except that I'm making it cross-platform since I spend a lot of time switching between Linux and Windows. As a result I'm currently using SDL(and thus OpenGL) for my graphics rendering, but I'm not sure if it'll give me the kind of flexibility I'm looking for. Right now I just want "Something to render 3d graphics easily", but at a later point I may want to dig more into the graphics side, and use raw OpenGL, or somthing more established like Ogre3D.
What I'm looking to do therefore is add an abstraction layer for graphics rendering, so that I can plug in which ever renderer I like. I read about GCC4's IRenderer interface for abstracting graphics, and decided to take a look at the code, but it doesn't seem to be quite how I expected. I was expecting to see IRenderer implement functions like DrawLine(), DrawMesh(), DrawTriangleStrip(), ToggleFullscreen() etc. so that I could pass the interface my game data, and the implementations of IRenderer would determine how to perform that action. Thus allowing the rest of the code to only care about IRenderer.
However there seems to be quite a lot of other parts of the code in GCC4 that hook directly in to the current renderer. For example creation of the D3D device is done directly in GameCodeApp::InitInstance(). Similarly there are indicidual scene nodes for both D3D 9 and 11, and multiple places in RenderComponent.cpp where it has to test which renderer is being used and perform different actions.
My question is whether there is a better way to abstract the renderer? Is the GCC4 code this way, because there is a fundamental flaw in the approach I described, or is it simply because the engine wasn't expected to use anything other than directX? It'd be great to get opinions before I program my way into a dead end.
Thanks!
The post was edited 1 time, last by Claxon ().