Multi-Api Render engine

Started by
5 comments, last by juglarx 18 years, 1 month ago
Hi guys! if a need to do a 3D-engine with multi api rendering support(OpenGl and DX) what is the best approach?. dll interface with the both api implementation is ok i think (myengineOGL.dll and myengineDX.dll) anyone have a cool implementation ( ideas ,101 steps....) of this to share? thanks in advance
Advertisement
yeah Ogre
Quote:Original post by juglarx
Hi guys! if a need to do a 3D-engine with multi api rendering support(OpenGl and DX) what is the best approach?. dll interface with the both api implementation is ok i think (myengineOGL.dll and myengineDX.dll) anyone have a cool implementation ( ideas ,101 steps....) of this to share?
thanks in advance

This is pretty much identical to the approach I'm taking in my engine design. I have a base interface class which the actual implementation inherits from (OpenGLDrv.dll/DX9Drv.dll) and my RenderController dynamically loads the DLL at run-time based on configuration. This should hopefully allow the system to be easily extensible once DX10 is released unless the API goes through a major overhaul but that's my hope anyways.
thanks for the help i download Ogre

@ Permafried- so , you have a function like

void MyEngine::drawVertex(VBuffer& vbuffer ) {

renderVertex(vbuffer);// this function is in DLL for DX and OGL
}

is that "pseudo code" an approach of the idea?
thanks for the help i download Ogre

@ Permafried- so , you have a function like

void MyEngine::drawVertex(VBuffer& vbuffer ) {

renderVertex(vbuffer);// this function is in DLL for DX and OGL
}

is that "pseudo code" an approach of the idea?
Something similar to that yes. When my RenderController is initialized it checks configuration and dynamically loads the correct library at runtime (I have an exported function which accepts a pointer to an IRenderDevice pointer). So I have something similar to the following:

class IRenderDevice{   IRenderDevice( void );   virtual ~IRenderDevice( void );   virtual void SetShader( params required to set shader ) = 0;   ...};class CDX9RenderDevice : public IRenderDevice{   CDX9RenderDevice( void );   virtual ~CDX9RenderDevice( void );   virtual void SetShader( params required to set shader );   ...};class COGLRenderDevice : public IRenderDevice{   COGLRenderDevice( void );   virtual ~COGLRenderDevice( void );   virtual void SetShader( params required to set shader );   ...};


When it comes time to use the device in my engine I do something similar to the following:

IRenderDevice* pRenderDevice = 0;// code in here to load the DLL dynamically and create the device (will either return a new CDX9RenderDevice() or new COGLRenderDevice() through extern function)...// i only do it through an extern function because of my architecture there's a number of ways to accomplish thispRenderDevice->SetShader( param );


Hope that helps but it will also totally depend on the architecture of your engine and where you house which objects and interfaces.
thanks!! that's very userful :)

This topic is closed to new replies.

Advertisement