DirectX AND OpenGL

Started by
8 comments, last by Khaos Dragon 18 years, 6 months ago
is it possible for my game engine to use either DX or OGL? or both?? such as OGL graphics and DirectSound? or some other combination? what about both doing graphics?
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
Advertisement
Yes, it can work.

Direct3D and OpenGL won't necessarily play nice as they're both going to be trying to use the same hardware and do the same thing. Using OpenGL for graphics and XInput/DInput for your controller and DirectSound for audio seems to be a fairly common combination.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

It's possible for both to do graphics, I'm just not sure if at the same time. Some 3D rendering packages give you the option to render in OpenGL or Direct X. You just have to design your rendering engine so it's flexible enough to use different APIs.
Ogre is an example of an engine that has renderers for both OpenGL and Direct3D. You'll notice that they have abstract classes which act as a template for the rendering system so that you can make a new renderer for pretty much any API you want to.
Rob Loach [Website] [Projects] [Contact]
Please, correct me if I'm wrong, but I think you can't use OpenGL and Direct3D at the same time (they couldn't use the same graphic device at the same time).
The engines allow us to select the graphic API (OGL or D3D) before the application starts. That is, I think it is not possible to render, in the same viewport, one mesh using D3D and another mesh using OGL.
I'm probably wrong but there should be no reason why you can't use two graphical API's at the same time. I know people who have used regular renderers and raytracing at the same time (for things like hair).

You should be able to happily draw several objects to seen in DirectX, and then loop through the other objects in openGL. All your doing as adding data to the framebuffer and it shouldn't care where the information comes from.

What you will have problems with is that openGL and DirectX have their Z axes pointed in different directions. You have to mess around with the geometry. Per frame this would be way too slow.

I'm a bit confused by the initial post tho. Do you want to using both at the same time...or do you want to be able to switch from DirectX to OpenGL just as you would change resolution?
Of course you can use both APIs at the same time - if you have multiple adapters* [wink]
* complete and total assumption

But yeah, if you want to achieve something like what Orge does, its not altogether to abstract the APIs and have a common interface. The only hard part is when you get into the more advanced stuff and not everything matches up exactly.
Of course you can use both simultaneously. I'm running Duke Nukem MP (Direct3D8) and a NeverBall (OpenGL) simultaneously in two separate windows right now.
You could use OpenGL for graphic rendering, DirectInput for input handling and SDL for window management...... Although I don't really see the point.
Rob Loach [Website] [Projects] [Contact]
Quote:Original post by doynax
Of course you can use both simultaneously. I'm running Duke Nukem MP (Direct3D8) and a NeverBall (OpenGL) simultaneously in two separate windows right now.


I guess there might be a problem if you use both APIs on the same render target, you could however use both if you delegate a separate render target to each.

This topic is closed to new replies.

Advertisement