Getting started with C++

Started by
16 comments, last by hawksprite 11 years, 9 months ago
Thanks for all the guides and advice.

I'm not reconsidering the switch and wondering if there's a better way to use C# other then XNA.

But at the same time i'm still going to learn C++ as a platform and as I get better at it slowly transition into it.
Advertisement

Thanks for all the guides and advice.

I'm not reconsidering the switch and wondering if there's a better way to use C# other then XNA.

But at the same time i'm still going to learn C++ as a platform and as I get better at it slowly transition into it.


Other than XNA you also got OpenTK (crossplatform), SlimDX (DX11 IIRC) and ofcourse Unity.

For C++ there are fewer really good options that are easily accessible, CryEngine 3 however is free for non commercial use and is available at a 20% of revenue royalty rate for indies (So you only have to pay if you make any money, allthough if you succeed it will get very expensive(still cheaper than UDK though)), getting familiar with OpenGL / Direct3D is a good idea aswell, if you plan on writing your own engine (Which really is the only reason one would willingly touch C++ for a game these days) you should take a look at lua, python or angelscript (or something else, there are tons of nice options) to add scripting support (an engine that requires the game to go through a 20 minute recompile each time you adjust the AI or tune your heat seeking missiles will become horribly painful to work with)
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
Have you profiled your XNA game? Where are the bottlenecks?

If you haven't identified the specific parts which are limiting performance then you're almost certainly not hitting the limits of XNA.

Also, I feel I have to call you out for referring to c++ as 'superior'. It may or may not be the most appropriate choice given a particular set of requirements, but is not superior in general. In many ways, and in many applications, C# is probably the better choice. It's true that somebody who is sufficiently experienced can usually squeeze out an extra bit of performance in C/C++/assembly, but it is becoming increasingly rare that it is worth the considerable extra effort (particularly since more and more work is being offloaded to the GPU these days).
I don't think there is anything wrong with exploring C++, especially if you have logged some programming with C# or other languages. If nothing else, it will reveal a newfound respect and love for reflection, a sane build model, sane debugging system, fleshed-out standard library, and memory management wink.png

I also agree with those that have questioned hitting a performance bottleneck in XNA. From what I hear there are a few gotcha's when targetting XBOX (and other limited platforms), but I can't imagine where a PC would have trouble CPU side that would magically be solved by just switching to C++.
I've decided to go with SlimDX for my next project. Thanks to all who gave me advice, i actually found a handful of engines and platforms I never knew existed.

To clear up the rest of the questions most of the bottleknecking in XNA was my own poor code just little bits in A* alogrithims that were dropping the FPS by like 10 and so on so forth. I understand that C++ wouldn't fix this but I simply wanted to start my next project on a better platform. I didn't quite write my original post all to amazingly.

To WavyVirus I agree and probably shouldn't have jumped to saying C++ was better, I simply meant for game programming. When it comes to desktop application programming or basically any other situation i'd never consider using C++ over C# or something like ruby.

While I still want to learn C++ and memory management aspects, etc. I'm going to stick with C# for now but use SlimDX so I have a little more availability instead of being limited to just DX9.

Finally; i've ran into a bit of an issue with SlimDX but I made a second post for that here.

To WavyVirus I agree and probably shouldn't have jumped to saying C++ was better, I simply meant for game programming. When it comes to desktop application programming or basically any other situation i'd never consider using C++ over C# or something like ruby.


Still, I think that saying that C++ is better for game programming is a very bold claim. There are some situations (e.g. developing the latest and greatest big-budget title, with cutting edge graphics being a selling point) where it is still necessary to use C/C++ for performance reasons. Also, sometimes the platform you are developing for (console/mobile etc) restricts your options. But for many of the games that an indie or hobbyist developer is likely to have the resources or desire to create, C++ is not the optimal choice as the same result can be achieved more quickly and easily by other means. Often the lack of a team of artists means that a small developer will naturally gravitate away from game ideas which depend on super-detailed graphical content, and instead focus on areas where they can be more competitive like original gameplay, story, stylised art etc.

A not-so-terrible analogy would be cars. Is a Formula One car the best for driving? Really this depends on the situation (what sort of track surface? lots of corners or long straights? Are you driving around town? A rally car, Mini or drag racer might be superior in some situations) and also on the driver (what are they familiar with? I could probably drive my own little car around a track faster than an F1 car as I would spend most of the time either stalling or killing myself in the more powerful and complex machine).

Having said that, I don't want to discourage you from learning C++ and getting deeper into things like memory management - it can be a lot of fun, is still the appropriate choice in some situations, and will improve the code you produce in other languages. Just reminding you that these things aren't black and white - c++ is just another tool in your toolbox to pull out when you recognise that it the right one for the job.
I'd actually recommend looking at ANSI C first. There's a lot of subtle stuff that C++ carries over from C (not surprisingly). That said I wouldn't treat C++ as an extension of C so that isn't really a necessity.

Also, I'd definitely look at COM before you look at DirectX. The book Inside COM is great (old though).
True true, thats mostly while I decided to go with SlimDX for now but still plan on learning C++ in the future. Thanks for the analogy BTW, clears it up pretty well.


[quote name='hawksprite' timestamp='1341886498' post='4957475']
To WavyVirus I agree and probably shouldn't have jumped to saying C++ was better, I simply meant for game programming. When it comes to desktop application programming or basically any other situation i'd never consider using C++ over C# or something like ruby.


Still, I think that saying that C++ is better for game programming is a very bold claim. There are some situations (e.g. developing the latest and greatest big-budget title, with cutting edge graphics being a selling point) where it is still necessary to use C/C++ for performance reasons. Also, sometimes the platform you are developing for (console/mobile etc) restricts your options. But for many of the games that an indie or hobbyist developer is likely to have the resources or desire to create, C++ is not the optimal choice as the same result can be achieved more quickly and easily by other means. Often the lack of a team of artists means that a small developer will naturally gravitate away from game ideas which depend on super-detailed graphical content, and instead focus on areas where they can be more competitive like original gameplay, story, stylised art etc.

A not-so-terrible analogy would be cars. Is a Formula One car the best for driving? Really this depends on the situation (what sort of track surface? lots of corners or long straights? Are you driving around town? A rally car, Mini or drag racer might be superior in some situations) and also on the driver (what are they familiar with? I could probably drive my own little car around a track faster than an F1 car as I would spend most of the time either stalling or killing myself in the more powerful and complex machine).

Having said that, I don't want to discourage you from learning C++ and getting deeper into things like memory management - it can be a lot of fun, is still the appropriate choice in some situations, and will improve the code you produce in other languages. Just reminding you that these things aren't black and white - c++ is just another tool in your toolbox to pull out when you recognise that it the right one for the job.
[/quote]

This topic is closed to new replies.

Advertisement