Do we use pointers in game programming?

Started by
12 comments, last by georger.araujo 9 years, 12 months ago

I'm learning c++ from basic and I have reach the pointers subject.

should I skip it or learn it, its alot of stuff to learn about, do I realy need to spend time on it?

Is it gonna help me to program games?

Advertisement

From a learning perspective, pointers are absolutely vital for dynamically allocated memory. There are newer alternatives to regular pointers, but they all more or less work the same way.

I'm learning c++ from basic and I have reach the pointers subject.
should I skip it or learn it, its alot of stuff to learn about, do I realy need to spend time on it?
Is it gonna help me to program games?


In many ways, pointers are the only reason we even use C++ in the first place. Modern usage of C++ will certainly insulate you from most of the worst parts of pointers, but understanding what they are, how they work, why they exist, and when to use them is essential.

Sean Middleditch – Game Systems Engineer – Join my team!

If you're wanting to learn C++, pointers are a critical tool - for almost any kind of software you want to write. Definitely don't skimp on learning them.

It also sounds like you're in a bit of a hurry. Motivation is great, but it's also important to understand that you're in for a very long and often difficult ride. The more things you are willing to spend time on learning, the better a programmer you will become over time.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

From a learning perspective, pointers are absolutely vital for dynamically allocated memory. There are newer alternatives to regular pointers, but they all more or less work the same way.

Thank you.

More importantly than learning about pointers themselves, IMHO, is that learning them is a great first step to learning about memory. This will be invaluable later on as you gain more experience, especially when it comes to optimization (whether for speed or other types of targets).

I concur with the above posters. If you were interested in game development only, than you could use a tool very specific to it, like Unity, Gamemaker, etc... But, since you are going the C++ route, which in my opinion has nothing wrong with it(except that it can take longer both learning and using, but with more control over code), I'd say you need pointers very much. Technically, you use a form of a pointer any time you would dynamically create an object, and in games, you tend to dynamically create lots of objects, like enemies, bullets, etc... Now, there are technically alternatives, but in any case, you should indeed learn the theory and then if you don't use them later, OK. Then, if you need them in order to apply some API, you'll know what you are doing. Even the "simple" Irrlicht engine uses pointers all over the place.



Pointers are vital in other languages too, but they're usually called something else, such as 'references'.

Pointers are vital in other languages too, but they're usually called something else, such as 'references'.

Caveat: many of those languages do not let you do raw pointer arithmetic, casting voids, or other dangerous tricks that you can do with real C/C++ pointers. But understanding pointers and memory is vital for a deeper understanding of computing, if you are looking for that.

Pointers are vital in other languages too, but they're usually called something else, such as 'references'.

There's a big difference between pointers and references from a "learning" point of view. References are "magic", so they're much easier to understand (or rather, not understand). I don't necessarily think that's healthy, but you don't really need to understand how pointers work, or even memory at all for that matter, in a lot of higher level languages.

This topic is closed to new replies.

Advertisement