• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Dagz

New to C++, could I get advice? (switching from C#)

18 posts in this topic

My experience with programming is C# and XNA, but I'm wanting to branch out and start using C++ as from what I've heard it's much more powerful and I don't have the overhanging shadow of microsoft. It's not that I ever expect to program a game so awesome that I might be able to sell it, but it's rather unsettling that. if such events did obtain, the game would be partially owned by microsoft (from what I hear). Regardless, I feel some what immature using XNA and that to really develop my abilities I need to start using C++.

I've been reading some C++ tutorials and have a fair enough grasp of the language, , but now I'm wanting to start working towards something a little more tangible. Of course with XNA the graphics and user input was taken care of, so I have absolutely no understanding of opengl or directx. The major pro's and cons of the two seem to be that opengl is more powerful and efficient and can run on practically all hardware, where as directx is weaker and lacking in these qualities but much easier to learn. I'm really not sure which to go for; I guess easy to learn outweighs less powerful, as I'm teaching myself. It would be nice to get feed back on this from more experienced programmers, though.

Also, for which ever you ultimately suggest, could you offer good beginner through intermediate tutorials which cover everything one might need to know? Up until now I've been looking only at opengl tutorials, and I do not understand anything. Any help I could get in this would be appreciated so much.
0

Share this post


Link to post
Share on other sites
[quote name='Dagz' timestamp='1331604151' post='4921543']
as from what I've heard it's much more powerful
[/quote]

This is incorrect.

[quote name='Dagz' timestamp='1331604151' post='4921543']
if such events did obtain, the game would be partially owned by microsoft (from what I hear).
[/quote]

This is more incorrect.

[quote name='Dagz' timestamp='1331604151' post='4921543']
Regardless, I feel some what immature using XNA and that to really develop my abilities I need to start using C++.
[/quote]

Likewise, incorrect.

[quote name='Dagz' timestamp='1331604151' post='4921543']
The major pro's and cons of the two seem to be that opengl is more powerful and efficient and can run on practically all hardware, where as directx is weaker and lacking in these qualities but much easier to learn.
[/quote]

Sensing a trend yet? Incorrect. OpenGL does tend to have better driver support across operating systems. DirectX tends to be more consistently supported where it is available.


If you can do things with C# and XNA, keep doing them. Do cooler, better things. 'Reading some C++ tutorials' is not sufficient to have a fair grasp of the language. If you're going to move (and I highly encourage you not to), writing programs is the only way. Even then, C++ will bite you in the ass a few dozen times before DirectX or OpenGL are suitable libraries to pick up.
1

Share this post


Link to post
Share on other sites
At the risk of simply repeating what Telastyn has said above, I feel it's worth re-enforcing some of the points made:

[quote name='Dagz' timestamp='1331604151' post='4921543']
the game would be partially owned by microsoft (from what I hear)
[/quote]
This is absolutely 100% incorrect. Microsoft do not own any games or other software you make using either C# or XNA, even if you're using the freely available tools they provide. Furthermore, they've made the C# language an open standard, meaning they do not have sole control over the language.

[quote name='Dagz' timestamp='1331604151' post='4921543']
I'm wanting to branch out and start using C++ as from what I've heard it's much more powerful
[/quote]
This one is something you often hear from people who don't [i]really[/i] know what they're on about; it's not uncommon for them to still be reasonably skilled, and perhaps even to have released some really cool products, but the moment they say one language is "more powerful" it should trigger alarm-bells.

The term "powerful", when relating to a programming language, is pretty poorly defined, and doesn't have much real meaning.
Programming languages can be [i]expressive[/i]; that is, more or less easily able to explain a given concept or idea, and this can be an important factor in language-choice.
Most of the time when discussing "power" of a programming language people are suggesting that programs written in that language will be less performant (i.e. slower) than others; this is actually an effect of the compiler or interpreter, the running environment, and most importantly of all the programmer who wrote the code. As a beginner it's going to be a [i]LONG[/i] time (if ever) where you run into a performance problem because of your language choice rather than because of how you used the language.

Software written in C# can in some cases run more slowly than a counter-part written in C++ -- but that isn't by all means something that happens all the time, and it's even rarer that the difference (if one exists) actually matters. As a beginner programmer, you'll also almost certainly make more costly (in terms of program performance) mistakes with C++ than with C#, meaning that [i]for you[/i] C++ would actually result in slower code execution.

Remember also that developer time (in this case that means [i]your[/i] time) is valuable, and a more expressive language or one with a better tool-set is an easy way to save yourself from wasting this valuable asset.

[quote name='Dagz' timestamp='1331604151' post='4921543']
I feel some what immature using XNA
[/quote]
That's a pretty common feeling, but it's also a pretty baseless one that you would do well to let go of. It's common in professional development to use existing middleware solutions or engines rather than wasting time implementing low-level solutions yourself, and if you have aspirations of one day entering the industry you would do well to be experienced at using such solutions; if you're not interested in an industry job, there's no reason at all to have to write your own lower level code, and you're just making more boring work for yourself writing the same old code to open a window and draw triangles on the screen rather than simply getting straight to the interesting game-play specific stuff. See for example some of the [url="http://www.havok.com/customer-projects/games?product=Physics"]professional titles that use Havok physics[/url] rather than wasting time writing their own implementation, or the [url="http://en.wikipedia.org/wiki/List_of_Unreal_Engine_games"]massive list of games that use Unreal Engine[/url].

If you want to learn the low-level stuff and implement things for yourself that's a perfectly valid personal choice, and you're certainly welcome to take that path -- but don't feel it's something you [i]need[/i] to do -- in many (perhaps even most!) cases professionals don't waste their time working at a lower level, and there's no reason you should feel the need to either.

[quote]...stuff about OpenGL vs. DirectX...[/quote]
The choice between these two is often just personal preference... but interestingly enough, the things you've listed are pretty much the opposite of what I normally hear. DirectX tends to be more consistently supported, and a lot of people consider OpenGL easier to get started learning.

Obviously DirectX is only available on Windows systems, but other than that the two APIs are very similar in capabilities, and if you learn either one well it should not be a big deal to later pick up the other if needed.



Honestly, I would[i] STRONGLY[/i] suggest sticking with C# and XNA, so that you can be making much more awesome things much sooner and with less effort, and build a portfolio of completed projects, whilst still learning valuable skills that you can later transfer to C++, DirectX, Java, or whatever you might feel the need to learn in future.


It's your choice if you want to pursue C++ instead though -- if you [i]really[/i] want to go down that path, I would suggest starting out with a higher level API such as SDL or SFML rather than either OpenGL or DirectX to start with -- although from your comment about "reading some C++ tutorials" I would suggest that you might need to actually write some programs rather than simply reading before moving on to a graphics API.



Hope that's helpful, and good luck! [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
0

Share this post


Link to post
Share on other sites
[quote name='jbadams' timestamp='1331610775' post='4921562']
[quote name='Dagz' timestamp='1331604151' post='4921543']
I feel some what immature using XNA
[/quote]
That's a pretty common feeling, but it's also a pretty baseless one that you would do well to let go of. It's common in professional development to use existing middleware solutions or engines rather than wasting time implementing low-level solutions yourself, and if you have aspirations of one day entering the industry you would do well to be experienced at using such solutions; if you're not interested in an industry job, there's no reason at all to have to write your own lower level code, and you're just making more boring work for yourself writing the same old code to open a window and draw triangles on the screen rather than simply getting straight to the interesting game-play specific stuff. See for example some of the [url="http://www.havok.com/customer-projects/games?product=Physics"]professional titles that use Havok physics[/url] rather than wasting time writing their own implementation, or the [url="http://en.wikipedia.org/wiki/List_of_Unreal_Engine_games"]massive list of games that use Unreal Engine[/url].

If you want to learn the low-level stuff and implement things for yourself that's a perfectly valid personal choice, and you're certainly welcome to take that path -- but don't feel it's something you [i]need[/i] to do -- in many (perhaps even most!) cases professionals don't waste their time working at a lower level, and there's no reason you should feel the need to either.
[/quote]

Getting used to working with middleware isnt the most important skill you need to pick up I found. I found that getting used to working within a codebase that is enormous is far more challenging. As you need to figure out if what you want to do is already written and if so who wrote it if you can't make sense of what they wrote and how to use it, and then there are the cases when the author has left the company.

Some of us do actually spend their waking hours fixing and maintaining these lower level systems and somethimes you actually have to dive into those levels when the middleware doesn't support what you want to do. A basic understanding of what is being done in the middleware is always necesary so writing these lower level systems can be extremely helpfull and teach you new things. Having said all that this is certainly not were a beginner should spend their time, once you are comfortable writing code in your chosen language is the point at which you can start looking at these things.

Side note: You are a gameplay programmer right. Graphics, physics, UI, audio and general programmers focus on different things and game play code is boring to them.
1

Share this post


Link to post
Share on other sites
First of, I'm a C++ engineer for almost 12 years now. You would never be able to create souch rich context as in XNA in souch a short period of time. The main problem is, that C++ in theory offers too much but in praxis provides very little. For example, thare are no strings in C++. You have to use array of buffers or you take STL. But, if you take STL, there is no guarantee that it is fully supported on Linux. Besides, many compilers do not even support STL by default, you have to download some additional libraries. When you get the libraries, you'll most probably run into compiler issues.

Also, there are almost no usable C++ classes out of the box. You need to provide them by yourself. Even OpenGL. You can't load a signle texture seeking for the code to open BMP or don't even think about DDS. Once you solve that, most probably with a library, that library will most offen not work cross platform. So you get stuck again.

And directx? Compared to XNA ? Oh dear jesus. Did you know, there are no classes except for the Gui? Everything is so basic in C++, you get down to ints and floats. There is no model class, there is no resource manager, there is no audio manager. You need to write / provide wrappers by yourself.

At the beginning it is interesting, but as more time you put into it, the more pitfalls come up and you get frustrated.

If you're not able to finish a game in XNA you will never be able to finish it in C++. That's my practical answer.

C++ simply offers to little in praxis. You should take a tool where you can quickly provide results. That's not C++. That's XNA.
-8

Share this post


Link to post
Share on other sites
Without wishing to start a "holy war", you don't need to use C++.

C++ is a very difficult language - I think very few people can get it right, in particular, the way that inheritance works (notwithstanding memory management issues) tends to catch out even the most experienced C++ coder.

I think you'd be much more productive in anything except C++ (except possibly, C)
0

Share this post


Link to post
Share on other sites
[quote name='SimonForsman' timestamp='1331644426' post='4921640']
[quote name='Samurai Jack' timestamp='1331641569' post='4921630']
First of, I'm a C++ engineer for almost 12 years now. You would never be able to create souch rich context as in XNA in souch a short period of time. The main problem is, that C++ in theory offers too much but in praxis provides very little. For example, thare are no strings in C++. You have to use array of buffers or you take STL. But, if you take STL, there is no guarantee that it is fully supported on Linux. Besides, many compilers do not even support STL by default, you have to download some additional libraries. When you get the libraries, you'll most probably run into compiler issues.
[/quote]

Wait what ?

Using the standard library does not cause any problems on Linux, gcc has solid support for C++98 and C++03 and when it comes to C++11 both gcc and clang are ahead of msvc++. There are plenty of disadvantages to using C++ but compiler support for the language isn't one of them.
[/quote]

I am going to make the assumption that he is talking about embedded or mobile systems running linux. For example, the Android ndk requires a little bit of trickery to get the STL working.

I would say the C++ is more powerful than many languages because of the low-level access it gives (bitwise operations, pointer arithmetic, etc); however, that low level power helps very little when making a game, and can add quite a bit of complexity. It is necessary when making something like an operating system or driver, but you don't need those for game programming. That said, from what I have read C# is just as powerful. It has many of these operations disabled by default because they can be "unsafe", but they are available.

My reason for choosing C++ over C# is cross-platform compatibility. Mono and C# are available for linux, but last time I checked it didn't have much in the way of graphics support (granted that was a few years ago). I also feel much safer about C++ being supported on any new platform I choose to develop. That said, when I do programming in Java I am much, much more efficient because of how expansive the standard java library is; C# has this same advantage.

Whether you should learn C++ or not depends a lot on why you want to learn it. If you want to learn it so that you can make games that run faster, don't bother. If you want to make games that are cross-platform, java might still be a better approach. If you want to simply develop your skills, I highly encourage it. If you are hoping to work on games for a AAA studio someday, I would consider C++ a must; although, you can probably get in the door with C#, as a lot studios develop tools in C# because it is quicker.

I would also say that writing some low level classes in C++ can give you a deeper appreciation for when which classes are useful.
0

Share this post


Link to post
Share on other sites
I started software development in a time where MS state of the art compiler was the MS C-6.0 Compiler. I learned C++ software engineering with the next generation Compiler MS C/C++7.0 compiler and since than I never stopped developing software in C/C++.

Both languages C and C++ gives you a huge variance in how to organize your code, how to organize your data structures and many other things that make up the development of a software system. But on the other hand the same variance gives you the possibility of misunderstanding concepts of these languages.

I found that only a few C/C++ software engineers are able to create easy to understand and easy to maintain systems. But these few are doing nothing else than developing software architectures and the basic structures of software systems the whole day.

So I think, if you do not want to learn C/C++ for the next years every day again and again, you should start with some other language.
1

Share this post


Link to post
Share on other sites
[quote name='Dagz' timestamp='1331604151' post='4921543']
...
[/quote]

STOP READING WOLFIRE BLOG [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img] [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img]

Anyway... the answers above sum it up pretty well. What you've heard is pretty much wrong all the way.
Having said that, learning C++ won't harm you, it can only make you a better programmer and also more likely to score a job in the game industry in the engine development department, if that's where your heart is at.

Also, don't fall into the flame wars..OpenGL, DX... learn it all, leave the flame wars to clueless teenagers.
1

Share this post


Link to post
Share on other sites
[quote name='Samurai Jack' timestamp='1331641569' post='4921630']
First of, I'm a C++ engineer for almost 12 years now.
[/quote]

How come that every single time somebody starts like this on a forum the post ends up being ahemm... pretty incorrect? :P
1

Share this post


Link to post
Share on other sites
Okay thanks guys, I'll take your advice and stick with XNA and C#. I'm suprised I got 9 replies in only one day, this community must be quite active.
0

Share this post


Link to post
Share on other sites
[quote name='Samurai Jack' timestamp='1331641569' post='4921630']
If you're not able to finish a game in XNA you will never be able to finish it in C++. That's my practical answer.
[/quote] Ditto[img]http://public.gamedev.net//public/style_emoticons/default/laugh.png[/img]
0

Share this post


Link to post
Share on other sites
[quote name='Samurai Jack' timestamp='1331641569' post='4921630']
First of, I'm a C++ engineer for almost 12 years now.
[/quote]
You mean "you're a C++ engineer [i]from 12 years ago[/i]"? The rest of your response might make more sense in such a context.

I don't think this is the place for a line-by-line look at your post, which would be rather off-topic in the current discussion, but suffice it to say that some of your views about C++ standard library and compiler support (both of which are actually quite good) don't really apply any more, or are only relevant when talking about embedded or console development that would not be of interest to a beginner.

I do appreciate the main point you were trying to make in support of C# and XNA, but misinforming a beginner about some of the problems with C++ isn't really a good way to make the point. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
0

Share this post


Link to post
Share on other sites
[quote name='Zael' timestamp='1331654630' post='4921675']
...because of the [b]low-level[/b] access it gives ([i][color=#FF0000]bitwise operations[/color]...[/i]
[/quote]

Low-level? "You keep using that word. I do not think it means what you think it means."
0

Share this post


Link to post
Share on other sites
[quote name='Zael' timestamp='1331654630' post='4921675']
Whether you should learn C++ or not depends a lot on why you want to learn it. If you want to learn it so that you can make games that run faster, don't bother. If you want to make games that are cross-platform, java might still be a better approach. If you want to simply develop your skills, I highly encourage it. If you are hoping to work on games for a AAA studio someday, I would consider C++ a must; although, you can probably get in the door with C#, as a lot studios develop tools in C# because it is quicker.
[/quote]
You won't get your foot in the door with only knowing C#, at least not on a game team that is using C++ as the main game language. The games industry doesn't really allow you to learn a language from scratch on the job if that is the main teams language. Now learning C# on the job however does happen, but defenitly not C++ from a beginner level, your application will be looked and and discarded if the job requires C++.
0

Share this post


Link to post
Share on other sites
[quote name='Dagz' timestamp='1331604151' post='4921543']
The major pro's and cons of the two seem to be that opengl is more powerful and efficient and can run on practically all hardware, where as directx is weaker and lacking in these qualities but much easier to learn.
[/quote]

:/

I am rather curious about where you heard this as OpenGL is known to be easier to learn than DirectX and both are equal in terms of what can be achieved (although I prefer the way DirectX is structured).

Anyway you dont have to leave C# to use DirectX / OpenGL, theres well known stable wrappers that have all the benefits of DirectX / OpenGL, have a look at SharpDX, SlimDX or OpenTK and if you are still worried about performance, which tbh you shouldnt be as the performance difference is unnoticeable, have a look at [url="http://code4k.blogspot.com/2011/03/benchmarking-cnet-direct3d-11-apis-vs.html"]http://code4k.blogsp...11-apis-vs.html[/url] it is an old thread and I typically avoid benchmarking articles but it does give an idea on how close C# can be to C++

[quote][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left]Also, don't fall into the flame wars..OpenGL, DX... learn it all, leave the flame wars to clueless teenagers. [/left][/size][/font][/color][/quote]

This.

Comparison wars happen with everything, ranging from programming to politics (theres even a Egg vs Tofu war :S), nothing except for flaming and bitching occurs in these wars, the smart people are the ones who learn both areas. In the end you will likely get flamed for anything you use, I get slack all the time for preferring SQL Server over MySQL and picking .net over Java. However as one evil genius once said (and I love this quote) "You can either succeed in one area, or ultimately fail trying to master two", this isnt to say you should stick with C# for the rest of your life, its to say take one area at a time.
0

Share this post


Link to post
Share on other sites
[quote name='Dynamo_Maestro' timestamp='1331725946' post='4921937']
[quote name='Dagz' timestamp='1331604151' post='4921543']
The major pro's and cons of the two seem to be that opengl is more powerful and efficient and can run on practically all hardware, where as directx is weaker and lacking in these qualities but much easier to learn.
[/quote]

:/

I am rather curious about where you heard this as OpenGL is known to be easier to learn than DirectX and both are equal in terms of what can be achieved (although I prefer the way DirectX is structured).

Anyway you dont have to leave C# to use DirectX / OpenGL, theres well known stable wrappers that have all the benefits of DirectX / OpenGL, have a look at SharpDX, SlimDX or OpenTK and if you are still worried about performance, which tbh you shouldnt be as the performance difference is unnoticeable, have a look at [url="http://code4k.blogspot.com/2011/03/benchmarking-cnet-direct3d-11-apis-vs.html"]http://code4k.blogsp...11-apis-vs.html[/url] it is an old thread and I typically avoid benchmarking articles but it does give an idea on how close C# can be to C++

[quote]
[left]Also, don't fall into the flame wars..OpenGL, DX... learn it all, leave the flame wars to clueless teenagers.[/left]
[/quote]

This.

Comparison wars happen with everything, ranging from programming to politics (theres even a Egg vs Tofu war :S), nothing except for flaming and bitching occurs in these wars, the smart people are the ones who learn both areas. In the end you will likely get flamed for anything you use, I get slack all the time for preferring SQL Server over MySQL and picking .net over Java. However as one evil genius once said (and I love this quote) "You can either succeed in one area, or ultimately fail trying to master two", this isnt to say you should stick with C# for the rest of your life, its to say take one area at a time.
[/quote]


It is perhaps worth mentioning that the benchmark you linked primarily measures the cost of API calls (native calls have quite a bit of overhead in managed languages), The overall performance difference in an actual application will most likely be far lower.
0

Share this post


Link to post
Share on other sites
[quote name='Dynamo_Maestro' timestamp='1331725946' post='4921937']
:/

I am rather curious about where you heard this as OpenGL is known to be easier to learn than DirectX and both are equal in terms of what can be achieved (although I prefer the way DirectX is structured).[/quote]
From people who I suppose were no better informed than me.

[quote]Anyway you dont have to leave C# to use DirectX / OpenGL, theres well known stable wrappers that have all the benefits of DirectX / OpenGL, have a look at SharpDX, SlimDX or OpenTK and if you are still worried about performance, which tbh you shouldnt be as the performance difference is unnoticeable, have a look at [url="http://code4k.blogspot.com/2011/03/benchmarking-cnet-direct3d-11-apis-vs.html"]http://code4k.blogsp...11-apis-vs.html[/url] it is an old thread and I typically avoid benchmarking articles but it does give an idea on how close C# can be to C++[/quote]
Thanks, yes I have descided to stick with C# and continue using XNA. I'm planning to start trying to duplicate many of the features of the game Ragnerok Online. I love tilebased/3rd person/mouse action games like RO, and I'd like to make one like it some day. Happily I've found a website that's ripped a ton of sprites from the game, creating graphics is such a hassle :P
0

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  
Followers 0