I am getting confused with DirectX and OpenGL and the rest. Which is best to start with?
Printable View
I am getting confused with DirectX and OpenGL and the rest. Which is best to start with?
Try using the search feature as this discussion has been brought up many times and your likely to find your answer there.
Also, try searching for articles over at www.gamedev.net , they have beaten this topic to death with a stick and you'll find a lot of good information.
IMO, OpenGL is more newb friendly, but what do I know .. i'm the one software developer on Earth that didn't get into the business to make video games ;)
I'd highly suggest OpenGL for one simple reason - You can easily port your OpenGL programs to other operating systems. Can't do that with DirectX. Well, not without a ton of porting and fustration.
OpenGL is easier, and I have yet to see an OpenGL based renderer beat by an equivalent Directx based renderer. They're both ultimately good, but I highly suggest OpenGL. I've been programming with it for, oh I dunno, must be like two years or so.
null and void, with only 8% of the consumer market being non-windows, there really is no reason to focus on opengl over directX unless you are making a professional app that needs to be on multiple platforms.Quote:
I'd highly suggest OpenGL for one simple reason - You can easily port your OpenGL programs to other operating systems. Can't do that with DirectX. Well, not without a ton of porting and fustration.
I am highly suggesting DirectX right now, as the little touches are nice, such as, not having to worry about writing up your own matrix math libraries(you still have to know whats for what, but you dont have to go through that hassle of getting a full Matrix library), as D3DX comes with alot of extensions for those purposes. I like opengl alot, but the problem is, while it is simple, once you get beyond the simplicity, your at the end of the standard OGL library and will have to create everything by hand.Quote:
OpenGL is easier, and I have yet to see an OpenGL based renderer beat by an equivalent Directx based renderer. They're both ultimately good, but I highly suggest OpenGL.
so, either way you go you are ok, but I would officially recommend both as you will need both if you are planning on getting a job in the gaming industry.
DirectX is more than just graphics. That includes sounds, user input (mouse and keyboard) and networking.
yeah, I forgot to mention that, that unless you are going to use OpenAL, most companies will have you use DirectX anyway for atleast sound/input/etc. even if you dont use D3D.Quote:
DirectX is more than just graphics. That includes sounds, user input (mouse and keyboard) and networking.
I disagree. Most companies that I've been looking into have two dev teams or simply program with one API or the other, not both. Check out some recruiting websites and company websites and you will find out that most companies, if not all, are gradually moving towards DirectX. The XBOX craze has only strengthened that movement since it, too, uses DirectX.Quote:
so, either way you go you are ok, but I would officially recommend both as you will need both if you are planning on getting a job in the gaming industry.
I'm sorry but the age of third party graphics API's is simply nearing an end. Very very few of any of my current games, in my library of nearly 270, natively support OpenGL. True that most FPS shooters - or at least the big hitters like DOOM 3, Half-Life 2, Unreal 2, etc. do natively support OpenGL but most commercial games stay with DirectX.
DirectX is really quite a brilliant API if you DON'T learn it from the supplied documents. MS really needs to work on their documentation for both MSVC and DirectX. The help files are so confusing they read like stereo instructions.
And, as has been mentioned, DirectX is a complete API. It supports extremely fast access to music hardware, input hardware - all sorts as long as the vendor has a driver for it, graphics hardware, etc. It has native support for playing music files - MIDI's at least, and has enough robustness to it that one could easily program their own streaming music library for just about any type of file format. DirectX is very awesome because it's all there - everything you need to make a very good game with high production value quality is there. It's up to you to use those effectively. Two thumbs up here....way up.
why are you guys talking about the other components of directx? when you get a thread comparing OpenGL and 'directx' isn't it kind of implied that you're only talking about rendering, i.e direct3d and directdraw only? You can still use all of the other stuff in the directx library if you use OpenGL...hell even carmack does that in his engines.
and bubba maybe you can answer me this question, but exactly WHO in the hell implements direct3d and direct draw? is it all the same implementation that just accesses whatever video hardware that is available?
May I jsut add that compared to OpenGL, DirectX is just a pain to use (especially if yo ucompare it to the ease of using glut).
It is my understanding that Microsoft decides on the function prototypes, if you will, and then the vendors for each video card supply the actual code bodies for the functions. This allows a universal interface to the API, but the code base changes to suit the video hardware - thus the video card vendors write the driver.
COM is all about function pointers so it is very simple to create the interface. MS does create software functions to emulate those functions not supported in hardware, but they are very slow.
DirectX consists of the
HAL - hardware abstraction layer
HEL - hardware emulation layer
For more info www.msdn.com - search on DirectX or d/l the dx9 sdk.
Thanks for all this. I have decided to start with OpenGL as many have suggested it to be easier but i think that in order for me to really get into game programming i should learn DirectX stuff.
identical to how it is done with opengl, except instead of microsoft they have the architecture review boardQuote:
It is my understanding that Microsoft decides on the function prototypes, if you will, and then the vendors for each video card supply the actual code bodies for the functions
which of course squabbles and never gets anything really done(took them forever to get a shader extension agreed upon, too many company rivalries).Quote:
...they have the architecture review board
I think that if you are going into the industry, learning DirectX (the full API) is the best bet, as you will probably have to use everything else besides D3D if you make an openGL game. I also dont know why everyone views it as so hard, when in many ways, its interface is more self-explanatory than OGL.
... I am just going to shutup now as I love both and dont want to turn this into a flame war.
If you can understand that a toolbox has many drawers with many different tools in them, then you can understand DirectX and COM. But with COM each tool box drawer could also have a smaller toolbox in it with drawers, boxes, etc. and so on.Quote:
I also dont know why everyone views it as so hard, when in many ways, its interface is more self-explanatory than OGL.
COM is easy and so is DirectX. In fact, DirectX is bordering on simple if you buy a book that explains how to set it up. Once that is done, the rest is very straightforward.
Having programmed a small 3D engine in DOS and a sound engine, DirectX is a lifesaver. Programming my sound engine in DOS was not easy and relied heavily on one sound card rather than supporting all of them. With DirectX as long as the vendor writes the function bodies for the functions - thus the drivers/dlls - it is supported under DirectX. Ingenious. Kudos to MS for DirectX.
For sound engines you don't have to worry about DMA modes, programming, or DMA page registers. You don't have to worry about writing an interrupt handler to handle the sound card interrupt and you don't have to write an additive mixer because its all done for you. You simply load the sound, specify if its looping or not, and then play it. DirectSound will auto-mix your sound into the primary buffer and thats it. But you can also mess with the primary buffer if you need to - it uses a circular buffer just like the old DOS sound API's. The DMA activity and programming is transparent to you which is, trust me, very nice.
With DirectInput you can gain access to nearly every modern device out there provided there is a driver for it. Keyboard programming is a snap with DirectX - no more interrupt 09h handlers, no more headaches with extended key codes or multiple key combinations. No more 'stuck key' issues if NumLock is on or off. As well the gamepad interfaces are so simple and the mouse, albeit a bit more complex than DOS, is still easy to use.
I don't know anything about OpenGL and I'm not against it or anything, but don't shy away from DirectX because someone told you it was too hard. It's not.
Well, If you think that 8% is not worth programming for, you're software will not that successfull as if it used OpenGL. It seems to me that everyone just thinks DirectX is the only possible solution, and it handels input, sound etc. Well, this can also be accomplished with various of libraries like Allegro, ClanLib, SDL.
Besides, those 8% not using MS windows today, may be 20% in a few years. You can't rely on todays situation. I can agree that it's convenient to have a DirectX syntax to everything in your game, but I believe that you have to search an API that you like for yourself. Be open minded, and try out many, look into the documentation of the API's.
It all depends on what you want to learn. OpenGL is easier, but that's not really a reason to call it "better". A lot of companys use DirectX so it would be good to learn it. Also, you should learn the one that you have the best resource for, for example: I have a C++ book. I want to learn DirectX or OpenGL. My book teaches DirectX. Therefore, I will most likely learn DirectX. But I think it would be best to learn both, that way if you made a DirectX thing and an OpenGL thing, you get 100%.
- SirCrono6
All video cards support DirectX - all. Not all natively support OpenGL. All the libraries you mention support the reason for using DirectX - why use twenty libraries to accomplish what one API can do? And just because my game does not support OpenGL or does support OpenGL does not mean it will be successful or a flop. That is not even a fair statement. Games do well based on whats in the game, not what library it uses to accomplish what it does. I'm telling ya, the days of proprietary graphic API's for certain video cards are coming to an end. DirectX will be all there is. 3Dfx API fell by the way side even though it was easier to use and had less dev time than DirectX. Granted 3Dfx fell for a host of other reasons not related to this topic but you get the jist of what I'm saying.Quote:
Well, If you think that 8% is not worth programming for, you're software will not that successfull as if it used OpenGL. It seems to me that everyone just thinks DirectX is the only possible solution, and it handels input, sound etc. Well, this can also be accomplished with various of libraries like Allegro, ClanLib, SDL.
Geez I feel like a MS crusader here, which I'm not, but DirectX is a very good, very stable, very modern, very versatile, and very easy to use API. Just try it.
what market are we talking about here, global or US. You are definately right in the global outlook of things, as asia is progressing towards its own Unix system, however, they also dont want any foreign developers(tough luck for Euros/Americans there). The EU is also progressing towards its own software, and may be alittle more open towards Americans, but not much. So this market advantage you are talking about will not exist for Americans due to inter-governmental troubles.Quote:
Besides, those 8% not using MS windows today, may be 20% in a few years.
exactly, in the end, it is the content of the actual game that determines whether it becomes a flop or a success. what people dont realize is that the base graphics engine is usually the fastest thing to be done, and it is the actual content(AI,Physics,etc) that takes the time(this is in general, as DOOM3 took several years for its graphics engine to become complete).Quote:
All video cards support DirectX - all. Not all natively support OpenGL. All the libraries you mention support the reason for using DirectX - why use twenty libraries to accomplish what one API can do? And just because my game does not support OpenGL or does support OpenGL does not mean it will be successful or a flop.
Learn both APIs as possible, but if it had to be one, I would go with DirectX, as it is as mentioned above, the only API to have 100% support by video cards.
EDIT: and another example of how DirectX makes it easier to do rotation if you dont want to program your own(you still need to know matrical math for the view matrix update however).
I still recommend writing your own rotation functions and try to optimize, but you probably wont be any faster than the D3DX functionCode:
void ICamera::Yaw(float degrees)
{
D3DXMATRIX mR;
degrees = (degrees *D3DX_PI)/180;
D3DXMatrixRotationY(&mR,degrees);
D3DXVec3TransformCoord(&vRight,&vRight,&mR);
D3DXVec3TransformCoord(&vAt,&vAt,&mR);
};
void ICamera::Pitch(float degrees)
{
D3DXMATRIX mR;
degrees = (degrees * D3DX_PI)/180;
D3DXMatrixRotationX(&mR,degrees);
D3DXVec3TransformCoord(&vUp,&vUp,&mR);
D3DXVec3TransformCoord(&vAt,&vAt,&mR);
};
here's how im doing it... learning opengl first because it is easier for beginners... http://nehe.gamedev.net is an excellent source btw) then once i understand all of the concepts of 3d programs, like rotation, lighting, etc. go learn directx because i conceptually understand everything. it will never hurt to know both but i think opengl is better to start with because it's easier. although i do agree that being able to do everything w/ directx is very nice and blizzard uses directx ;) meaning if you want a job there you gotta learn it.
I'm completely coding all of my matrix and mathematics stuff...in fact, the only REASON I really even do 3D programming is because i really enjoy solving complex problems ...I am not big on playing games, in fact, afaik even carmack didn't really like playing games, and he's really successful
Im almost at that point to, which is why I still have all of those matrix functions still written up which I will optimize with assembler once I learn more of it(matrical inversion without using the determinant really is a pain in the ass to get working right).Quote:
I'm completely coding all of my matrix and mathematics stuff...in fact, the only REASON I really even do 3D programming is because i really enjoy solving complex problems
honestly it's pretty much next to impossible to optimize with assembly. I've re-written things like sqrt and almost all of my mathematics stuff, and even the C standard stuff runs way faster.
The only way to get good optimizations is to get into SIMD optimizations and 3D now, which isn't supported on every processor. Some of that stuff gets pretty hairy, but i wouldn't worry about optimizing until you've actually got something that runs.
you are right for most basic math functions, but when it comes time to SSE optimized, you can cut alot of garbage out of the outputted assembly by handcoding it(for example, on gamedev.net, one person cut the outputted assembly from 20 instructions using the stack(MS VC outputted assembler code) down to 3 instructions at a pretty high performance gain.)
I wasnt planning on optimizing any of my stuff until I get it to where it works and the only thing holding me back is my code's speed.