Getting started with C++ and DirectX

Miscellaneous Forums/General Discussion/Getting started with C++ and DirectX

I am interested in learning a little about C++ and DirectX 9 or 10, but I don't even know where to start.

I installed Visual Studio 2005. How about a tutorial showing non-C programmers how to set up a simple program?

http://www.devmaster.net/forums/showthread.php?t=9950&highlight=GameEngine_Designer


I am an exsisting C++ programmer & know a lot about DirectX 9.0. If any questions please feel free to email me at anytime!

FlashProducer@...

Josh aka Leadwerks: I'm a little suprised at your request given the proffessional quality of your work to date:- the HDR test for example. What language/engine do you normally code in?

And have you downloaded the MS DirectX SDK ? It comes with a number of examples. However, I think for dx9/10, all examples are in .net

I've thought about looking at this for ages. It's very complicated compared to blitz due to all the setting up and initializing of stuff you need to do.

It's not "graphics3d x,x,x,x" and off you go. It's ten minutes setting up the compiler, then another half an hour typing in initialisation code before you get even a blank window. That's my experience anyway, hopefully I'll find an easy guide to it that will make it all straight forward.

I am allowed to learn new things in my free time.

If you're interested in a good resource for C++ from scratch (not necessarily Directx) this isn't a bad starting point:

http://www.cprogramming.com/tutorial/lesson1.html

@LilMain link, suggests starting with simple text games, it is possible to do a simple space invaders clone in a terminal window... not 3D I know, but walking's good before running.

I am interested in learning a little about C++ and DirectX 9 or 10, but I don't even know where to start.

I downloaded the DirectX SDK a while ago, and they seem to have fairly good tutorials and examples.

How about a tutorial showing non-C programmers how to set up a simple program?

I remember I tried learning DirectX a long time ago before I fully understood C/C++, and I ended up totally confused. Unless you fully understand C arrays, pointers, etc., it's going to be really difficult learning DirectX (and even if you can, you may learn something improperly or miss something important).

It's very complicated compared to blitz due to all the setting up and initializing of stuff you need to do.

True, but it gives you 100x the control. Every minute detail is fully under your control, and that can really help if you're trying to build a specialized high-performance engine.

Tutorials:

http://www.ultimategameprogramming.com/demoDownload.php?category=DirectX&page=1

And book...

http://www.charlesriver.com/Books/BookDetail.aspx?productID=124869

I recommend "sAms Teach yourself C++ in 24 hours ". By Jesse Liberty and David B. Horvath. Its gets you started quite well in 24 lessons.

I went through the book in about a month in my spare time. and am digging for a good DX boox atm.

BlitzPlotter, I was just about to post that!!!
Hehehe.

@RifRaf - No, Sams Teach Your Self C++ in 21 Days is better. DO NOT GET THE FOR DUMMIES BOOKS! Yes caps is on! It's urgent. C++ for Dummies books all use C style strings.

I don't think Josh would get a book for dummies.

The other really good option is found here:

www.3dbuzz.com

Look for the Video Tutorials there's nearly 9 hours worth.

IPete2.

@IPete2 - Most of those videos you have to buy for liek $100.00. I bought them & not to good. It's like listening to a football game on the radio..

@Lil Main, yeah, I delved into that (Sams C++) about 4 years ago for the first eight lessons, might dig it back out again once I've finished cprogramming.com tutorial. I reckon the cprogramming.com is very easy to read, nice slant on pointers. In fact I'm currently on lesson 10..... And my compiler of choice the now is CodeWarrior 6, dipped my toes into Visual Studio and I prefer Code Warrior.

@Yo!Wazzup? ahhh, I see I'm in good company....

Bruce Eckel: "Thinking in C++".
Robert Lafore: "Object-Oriented Programming in C++."

I only bought one book about Direct-X ages ago, and I did not like it, so I don't have a recommendation for it. However, Direct-X is one of those 'Windows-only' technologies, so I wouldn't bother with it in the first place.

I love blitz3d and see al above. what a mess c is :)

have you tryed blitz max. is have support for c.

My experience is OPEN GL is the way to go.

@Wings - Actually OpenGL supported games are slow on some computer that are meant to play applications fast.

Yeah. Thinking in C++ is the book for becomming a C++ programmer from scratch.

If you're already fairly competent in Java, Mark Allan Weiss's C++ for Java programmers is also good.

Maybe even a reference manual like C++ in a Nutshell?

As for the tutorials, I wouldn't really know, since I'm more inclined towards OpenGL, but I hear the ones that ship with the SDK are as good as any you'll find (which unfortunately doesn't say much).

what a mess c is :)
Rubbish. C is wonderful. C++ is the problem.

Actually OpenGL supported games are slow on some computer that are meant to play applications fast.
I think you have that the other way around.

@FlameDuck - Nope, I don't. I ahve tested it, Spodi has tested it(Creator of vbGORE.) Also other programmers have tested it as well OpenGL is crap.

Rubbish. C is wonderful. C++ is the problem.

Funny, that's completely the opposite of what 99% of developers would say (C++ is wonderful, C is the problem).

I think you have that the other way around.

Have you even tested this claim? In every computer I've had, OpenGL ran considerably slower than DirectX. Whether it's a GeForce 2 MX, or a GeForce 7800 GT OC, I've always noticed at least a moderate performance boost with DirectX over OpenGL (with the latest drivers). On later cards like my 7800 GT the difference is much less noticeable (maybe only 5% performance loss when using OpenGL), but the fact is OpenGL is slower than DirectX.

Saw this at B&N today.
http://www.amazon.com/Beginning-Through-Game-Programming-Second/dp/1598633600/ref=pd_bbs_1/105-6170385-0962820?ie=UTF8&s=books&qid=1188761264&sr=8-1
Don't know how good it is, but since it's aimed at people that want to write games, it might be worth a look.

Funny, that's completely the opposite of what 99% of developers would say (C++ is wonderful, C is the problem).
C is a wonderful language. C++ is just it's bastard child.

If you're looking for a book to learn plain C, you can't beat 'The C Programming Language' by Brian Kernighan and Dennis Ritchie (they invented C). ISBN 0-13-110362-8. It's only 272 pages, but every word in it will impart knowledge.

Question is if DX works in linux

Open GL do

What has Linux got to do with anything? It's just a geek toy. :P

found this old info. from 2003 :)
that was why i wend blitz3d i guess..

nutball20-Jan-2003, 19:03
Well, I've gone with OpenGL, but as I only code under Linux I didn't really have a choice :) Of course if you care about any platform other than Windows, then OpenGL is the way to go.

OpenGL has the advantage that hardware vendors can add their own extensions to expose all of the functionality of their hardware, whereas DX9 is controlled by Microsoft and this isn't possible. NVIDIA, for example, have said that the full feature-set of GeForceFX will only be exposed under OpenGL.

OpenGL has the dis-advantage that hardware vendors can add their own extensions to expose all of the functionality of their hardware, and they seem to quite enjoy doing this. They particularly enjoy doing so in a manner which is incompatible with their closest rival. Hence you end up with GL_ATI_blah_extension and GL_NV_blah_extension, doing the same(-ish) thing in different(-ish) ways. Fortunately over time the OpenGL ARB (Architecture Review Board) bang heads together and sort things out.

I can't answer whether OpenGL 1.4 has the same shader support as DX9, as I don't know DX9. It supports vertex programs and pixel programs (shaders in DX parlance), if that's what you're asking.

OpenGL 2.0 is bubbling along nicely, and looks like it might be quite good. It will implement a high-level shading language like Cg or the Microsoft one.

If you find a decent lang in c++ and dx please leet me know if there are any decent tutorials.

Folks, it's not that OpenGL itself is slower than DirectX, it's simply the fact that OpenGL has always been treated by the industry as the professional API for graphics workstations and DirectX was the API for games. So the high-end graphics cards have OpenGL-optimized drivers that will blow any DirectX driver out of the water. But when you enter the consumer market, the developers will have focused on DirectX and optimized their drivers only for that.

Enter Vista: OpenGL calls are now translated to Direct 3D calls, making it impossible that OpenGL on Vista will ever match the performance of Direct 3D. And that is not the fault of OpenGL, but of Microsoft's OpenGL implementation.

Anyway - if you ever want to support something other than the Microsoft platform, you should go down the OpenGL road and leave DirectX/Direct3D aside.

Have you even tested this claim? In every computer I've had, OpenGL ran considerably slower than DirectX.


Opposite here. I can usually get around 30-50 more frames per second using OpenGL in my applications.

It's mostly the newer computer that OpenGL runs slow on. Mines all up to date brand new & OpenGL programs run very slow on my computer..

OpenGL has the dis-advantage that hardware vendors can add their own extensions to expose all of the functionality of their hardware, and they seem to quite enjoy doing this. They particularly enjoy doing so in a manner which is incompatible with their closest rival. Hence you end up with GL_ATI_blah_extension and GL_NV_blah_extension, doing the same(-ish) thing in different(-ish) ways. Fortunately over time the OpenGL ARB (Architecture Review Board) bang heads together and sort things out.

This is one of the main reasons I chose DirectX over OpenGL:

1. The whole idea of extensions seems really sloppy
2. DirectX runs faster than OpenGL on every computer I have ever seen, from the average "casual" web surfing computer, to the high-end gaming PC
3. I don't mind restricting my games to Windows only

Anyway - if you ever want to support something other than the Microsoft platform, you should go down the OpenGL road and leave DirectX/Direct3D aside.

True. The only real reason to use OpenGL IMO is if you want to support platforms other than windows.

Opposite here. I can usually get around 30-50 more frames per second using OpenGL in my applications.

Strange. What video cards were you using when you got that?

P.S. 30-50 more frames per second doesn't mean much - you could be referring to 200/250 FPS or 1/51 FPS.

Also, what program did you use to compare? Were any graphical effects reduced when OpenGL was activated?


big10p: Have you ever written any programs in C/C++? If so, could you explain why you think C++ is so bad? I use C++ every day, and some of the things I do with it would be nearly impossible to manage with C.

I agree that C++ isn't a "perfect" language, but neither is Blitz, or any other language. I would also agree that languages like C# can be more productive, but unfortunately performance is an issue with games programming, and higher-level languages are known to run considerably slower in most real-world appliations.

Either way, C++ is still the best high-performance game programming language, unless you're thinking about using C and dumping OOP (and if you're arguing for C over C++ because you don't care about OOP, I suggest you find out how useful OOP can be first).

I've always found D3D faster too. I also think the extensions are a pain, often added as an afterthought causing all kinds of compatibility problems on high end hardware.

D3D is nice in that it usualy gets the new features first, and GL gets hardware ventor supported extensions in order to play catchup.

Most high end 3D apps started using D3D now since they have better support for shaders and fancy shaderd with better compatiblity over a broad range of hardware.

GL used to be faster than D3D 2-3 years ago in 3D apps, but now theres not much difference except for you cant use shaders in GL with many apps. Whilst D3D renderer usualy have direct support for HLSL .FX shaders in viewports.