Sign in to follow this  
juglarx

Multi-Api Render engine

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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 this

pRenderDevice->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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this