Hi.
I will be creating a game engine in the future based on ogre3d using qt and supports both dx and opengl while qt uses opengl but dx can be added since it's open source. (future plan)
The question is how does ogre3d manage to do this hybrid job because i will probably use the same functionality in my engine except it is not feasible for an engine since ogre3d is only a render engine.
Thanks
How does ogre3d manage opengl and directx
-
- Gnoblar
- Posts: 9
- Joined: Fri Nov 29, 2013 1:38 pm
- Klaim
- Old One
- Posts: 2565
- Joined: Sun Sep 11, 2005 1:04 am
- Location: Paris, France
- x 56
- Contact:
Re: How does ogre3d manage opengl and directx
Basically, it have different modules for different rendering interface. You can see dlls for directx, dx11, gl and gl3+, also GLES (for android and iPhone).
How it works is that Ogre define an interface (a virtual base class) that have to be implemented for any render system implementation. So OgreMain doesn't know if it's DX or GL that it uses, it just manipulate the interface. The implementation is a different module that is loaded at runtime, so you can even choose before running the application.
It's nothing magic: there is a different project for each render system implementation.
Beware though: except if you use something like CG (there are other alternatives), you can't write shader code that will work for both GL and DX render systems. This mean that even if Ogre is helping your C++ code to ignore what is the render system used, you still have to have either different shader sources for different render systems, or have some tools that do the work for you, like CG (which currently is not really a good choice apparently). Or you can stick to OpenGL/GLSL and have maximum compatibility, with potential drawbacks on Windows but I'm not an expert on this.
How it works is that Ogre define an interface (a virtual base class) that have to be implemented for any render system implementation. So OgreMain doesn't know if it's DX or GL that it uses, it just manipulate the interface. The implementation is a different module that is loaded at runtime, so you can even choose before running the application.
It's nothing magic: there is a different project for each render system implementation.
Beware though: except if you use something like CG (there are other alternatives), you can't write shader code that will work for both GL and DX render systems. This mean that even if Ogre is helping your C++ code to ignore what is the render system used, you still have to have either different shader sources for different render systems, or have some tools that do the work for you, like CG (which currently is not really a good choice apparently). Or you can stick to OpenGL/GLSL and have maximum compatibility, with potential drawbacks on Windows but I'm not an expert on this.