OpenGL & DirectX

Started by
6 comments, last by adam_o 16 years, 5 months ago
is it possible to write programs using both OpenGL and DirectX? If so, where could I learn to do that? Or is there someone who could tell me how? If not, which is better and where can I learn to program in that style?
Advertisement
I don't know anything about DirectX, being a Mac user, but I would think that since people are always talking about "OpenGL VERSUS DirectX" that they wouldn't be compatible. On the Mac side, OpenGL is optimized to work with our graphics cards, so if you're looking for a broader audience, go OpenGL. I personally use OpenGL and SDL.
_______________________My computer stats:Xcode 3.1.2Mac OS 10.5.8---Visual C++ 2008 Express EditionWindows XP---NetBeansUbuntu 9.04---Help needed here!
It's very possible. I don't think anyone has written anything on it because it's pretty easy to do, honestly. Once you get some more programming under your belt you'll know how to do it yourself. It'll be one of those "wow, it was that obvious?" things.

In the meantime, i suggest going with OpenGL, but i'm a sucker for open/cross platform standards. Check out NEHE's tutorials to get started.
I didn't know that Mac didn't support DirectX. I guess, if I can find out if the 2 are compatible, it's possible to run 2 programs, one for Mac, and another for Windows. Well, is there a place I can find out about DirectX? There wouldn't happen to be a lib that I'd have to get to use with C++, would there?
Quote:Original post by PokeDestiny
I didn't know that Mac didn't support DirectX. I guess, if I can find out if the 2 are compatible, it's possible to run 2 programs, one for Mac, and another for Windows. Well, is there a place I can find out about DirectX? There wouldn't happen to be a lib that I'd have to get to use with C++, would there?


OpenGL is the standard Graphics API used across platforms. DirectX is the standard API for Windows not just for graphics but for sound and input. It was created for Windows by Microsoft is ONLY on Windows. OpenGL programs will be the easies to port but it is only graphics and not input.

The two aren't directly "Compatible" but you can do more or less the exact same thing in both Graphics wise. If you want to use both you would wrap the API specific code inside your own function. You then call your function and it does OpenGl or DX depending on what you are using at the time. If all this is making your head hurt then its time to go back to the books for some more research. My advice is if you have to ask how you can use both then your not ready to use both. Pick one and only one, then make something.

As for finding out information on DX there are many places, books, and what not on the subject. First thing you will need is the DirectX SDK which also comes with documentation. Google Starting DirectX and see what you get. If your hardcore interested in Cross platform stuff then go with OpenGL but you will also need something like SDL for audio and input.
------------------------------------------------------------- neglected projects Lore and The KeepersRandom artwork
It's like you're comparing the engine from one car with the entirety of another car. The direct comparison can only be made between OpenGL and Direct3D. The other parts of DirectX - DirectSound, DirectInput, and so on - will quite happily coexist with OpenGL. From a technological point of view, the major parts of DirectX are completely separate; the only reason it's referred to as a single 'DirectX' thing is because of the way it's shipped and marketed.

As Goober King has said, OpenGL and Direct3D do pretty similar things - after all, at the end of the day it's the same graphics hardware that they're controlling, so all that really differs between the technologies is the way they expose that hardware to you.

Of the two, if you're working on Windows, I personally prefer Direct3D, as my experience of the tools for it has been much better - the DirectX SDK includes tools like PIX, which lets you examine in detail the Direct3D calls made by your application, and lets you explore the effect of each call on the framebuffer, the data they use, etc etc.

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

Half-Life and Half-Life 2 ran in both OpenGL and DirectX, not at the same time, but users do have the option.
---Veni, Vidi, Vici.War is Peace. Freedom is Slavery. Ignorance is strength.
I must stress that OpenGL / SDL are compatible with Macs and PCs, so if you're going to be cross-platformal, go for OpenGL. If you don't care about Macs, then take DirectX just because it has sound, input, etc. built into it. I must say that OpenGL uses a no-nonsense method of working its magic, although I know nothing of DirectX.
_______________________My computer stats:Xcode 3.1.2Mac OS 10.5.8---Visual C++ 2008 Express EditionWindows XP---NetBeansUbuntu 9.04---Help needed here!

This topic is closed to new replies.

Advertisement