TGE Patch: DX9 Support
by Tim Gift · 05/09/2003 (2:54 pm) · 12 comments
Download Code File
[Comments from Nick]
The patch is comprised of two files, the patch itself and a zip file which contains additional files for the OpenGLd3d project; those go into/torque/lib/opengl2d3d/.
Known issues
[Comments from Nick]
The patch is comprised of two files, the patch itself and a zip file which contains additional files for the OpenGLd3d project; those go into/torque/lib/opengl2d3d/.
Known issues
About the author
Recent Blogs
• Plan for Tim Gift• Plan for Tim Gift
• Eclipse Project for Torque
• Scene Lighting Patch
• Plan for Tim Gift
#2
I think we should just drop the DX support for Torque(in its current state) completely. Don't get me wrong. I completely support having a game engine support both API's but I believe in order to get true DX support into Torque, as it is now, would require a lot more infrastructure changes then I think we should do with Torque in its current state. I think when it comes time to make "Torque 2.0" would be more of an appropriate time to discuss how the engine should implement both API's.
05/10/2003 (4:32 pm)
Personally speaking,I think we should just drop the DX support for Torque(in its current state) completely. Don't get me wrong. I completely support having a game engine support both API's but I believe in order to get true DX support into Torque, as it is now, would require a lot more infrastructure changes then I think we should do with Torque in its current state. I think when it comes time to make "Torque 2.0" would be more of an appropriate time to discuss how the engine should implement both API's.
#3
05/11/2003 (11:55 am)
I tend to agree Robert. Though if upgrading the DX wrapper makes it easier for people to play with new DX 9 functions, it could be worth putting in. It's definitely not a long term solution though.
#4
For our project we had removed completally.
05/18/2003 (2:08 am)
i think that drop DX is the best solution. Half of the resources and code, doesn't work in D3D mode.For our project we had removed completally.
#5
nVidia has exposed the features of the FX lines of video cards to OpenGL since before DirectX 9 entered beta.
ATI has exposed the features of the Radeon cards to OpenGL since before DirectX 9 entered beta.
There is no advantage to supporting DirectX in terms of feature set. The features are already exposed and available in OpenGL.
The DirectX support was put there in a day and age when OpenGL drivers really sucked badly, when the major 3D video card vendor had a proprietary API, and when life just generally sucked for game designers. You had a choice between including DirectX support and being able to run on most compuers, or implementing only OpenGL and not being able to run on many computers.
That day is passed now. There's no advantage to supporting both DirectX and OpenGL in the renderer system. One technology or the other is completely adequate for the games needs, and both technologies expose an equal feature set.
So you pick one. OpenGL if you want portability or DirectX if you want to run only on Windows-based platforms. Torque picked OpenGL, and is designed around it.
The DirectX support is in terms of a wrapper that translates OpenGL calls to equivalent DirectX calls. As such, it will always and forever be slower and less capable than just directly calling the OpenGL driver. The driver will always provide a lower capability visual than the native GL driver can.
I am not saying that DirectX sucks -- what I'm saying is that in order to support each new feature, the wrapper must be updated. In order to support vertex programs, the GL_ARB_vertex_program extension, for example, would need to be implemented in the DLL. This would have to translate the feature from OpenGL to DirectX. If the vertex_programs are similar (I believe them to be), the call might be pretty fast. If the vertex_programs are divergent, it could take a lot more effort.
In the case someone was implementing these features, you could have a lot of kludges and system-dependent code end up in the (currently) platform neutral OpenGL code.
It is a lot better to simply not support DirectX at all.
Implementing the DirectX 9 features via the OpenGL equivalent extensions has another significant advantage. The Linux and Macintosh video drivers for ATI, nVidia and Matrox cards will automatically pick up the new features as well if you use pure OpenGL, while if you use DirectX equivalent calls, these other platforms won't pick up the features -- even though they support them.
There was a day and age when the OpenGL support on video cards was fairly primitive, and when there were a lot of bugs (especially in the non-Matrox drivers). Today, the drivers are decent and capable.
07/07/2003 (5:44 am)
Torque uses OpenGL. I have also removed the DirectX driver.nVidia has exposed the features of the FX lines of video cards to OpenGL since before DirectX 9 entered beta.
ATI has exposed the features of the Radeon cards to OpenGL since before DirectX 9 entered beta.
There is no advantage to supporting DirectX in terms of feature set. The features are already exposed and available in OpenGL.
The DirectX support was put there in a day and age when OpenGL drivers really sucked badly, when the major 3D video card vendor had a proprietary API, and when life just generally sucked for game designers. You had a choice between including DirectX support and being able to run on most compuers, or implementing only OpenGL and not being able to run on many computers.
That day is passed now. There's no advantage to supporting both DirectX and OpenGL in the renderer system. One technology or the other is completely adequate for the games needs, and both technologies expose an equal feature set.
So you pick one. OpenGL if you want portability or DirectX if you want to run only on Windows-based platforms. Torque picked OpenGL, and is designed around it.
The DirectX support is in terms of a wrapper that translates OpenGL calls to equivalent DirectX calls. As such, it will always and forever be slower and less capable than just directly calling the OpenGL driver. The driver will always provide a lower capability visual than the native GL driver can.
I am not saying that DirectX sucks -- what I'm saying is that in order to support each new feature, the wrapper must be updated. In order to support vertex programs, the GL_ARB_vertex_program extension, for example, would need to be implemented in the DLL. This would have to translate the feature from OpenGL to DirectX. If the vertex_programs are similar (I believe them to be), the call might be pretty fast. If the vertex_programs are divergent, it could take a lot more effort.
In the case someone was implementing these features, you could have a lot of kludges and system-dependent code end up in the (currently) platform neutral OpenGL code.
It is a lot better to simply not support DirectX at all.
Implementing the DirectX 9 features via the OpenGL equivalent extensions has another significant advantage. The Linux and Macintosh video drivers for ATI, nVidia and Matrox cards will automatically pick up the new features as well if you use pure OpenGL, while if you use DirectX equivalent calls, these other platforms won't pick up the features -- even though they support them.
There was a day and age when the OpenGL support on video cards was fairly primitive, and when there were a lot of bugs (especially in the non-Matrox drivers). Today, the drivers are decent and capable.
#6
08/06/2003 (12:41 am)
cross vendor opengl pixel and vertex shaders were certainly not available before dx9, and are still not available (cross vendor) in any working capacity.
#7
(ie, one of the attractions to Torque for me is the DX support, although it sounds like it might not all be there?)
08/24/2003 (10:54 am)
In terms of dropping DX support in Torque, what are the ramifications of this with Microsoft removing OpenGL support from Windows? I ask because it seems that new installs of XP do not have H/W OpenGL support and updating 98/ME/2K/XP can remove that support. This means that end users must upgrade video drivers which they are often not able to do (esp. causual gaming market) and is causing me a lot of tech support on my OpenGL games.(ie, one of the attractions to Torque for me is the DX support, although it sounds like it might not all be there?)
#8
08/25/2003 (11:18 am)
Lane, we're not planning on dropping DX support. The Torque engine currently auto-detects OpenGL vs DirectX, which seems to work pretty well for our current products. We're not happy with the way it's integrated into the engine, but that's different issue. I doubt we'll be integrating this patch though.
#9
11/06/2003 (9:30 pm)
i'm missing files D3d9.h and d3dx9.h ?? or is this just my error?
#10
Yeah, I did modify TGE's OpenGL to DX wrapper to use DX9 for to see if I could use HLSL shaders with Torque. Yeah, I got it working, but my conclusion (same as a few others independently came to)... it's absolutely not worth it. Stick with OpenGL. Furthermore, if you really want DX9 support in TGE, implementing DirectX support through an OpenGL wrapper isn't the best approach. There are issues with uneccessary copying of entire vertex buffers on every frame (among other things).
Yes, there is a lot of Microsoft example code that had to do with initialization of DX9 (the initialization shortcut present in Direct3D7 is not supported in Direct3D9).
Although the initialization code can certainly be rewritten without too much effort, I have no plans to do so I no longer think a OpenGL to DX9 wrapper is of much value.
If you are really really really curious, you do need the DX9 SDK in order to use the patch. But again, I strongly recommend sticking with OpenGL.
12/14/2003 (6:41 am)
Hehe, I stumbled on this thread by accident ... Yeah, I did modify TGE's OpenGL to DX wrapper to use DX9 for to see if I could use HLSL shaders with Torque. Yeah, I got it working, but my conclusion (same as a few others independently came to)... it's absolutely not worth it. Stick with OpenGL. Furthermore, if you really want DX9 support in TGE, implementing DirectX support through an OpenGL wrapper isn't the best approach. There are issues with uneccessary copying of entire vertex buffers on every frame (among other things).
Yes, there is a lot of Microsoft example code that had to do with initialization of DX9 (the initialization shortcut present in Direct3D7 is not supported in Direct3D9).
Although the initialization code can certainly be rewritten without too much effort, I have no plans to do so I no longer think a OpenGL to DX9 wrapper is of much value.
If you are really really really curious, you do need the DX9 SDK in order to use the patch. But again, I strongly recommend sticking with OpenGL.
#11
nm... I'll apply this to a clean 1.3 sdk. I'm going to try removing opengl completely and replacing the wrapper with full dx 9 support.
edit 2:
patch fails at 1.3...
08/06/2005 (8:14 am)
edit:nm... I'll apply this to a clean 1.3 sdk. I'm going to try removing opengl completely and replacing the wrapper with full dx 9 support.
edit 2:
patch fails at 1.3...
#12
02/18/2006 (5:20 am)
What about Windows Vista, which will not support OpenGL as much as D3D? 
Torque Owner Tim Gift
There are some outstanding issues with it and probably the biggest is that the patch includes quite a bit of Microsoft example code. My understanding is that their example code is copyrighted "all rights" reserved and cannot be re-distributed, but I could be wrong.
I've written to Nick but haven't heard from him in a while so I'm posting the patch here temporarily. I'll remove the patch if no one has time to work on it, or something else turns up...