Jump to content
  • Advertisement
Sign in to follow this  
janisoft27

Game Engine API Support

This topic is 4812 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

Hello All I have been working on a game engine that currently supports directX. I have a macro that allows support for directx 8 and directx 9. I am currently interested in learning/using opengl. I guess my question is can i do a macro or some kind of check to use directx or opengl. I want to add this to the current code base instead of keeping 2 copies of the same project (one in DirectX one in OpenGL). Also if you could give me insight as to how bigger compaines/ support both api's in there game engines

Share this post


Link to post
Share on other sites
Advertisement
They usually abstract away all Render calls into 1 class.

EG

class Renderer()
{
virtual void drawModel() = 0;
virtual void bindTexture() = 0;
etc...
}

class OpenGLRenderer : public Renderer
{
overload the base class functions and implement them in opengl

}

class DX9Renderer : public Renderer
{
overload the base class functions and implement them in opengl

}


In your main code, once user has chosen the api of choice,

if(choice == OPENGL)
{
Renderer* r = new OpenGLRenderer();
}
else
{
Renderer* r = new DX9Renderer();
}

Share this post


Link to post
Share on other sites
^^

That is exactly what you want to do, in my engine I need the renderers abstracted and in their own seperate DLLs so I only load the one that I need to use.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!