Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

finas

OpenGL differents between openGL and DX

This topic is 6185 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I wrote my 3D engine with openGL, but I want to move it to DX now. How must be Engine which can to work with openGL and DirectX. I don''t want to write 2 differents eng3d. maybe: if ( SETTINGS->VideoCardSupportOpenGL ) __platform = OPENGL else __platform = DX -[finas]-

Share this post


Link to post
Share on other sites
Advertisement
How about using a nice class structure? Something like this:
  
class CRenderer
{
public:
virtual void drawScene() = 0;
...
}

class D3DRenderer : public CRenderer
{
public:
void drawScene();
...
}

class OGLRenderer : public CRenderer
{
public:
void drawScene();
...
}

Then, in your game loop, you can do something like this:
  
CRenderer* pRenderer;
if(renderType == R_OPENGL)
pRenderer = new OGLRender;
else if(renderType == R_D3D)
pRenderer = new D3DRenderer;

pRenderer->applyTransformations();
pRenderer->calculateVis();
pRenderer->calculateLights();
pRenderer->drawScene();

This way, you only have to worry about whether you are using D3D or OpenGL whey you first start your app. All the method calls are the same.

~~~~~~~~~~
Martee

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Use DLLs with a standarized API. Then at runtime, you load the appropriate DLL.

D3D and OpenGL aren''t that different, esp. since DX8, M$ uses more OpenGL like functions. For allmost all OpenGL commands and concepts, you will find a D3D alike. Eg. VertexArrays = VertexBuffers in D3D, I think. But beware: If you are used to the clean, simple and logical programming style of OpenGL, you''ll get some surprises. D3D is made by M$, this should say everything, forget about simplicity. Although D3D8 is a bit better.

Share this post


Link to post
Share on other sites
im doing some similar, only i use only OpenGL, but i do support multiple window managers. the way i found is to have standard functions (like wndCreate()) to do the things different window managers would do. for each OS/window manager i have a different module to compile the functions from. make -fWin32.mak for the windows version, make -fGnome.mak for gnome specifics, make -fglut.mak, etc.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!