The first step for graphics in C++?

Started by
5 comments, last by ryancfcsas 12 years, 10 months ago
This is my first post here, and I hope that the question I am asking has not been asked and answered before. I did some searching, but didn't find specifically what I am looking for.

I started with C++ about a week ago, using visual c++ express, and my goal is to start using C++ for future solo game projects. Previously I have used Multimedia fusion 2 developer to develop games, and I have so far finished and released one game with it (Cave of no return, for those that are interested).

The reason I want to move over to C++ is that it seemingly provides a lot (and I really mean a lot) more freedom. Not only can C++ be used to create applications for many different platforms, but it also gives the developer great freedom to structure a project in a nice and logical way.

Larger projects in MMF2 can get hard to monitor properly, and the frame based structure means that if you want to change something engine wise, you have to change it in every single frame you have created manually (at least this is my experience - I might have missed something). In C++ you can call functions from pretty much anywhere, and if something needs changing you can generally do so by altering only that specific function.

So far I am still stuck to console programming in C++, and while I feel that I am starting to get a grasp of how things work (I am following the tutorials on http://www.learncpp.com/), I am pretty unsure how to start creating graphics. That is, I know a lots of ways to create graphics using tools like Allegro or SFML, but I'd rather take things one step at a time, and learn how to code stuff from the beginning (from a C++ perspective - otherwise I'd have to move to assembly/machine code level I guess, but I am not that masochistic).

So, let's pretend I know all the stuff from the tutorials at learncpp.com (I don't, but I am about halfway there so far). What would be the next logical step towards gettings some graphics on the screen? If someone could point me in the right direction here I would be very thankful.

Thank you.
Advertisement
Well you can't expect C++ to have any functions to draw and create graphics beyond simple text based visuals (terminal output).
C++ is a powerful language that was developed for very low level work. However, it is quite popular and people have written libraries that allow it to work with hardware to render graphics. As far as I know there is really no way around adding a library like SFML, SDL, or Allegro. You can probably play a bit with text adventures with primitive ASCII graphics if you want to just get something visual working. I'd use a 2D screen buffer of chars to make ASCII graphics and pictures.

C++ is a very lean and fast language that was made for low level work. We can adapt it to other needs however like rendering graphics, sounds, and joystick polling.
In this way, C++ works like glue, by binding components together so that we can use elements and functions from libraries.
You also might want to look into DirectX or OpenGL to get you started with serious graphics programming. Your first hurdle is to set up a window where you can render stuff using one of the aforementioned APIs. Your second hurdle is to actually use em.

There are lot of resources and tutorials in this area:

DirectX:
http://msdn.microsoft.com/en-us/library/ee416396%28v=VS.85%29.aspx

OpenGL:
http://nehe.gamedev.net/
http://www.opengl.org/code/


(ask uncle google for more)
Latest project: Sideways Racing on the iPad
Thank you for the replies. I will take a look at OpenGL for now. After a bit of reading it seems like a good alternative considering I want to create applications for multiple platforms.

I know that C++ is (pretty) low level, and that there are no simple ways to draw graphics "by hand" (that is, without external libraries), but I really like the concept of doing things one building block at a time (first I learn A, and by learning A I am ready to learn B etc.). I guess I should submit to the fact that using ready libraries is the way to go (after all, iostream, cstdlib and such are also libraries that I use without caring so much about how they work).

Thanks again - I look forward to spending a lot of time on these forums :)
I would recommend you try SDL (Simple DirectMedia Layer). It is a graphical API that is used for games and is a good progressive block to the more complicated APIs like OpenGL and Win32 API.

However, even SDL will require you to know a fair amount of C++ but does not require you know everything from the book. I would recommend you know the following before proceeding:

Primitive data types (int, char, bool, long, double).
String class.
Pointers and pointer arithmetic.
Classes, data structures (structs), unions.
Simple operator overloading.
Function overloading.
Enumerations.

To make anything decent, you'll need to learn object oriented programming techniques, this will help you when you come to work on joint projects.

To be honest, I started without some of these, but make sure you have pointers, primitive data types, classes, and operator overloading covered. About 4,5 years ago, I didn't quite get C++ fully but I still tried to learn SDL, and it helped me to understand the C++. I have been a lead programmer on a number of joint projects, so don't lose heart. :)
[size="5"]My Twitter

[size="2"]I do not care for reputation, merely to help fellow users.

I would recommend you try SDL (Simple DirectMedia Layer). It is a graphical API that is used for games and is a good progressive block to the more complicated APIs like OpenGL and Win32 API.

However, even SDL will require you to know a fair amount of C++ but does not require you know everything from the book. I would recommend you know the following before proceeding:

Primitive data types (int, char, bool, long, double).
String class.
Pointers and pointer arithmetic.
Classes, data structures (structs), unions.
Simple operator overloading.
Function overloading.
Enumerations.

To make anything decent, you'll need to learn object oriented programming techniques, this will help you when you come to work on joint projects.

To be honest, I started without some of these, but make sure you have pointers, primitive data types, classes, and operator overloading covered. About 4,5 years ago, I didn't quite get C++ fully but I still tried to learn SDL, and it helped me to understand the C++. I have been a lead programmer on a number of joint projects, so don't lose heart. :)


Thank you - this is what I am looking for. Those are, quite conveniently, the next concepts in the tutorial I am following, and I'll make sure to have them covered before moving on to SDL (and OpenGL later on).
Your welcome. Trust me, it's hard and it can get nasty but you get better as a coder and you end up really enjoying programming for games/applications.
[size="5"]My Twitter

[size="2"]I do not care for reputation, merely to help fellow users.

This topic is closed to new replies.

Advertisement