Supporting DirectX and OpenGL in 1 engine

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Supporting DirectX and OpenGL in 1 engine

      I am looking to develop my own game engine and have been brainstorming desired features for a while now. Also in this time i learned OpenGL and became comfortable with the API. But as part of my engine i want to implement both Opengl and DirectX and allow end user can pick witch API they wish to use. Either at Launch or during the running of the engine.

      Can you suggest possible ways of implementing this and link any resources you may find useful.
    • If I remember correctly Game Coding Complete discusses this in the chapter on Rendering. Essentially you have an IRenderer class that your DirectX and OpenGL renderers inherit from. Then you just load up whichever renderer the user selects.

      I don't have my book with me at the moment, but I'm sure someone else will chime in who is more knowledgeable than I.
    • Trinak is correct, you'd basically have an interface for the major components of the rendering system and a factory (or factories) to instantiate the concrete objects.

      I don't understand your question. Why would using an interface limit you to Window?

    • In my rendering engine, I actually split up the renderer implementations into multiple libraries, I have my base rendering engine, and a 'GLRenderSystem' library which holds the implementation of the GL renderer. This means that you can selectively add them to your project based on OS (such as through a premake file which is what I use). The other benefit is the ability to create them as a shared library, this way you can (given that the interface doesn't change) drop in a new dll/so file for the renderer whenever it updates.
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz