Well to start just choose any API opengl or directx whichever you are more comfortable with and keep all low level platform dependent code in seperate directory or library. Create your own custom wrappers for all lowlevel functionality.
For example You can create MyRenderDevice for D3D device, MyVertexBuffer or D3DVertexBuffer, MyWindow to handle window mgt on win32,etc
Then to port your code to new platform lets say opengl you just have to replace these low level classes/libraries.
One interesting way can be done is that you can try to keep header files for MyRenderDevice etc same and make implementations in #defs according to the platform its running on.
A Quick Example
////MyRenderDevice.h
class MyRenderDevice
{
void Init();
void RenderBegin();
void RenderEnd();
}
/////MyRenderDevice.cpp
#if GfxDriver == DirectX11
void Init()
{
ID3D11Device mydevice;
....
}
void RenderBegin()
{
}
void RenderEnd()
{
}
#elseif GfxDriver == OpenGL
void Init()
{
OpenGLDeviceContext mydevice;
....
}
void RenderBegin()
{
}
void RenderEnd()
{
}
#endif
Another Approach can be to make an Interface from which actual RenderDevice Implementations will derive somewhat similar to what Joyal mentioned above but it would be nice to make render in seprate libraries and keep a seprate var for choosing gfxdriver as you may want to run opengl on windows and may want to run different versions of directx (dx9 ,d3d11,etc) on windows -
class IRenderDevice
{
......
}
#if Driver == DirectX11
class RenderDeviceDX11 : IRenderDevice
{
.....
}
typedef RenderDeviceDX11 MyRenderDevice; // or #define
#elseif Driver == Opengl
class RenderDeviceGL : IRenderDevice
{
.....
}
typedef RenderDeviceGL MyRenderDevice; // or #define
#endif
////And later in app
class Scene
{
MyRenderDevice device;
void Render()
{
device->RenderBegin();
...
device->RenderEnd();
}
}
There are many ways to do this but I would also agree with blueshogun96 it will be better to have seperate libraries.
I thing it would be a better if you can spend few days looking at some good open source cross platform engines. Here are the two of many -
WildMagic
Ogre3D
(These engines also keep things in separate libraries)