Hey guys,
I've been fooling around creating an engine just for fun and learning purposes and I decided to focus a bit on cross platform and working with both OpenGL and DirectX.
Now this is working fine so far, I can run the engine with either OpenGL or DirectX, I am however not very pleased with how I achieved this, or at least, I think there must be a way more elegant way of getting this to work properly. Let me explain:
For OpenGL and DirectX to work, I obviously need to have the headers/libraries for these, but I don't want to include the GL headers when compiling for DirectX and vice versa. The way I do this is to simply use #defines and check against these, but it seems very ugly. This is how it looks in general:
#ifdef OpenGL
class GraphicsOpenGL : Graphics
{
// bunch of functions
}
#endif
//////////////////////////////////////////////
#ifdef DirectX
class GraphicsDirectX : Graphics
{
// bunch of functions
}
#endif
The #ifdef is also in the implementation, but just to get my point across.
What other (better?) way is there to exclude certain files that can vary with a build? I can't help but feel this is ugly, but it's also the most common solution I found while searching for this.
I am not really that far in, just context creation and screen clearing, so a total overhaul wouldn't be a problem. Any tips and/or solutions are welcome