c++ - Multiple render systems -
c++ - Multiple render systems -
some time in near future, begin developing game engine. 1 feature want include having multiple render systems such directx 9/10/11 , opengl. way, game using engine able back upwards more players since if 1 render scheme doesn't work, revert different one.
so question, how go doing this? researched bit , saw ogre3d uses have no thought how it. want able plug in different render systems , utilize same code run it.
you create interface class allows farther extend api hoping expand to.
i have done in past create directx9\11 renderer , hoping expand opengl soon. there certainty lot task, easy explain basic working of it. unfortunately project on closed source, if have questions please don't hesitate ask.
first want create separate project used .lib/.dll, called "renderinterface". contain basic interfaces vertexbuffer's, indexbuffer's, shaders, , importantly, irenderinterface , irenderutility, in later implementation potentially hold items such such id3d11devicecontext , id3d11device.
my 2 of import items in "renderinterface" project, irenderinterface , irenderutility. thought here have irenderinterface heavily lifting, such creating render targets, presenting, , initializing api. irenderutility more mutual things, such creating vertex/index buffers, creating shaders , rendering. pass irenderutility around more on initialization , rendering, , irenderinterface passed around. prevent users doing accidental operations when not need to. project include mutual structs\enums used throughout code base.
i create project, such d3d11renderinterface. d3d11renderinterface have implementations of irenderinterface, irenderutlity, ivertexshader, ivertexbuffer, etc.
an overlysimple illustration be
class irenderutility { public: virtual void draw(unsigned int vertexcount, unsigned int vertexstartoffset) = 0; }; class d3d11renderutility : public irenderutility { protected: id3d11devicecontext *md3d11devicecontext; public: void draw(unsigned int vertexcount, unsigned int vertexstartoffset) { md3d11devicecontext->draw(vertexcount, vertexstartoffset); }; };
this works having vertexbuffer , ivertexbuffer beingness set phone call irenderutility, before irenderutility::draw call.
then, in application need load renderinterface project, , api implementation. there other ways this, such #define'ing code throughout code base, imo, messy.
c++ directx system render game-engine
Comments
Post a Comment