I cover this topic in detail here: http://lspiroengine.com/?p=49
My engine runs on 3 platforms (iOS, Macintosh OS X, and Windows x86/x64) and supports 5 rendering API’s (OpenGL ES 2.0, OpenGL 3.2, DirectX 9, DirectX 10, and DirectX 11).
I use the method described in my post and things are extremely clean and easy to manage. It is always easy to add support for new platforms or API’s.
In a nutshell:
COpenGlStandardTexture : public CTextureBase -OR- CDirectX9StandardTexture : public CTextureBase -ETC.-
CStandardTexture : public *API-specific class here*
The objective is to use as few #ifdef’s (are those allowed in C#? I forgot) as possible. Or whatever way C# has for switching code between multiple platforms.
This keeps the platform-specific code in separate files and simply injects them into a class hierarchy where needed, reducing the mess of trying to handle support for 5 different platforms all inside one file.
The rest of the engine just uses CStandardTexture, which has an interface that does not change across any platforms.
This applies equally well to render targets, vertex buffers, index buffers, shaders, etc.
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums