From OpenGL 2.1 to DirectX 10

Started by
10 comments, last by V-man 15 years, 8 months ago
Hi, I asked these question on the DirectX/XNA forum, but I wanted to get a range of opinions, so I am posting here as well. After reading the OpenGL3 spec I have decided that DirectX is the best choice for the long-term future of our company. I intend to start learning it so the next iteration of our technology can be written using DirectX. This will be at least a year from now, and will probably be longer, but I want to start planning for our long-term future. I have a few basic questions. -What are the key differences between the D3D way of doing things and the OpenGL way? -How far apart are DirectX versions usually released, and how much difference will there be between DX10 and 11? I have heard the transition from 9 to 10 involved significant changes. -Does a program have to be written in C# to run on the XBox? -Does the XBox use DirectX 9 or 10, or some special version? I don't have time to support two APIs, so which is the best version to use? Can I use the same exact code for the XBox and the PC versions? -What is the GPU used in the XBox? Is geometry instancing supported? Is a deferred renderer possible? I have heard Crysis cannot run on the XBox because the console is not powerful enough. C# seems to be the new trend, but C++ provides slightly faster code. Code execution time for a 3D engine isn't that crucial, since the rendering is all on the GPU and physics usually use a third-party library. Would you recommend C++ or C#? I prefer a small manageable source I can quickly edit and test different techniques with. Is there a DX SDK for C#, or is that what XNA is? Is XNA considered the "kiddie" version of DirectX? Is it a disadvantage for writing a high-end renderer? Here is some of our work, by the way. I expect our current technology to be good for a long while, but that doesn't mean I don't need to plan ahead.
Is there anything special in DirectX 10 that is friendlier towards deferred renderers? I heard something about a way to sample pixels that are using MSAA or FSAA. Thanks for your answers.
Advertisement
-What are the key differences between the D3D way of doing things and the OpenGL way?

I can only speak for D3D9, but from the API standpoint there really isn't a big difference. Since most of the heavy graphics work is done in shaders these days, the API differences become less important. For everything else, such as texture management, offscreen rendering, etc .. both API ares equally competent. D3D has the added benefit of Effects, which makes it easier in managing your shaders. To me, the real benefit of D3D over OpenGL is in the driver support/performance. Hardware vendors seem to be on top of their game in D3D drivers, but OpenGL drivers are usually a lot more buggy or are missing support for certain features (even in the core spec).

-Does a program have to be written in C# to run on the XBox?

No, you only have to use C# if you are creating an XNA game. Otherwise, you can write a native c++ application with the XDA (name of the official SDK), but that requires an official devkit from MS.

-Does the XBox use DirectX 9 or 10, or some special version? I don't have time to support two APIs, so which is the best version to use? Can I use the same exact code for the XBox and the PC versions?

I last did Xbox dev a couple of years ago, but at the time they had a special version of the D3D that was somewhere between D3D 8 & 9. I'm assuming that they constantly update their API as the SDK matures. My best guess is that its now some sort of D3D9 incarnation with extra features.

-What is the GPU used in the XBox? Is geometry instancing supported? Is a deferred renderer possible? I have heard Crysis cannot run on the XBox because the console is not powerful enough.

No sure if the current XBox SDK supports geometry instancing, but I don't see why deferred rendering wouldn't be supported, since it can be done as long as rendering to offscreen buffers is possible (which it is).

C# seems to be the new trend, but C++ provides slightly faster code. Code execution time for a 3D engine isn't that crucial, since the rendering is all on the GPU and physics usually use a third-party library. Would you recommend C++ or C#? I prefer a small manageable source I can quickly edit and test different techniques with. Is there a DX SDK for C#, or is that what XNA is? Is XNA considered the "kiddie" version of DirectX? Is it a disadvantage for writing a high-end renderer?

From the functionality point of view, XNA is just as feature rich as the native D3D versions, and it also provides a lot of convenience functions that will save time. In my opinion, its perfect for hobbyists and independent devs that are under more time constraints. For commercial level games/engines, C++ is definately the way to go as managed code is almost always slower than properly optimized native code. For console development, you will likely want to manage your limited amount of memory quite closely, and native C++ is the only way to do this.

Hope this helps!

-Clapfoot
On a side note, don't buy into the current hate thats being thrown around about OpenGL 3.0. Most people on this forum haven't even done enough graphics work to make a credible comment on the spec and I question how closely they've studied the spec. To be honest, for most hobbyist/independent game development work, you wouldn't really even need an API more powerful than OpenGL 2.1 so the fact that OpenGL 3.0 is mostly comprised of promoted extensions isn't really a big deal. While I understand that everyone was expecting a revolutionary "reboot" of the API, I seriously think the current trend of wanting to switch APIs is more of a bandwagon thing than anything else.
Quote:Original post by JKlint
Is there a DX SDK for C#, or is that what XNA is?


Try SlimDX, it's a DX wrapper for C#. It's even developed by gamedev members [smile]
...
My two cents:

If you want to support Windows and Xbox 360, you can use C# and XNA Game Studio. This will allow the same program to run on both, but will limit you to D3D9 level functionality. If that's not enough, then you'll have to use C++, and write special code for Xbox. It's not D3D10 nor D3D9.

Direct3D 10 API is different in some ways from OpenGL and D3D9 (though I haven't used modern OpenGL, so I'm not fluent in it). The API treats resources separately from views, and most things need to be defined in advance. You can't just expect to set states and have things work efficiently. Conceptually it's of course similar to the others, but constructing an engine around it can be a little different than other API's, in some respects.

D3D11 will use an interface similar to D3D10, but will add some abilities. Some of them will be available on D3D10 level hardware, for example a display list sort of functionality (allowing for better multithreading).
Quote:Hi,

I asked these question on the DirectX/XNA forum, but I wanted to get a range of opinions, so I am posting here as well.

After reading the OpenGL3 spec I have decided that DirectX is the best choice for the long-term future of our company. I intend to start learning it so the next iteration of our technology can be written using DirectX. This will be at least a year from now, and will probably be longer, but I want to start planning for our long-term future. I have a few basic questions.


Hello, and welcome to DirectX land. We hope you enjoy your stay.

Quote:What are the key differences between the D3D way of doing things and the OpenGL way?


All of the concepts behind 3D rendering remain the same. The way in which you go about applying those concepts can look radically different, however, since DirectX makes heavy use of COM and object based (in the C++ sense of the word) interfaces to provide the functionality, while OpenGL presents a more procedural, C-style interface.

Quote:How far apart are DirectX versions usually released, and how much difference will there be between DX10 and 11? I have heard the transition from 9 to 10 involved significant changes.


In the past, DirectX versions were updated quite rarely. The Direct3D9 model presented a capabilities system that allowed the API to be used across a vast range of hardware, greatly prolonging its life. With the switch to Direct3D10, the capabilities system has almost completely vanished in favor of specifying a base line for all Direct3D10 capable hardware. In order to keep up with hardware growth, newer versions will need to be released more frequently in order to raise the base line. However, I don't expect the newer versions to be as large a jump as D3D10 was.

Quote:Does a program have to be written in C# to run on the XBox?


Only if you are a hobbyist. If you go through official channels, you can purchase an official XBox development kit, although I've heard that this is very difficult and very expensive.

Quote:Does the XBox use DirectX 9 or 10, or some special version? I don't have time to support two APIs, so which is the best version to use? Can I use the same exact code for the XBox and the PC versions?


The XBox supports Direct3D9, but not 10. No matter whether you decide to use C# or C++, your code will still not be able to run on both the XBox and the PC without very careful attention to cross platform issues. It's no different from the way OpenGL can be used on multiple platforms; you need to be careful and provide extra effort to ensure that you all platform specific code is set up to conditionally compile correctly.

Quote:What is the GPU used in the XBox? Is geometry instancing supported? Is a deferred renderer possible? I have heard Crysis cannot run on the XBox because the console is not powerful enough.


The XBox360 has a custom ATI GPU; there are several articles on the internet where you can read about it, such as this one. You are certainly able to use hardware instancing, as well as deferred rendering.

Quote:C# seems to be the new trend, but C++ provides slightly faster code. Code execution time for a 3D engine isn't that crucial, since the rendering is all on the GPU and physics usually use a third-party library. Would you recommend C++ or C#? I prefer a small manageable source I can quickly edit and test different techniques with. Is there a DX SDK for C#, or is that what XNA is? Is XNA considered the "kiddie" version of DirectX? Is it a disadvantage for writing a high-end renderer?


Your choices boil down to this:
- If you want to release an official game for the XBox360, you are going to want to use C++ along with Direct3D9. In order to keep your code simpler, you would most likely take the same path for a PC release.

- If you want to release to XBox Live Arcade, you can make use of XNA with C#, which will let you release to both the XBox and the PC with minimal extra effort.

- If you want to make use of Direct3D10, you have no choice but to target the PC only. You can make use of either C# or C++ for this task. Personally I would choose C#, since it is a much nicer language, easier to use, and will get you moving much faster.

- If you are targeting Direct3D9 for the PC only, you can choose from any of the technology options presented above.

If you are going to be targeting the PC only and are interested in C#, you may prefer using SlimDX, which is a direct translation of DirectX to C#, over XNA, which is a higher level framework that occasionally leaves out features in order to ensure compatibility with its lowest common denominator (ie. the XBox).
Mike Popoloski | Journal | SlimDX
Mike has good points and opinions.

As a somewhat "insider" in D3D11 development, I would like to add that converting D3D10 code to D3D11 is going to be very easy, with the basic interface hierarchy being mostly same. There is a minor difference in basic render state setting, but the impact is only about one extra row of code.

Only when you access D3D11-specific features such as compute shaders, tessellation and SM5.0 stuff, there will be major differences in code since there are no equivalent D3D10 interfaces.

Niko Suni

...
Is there a middleware that allows you to use C++, call some routines in a link library which routes to XNA?
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

This topic is closed to new replies.

Advertisement