Function Pointers to DLL functions.

Hi,

I have 2 DLL's.
1: DirectX.dll
2: OpenGL.dll

Both DLL's have the same functions but one handles them using OpenGL and the other uses DirectX.

Now im building a interface which is a class with again, the same functions. I want the constructor of this class to decide which dll to load and asign the right addresses to the member functions. This means that all member functions in this class are pointers to the functions in the dlls.

The reason im doing this is because it will be easy for the developer to switch between opengl and directx. And the developer doesn't need to include/link to the opengl/directx sdk as all this is done within the dll(s).

Is this the best way to do this? And if so, can someone show me a example because im quite stuck.

Thanks,

Ares
Last edited on
I think it'd be easier to use macros.
Maybe you could use an abstract factory to create your adapter. Check out those two design patterns.
Thanks for the tip, i will check it out.

*Edit

It works, perfectly. Thanks mate!
Last edited on
Topic archived. No new replies allowed.