Sign in to follow this  
bmburditt

OpenGL vs Directx

Recommended Posts

Good Afternoon Ladies and Gentlemen: A new member here. I have been reading through the gamedev.net website for about a year now and have just embarked on the long journey of game programming/development. I have always enjoyed playing games and have been fascinated by software development especially with respect to games. I am just at the tail end of reviewing my C programming skills. IE a beginners level understanding. I have purchased and read 7 or 8 books recently on game programming and development of software. Please understand I have not worked thru the books I have read thru them to get an overview. my question is this ... After bringing my C/C++ skills up to snuff, what do you think I should look into first OpenGL or Directx? Or maybe I should be asking which book to work through first, Beginning OpenGL Game Programming or Tricks of the Windows Game Programming Gurus, 2nd Ed?

Share this post


Link to post
Share on other sites
Quote:
Original post by SippyCup
I have been wondering the same thing. I'm actually trying to find some good, current OpenGL coding examples, but I haven't really found any that I can understand.


You have visited NeHe, havent't you?

To the OP: I find OpenGL easier to begin with, because you don't need to setup vertex arrays like in D3D, but you just do glBegin/glVertex/glEnd calls.
But Direct3D isn't really harder, just more interfaces to remember (and it doesn't have an extension mechanism).
Once you are comfortable with either API, learning the other should be a piece of caek.

Share this post


Link to post
Share on other sites
Quote:

After bringing my C/C++ skills up to snuff, what do you think I should look into first?


More C++. Getting from beginners knowledge to a level where you can effectively make games is a long long time. Moving to either API before you're ready to actually make games will only hurt in the long run.

Share this post


Link to post
Share on other sites
Quote:
Original post by bmburditt
More C++ knowledge gotcha. Having said that, which path do you suggest?


Honestly, the APIs are so likely to change in the year or two [conservatively] that it's going to take, I wouldn't hazard a guess. It mostly doesn't matter though. I'd avoid the 'Tricks' book though.

Share this post


Link to post
Share on other sites
I'd recommend you take a look at SDL - a free cross-platform 2D API to get started with. SDL not only will handle all your graphics, but your input handeling, networking, etc. Its a pretty neat, expansive library. I'd recommend Focus On SDL if you're interested in books.

The great thing about SDL is that it can be used alongside OGL to get a render context, load textures, getting input, etc. Which makes it the logical precursor to learning OGL.

You can also use SDL to bypass learning any win32 stuff to use D3D (in essentially the same way you'd do it with OGL).

<3 SDL.

Share this post


Link to post
Share on other sites
I highly recommend using NeHe as a starting point. OpenGL just seemed so much more newbie-friendly than DirectX. Drawing a red triangle in OpenGL (for the most part) is just doing something as simple as:

[source=cpp]
glBegin(GL_TRIANGLES)

glColor3f(1.0f, 0, 0);

glVertex3f(-1.0f, 0, 0);
glVertex3f(0, 1.0f, 0);
glVertex3f(1.0f, 0, 0);

glEnd();





In DirectX you have to deal with creating a vertex array/buffer and IMO there were just too many places to get lost. It basically comes down to whatever you can find a clear tutorial for. NeHe is one of the best and clearest tutorial sites I've ever found for OpenGL, while Drunken Hyena and www.andypike.com are good for DirectX.

Share this post


Link to post
Share on other sites
Personally, I liked Tricks vol 1, it helped alot with DirectX(specifically DirectDraw).

But I started learning OpenGL before learning DirectX, I think OpenGL is a little easier for the 'newbie' DirectX is kinda odd, but I like it a little more than OpenGL. But NeHe is a great place to learn OpenGL.

Share this post


Link to post
Share on other sites
Don't forget that SDL in conjunction with OpenGL will build portable source codes so you can get them to run on Mac and Linux. DirectX is stuck with just Windows (and XBox if you count that as a platform).

Share this post


Link to post
Share on other sites
Quote:
Original post by bmburditt
No Tricks book? I have read mixed reviews on the net and on this site. Not to mention he has my sense of humour. Any other book suggestions.


Best books I have ever read. You will learn from him (Andre) the fundamentals, that is skills that allow you to program a game on a system where all you have access to the screen pixels and basic "is it pressed" input. I found this to be immensely useful and highly recommend his two books (the second one especially). I am curious why so many people think otherwise on this issue.

As for the original issue? If you want to learn 2D programming then use a 2D api such as directDraw or SDL. The simpler the better here, so SDL is probably your best bet. If 3D is your goal then I recommend you start with a software 3D engine. Sure, call me crazy, but if you do this then you will gain a true understanding of how 3D processing works, and the switch to OGL or DX will be a simple matter of passing the control off to the hardware. You will know what the hardware will be doing with what you give it, and so will better know how to gain the results you want.

I can tell you now that many will disagree with me here, and making sense out of the mass of opinions can be frustrating. Follow my advice if you want to have a deep understanding of how 3D graphics work. If you do not care about that, then this advice will probably bring more grief then good and you'd be best to take the advice of another.

Hope that helps.

Share this post


Link to post
Share on other sites
I don't really know why nobody ever suggests D3D. I think nobody ever says it because so many here use OpenGL or SDL so D3D is "the bad guy", but it's not. D3D and OGL are capable of the same thing. D3D is more low-level and in C++ were OGL is high-level and in C. The thing I found about OGL was that in order to get the same performance under windows as D3D, you had to use things like VBOs and extensions which pretty much eliminates the "high-level" part. Many also forget about D3DX, a set of helpful functions that eliminate the need to write somewhat complex functions(png loading in d3d is one call!). BTW those of you that can't understand D3D code need to go brush up on your GPU and C++ skills.

Anyway if you need cross-platform compatiblity than use OGL. Otherwise test both out and use the one you think is best. If you don't understand either than you need more C++.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by samuraicrow
. . .DirectX is stuck with just Windows. . .


Heh, I can live with 90% of the market.

Share this post


Link to post
Share on other sites
And another thing is: DirectX handles a lot of the functions that OpenGL doesn't, such as input and sound, or at least that's what I've been told. I don't know for sure because right now I'm in SDL where everything is easy. :)

Share this post


Link to post
Share on other sites
My $.02:
I jumped right from C++ to D3D (and the other parts of DX) without any problems, and you get more than just graphics with DX. I found the book Beginning Game Programming by John Harbour to be extremely useful while learning DX, but it mainly tlaks about 2D; check out Programming Role Playing w/ DX 2nd Edition for a 3D look at D3D.
P.S. I'm surprised this hasn't been closed yet; normally DX vs. OGL threads kick it afer post 5...

Share this post


Link to post
Share on other sites
Quote:

You will learn from him (Andre) the fundamentals, that is skills that allow you to program a game on a system where all you have access to the screen pixels and basic "is it pressed" input.


And what systems are those?

Game programming is hard. Worse yet, it's tedious. Writing everything from the ground up every time is foolish. Why should you read through such a large book to learn how to do things like load bitmaps that even the lowest level API [directX] does for you these days?

A waste of time and money. In my opinion of course.

Share this post


Link to post
Share on other sites
Quote:
Original post by bmburditt
[...]After bringing my C/C++ skills up to snuff, what do you think I should look into first[...]
Personally, I would STRONGLY suggest you buy the following three books(roughly in order, definitely buy the first before the last 2) to round out your C++ programming skills:

Code Complete, 2nd Ed.

Design Patterns: Elements of Reusable Object-Oriented Software

Modern C++ Design

They're all very good books. Reading (and understanding) them should greatly improve your coding abilities.

Share this post


Link to post
Share on other sites
I agree with Telastyn. Learning how to write a 3D renderer in software is interesting, but do you want to make games or write 3D engines? Game programming has become a big enough topic that you'll never learn everything there is to know about it, so focus on the basics and then the things that interest you. If you want to specialize in graphics or be an engine programmer, then writing a 3D software renderer may be a good idea. Otherwise, your time will be better spent elsewhere.

André's books are good for learning a wide range of foundational game programming topics, but I feel that they are kinda dated now.

Btw, Beginning OpenGL Game Programming is a great book [wink], and the follow-up is due out in a week or two.

Share this post


Link to post
Share on other sites
Quote:
Original post by bmburditt
...what do you think I should look into first OpenGL or Directx?

Flip a coin, it really makes no difference.

Quote:
Or maybe I should be asking which book to work through first, Beginning OpenGL Game Programming or Tricks of the Windows Game Programming Gurus, 2nd Ed?

The latter is a recasting of a book written for DOS Mode 13h to roughly DirectX7 compatibility. There are better ways to learn, and better resources to learn from.

Share this post


Link to post
Share on other sites
I use to be against OpenGL, but now in this huge market outside of just Windows, it's probably more benefitial to learn OpenGL. It would be more often used if you're going after portability with mobile phones, applets, desktop games, game consoles, etc. You just need to know where your target is, and start going after it. Are you a general programmer? Use OpenGL. Are you a Windows programmer? Use DirectX.

Share this post


Link to post
Share on other sites
All I will say on the subject is do not let mere words on a programming forum choose the path you will take in programming your games. It is up to you to decide which to pursue more heavily. Feel-out both DirectX and OpenGL and see which framework suits your style best. No one says you must only know one set of APIs.

Share this post


Link to post
Share on other sites
Quote:
Original post by thugkilla
Man just go with which one you like.Direct x or OpenGl....Most game company I'am pretty sure use there own library


... Wow...

I would think otherwise, I have never had to download or install any third party API set due to a game. But game companies do use there own engines, which probably mask a lot of the straight API calls.

Share this post


Link to post
Share on other sites
These posts are somewhat pointless. There is no DirectX VS OpenGL. They each have their strong and weak points, which I'm not going to list, mostly cause I've never bothered with a side by side comparison, I use openGL personally, but mostly out of choice. I have tried both, and liked openGL better, it fits my style of thinking, but that doesnt mean it will fit yours. You might find DX works more the way you think.

They will both basically function the same, after all, 3d mathematic, texturing, lighting... etc, are all part of 3D programming. The difference is in how they organise it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this