Game Engine API Support
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
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();
}
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();
}
^^
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement