C++

Miscellaneous Forums/General Discussion/C++

I wanted to try my hand at making games in C++. Yes, I know it's really tough.

After learning (sort of) the language, I wanted to try making some pretty screenies instead of just using the console window for once. I looked up tutorials on how to create a window, and the only ones I could find (GameTutorials.com and GameDev.net) were ancient, used "Windows 95" in the same sentence as "modern," and - most importantly - failed to compile in Dev-C++, the compiler I've chosen.

Dev-C++ does have a template that creates a window for you, but it doesn't help me to actually learn it.

In addition, I have another question. Can I draw graphics (sprites, animations, rotations, etc.) without using OpenGL, DirectX, or some equivalent? Is there an easy way to learn OpenGL or DirectX?

Why is there nothing on the internet? All of the "programmer wanted" job listings call for years of C++ experience, but there doesn't seem to be much of an online community.

Just because you're not using Blitz, doesn't mean you have to write your own 2D engine or do everything at a low level. There are plenty of 3D acclerated 2D engines out there which offer similar features to Blitz.

There was a very cool one I came across recently, and for some reason I didn't bookmark it. Anyway, you've still got HGE ( a personal favourite which works nicely with Dev ), SDL, the PopCap framework ( not sure if you can use this with Dev) the Playground SDK ( very nice one, but you'll need to use Visual C++, Dev won't cut it. )

If you want to learn it, you'll need a good book. The reason you can't find much on the Net is that most people learning C++ to make games want to make 3D games. As you've already discovered, it's been a few years since people were commonly making 2D games in C++ so most of the information is very out of date. ( Although some might still be helpful. SDL has evolved a little, but it's still going. )

Dabz over at Syntax Bomb will probably be able to give you a few pointers - he's into doing 2D stuff in C++ at the moment. Not sure what compiler he's using, though.

I looked up tutorials on how to create a window, and the only ones I could find (GameTutorials.com and GameDev.net) were ancient, used "Windows 95" in the same sentence as "modern," and - most importantly - failed to compile in Dev-C++, the compiler I've chosen.

Dev-C++ does have a template that creates a window for you, but it doesn't help me to actually learn it.

Creating a window usually isn't that hard, and I usually just copy + paste the code and forget about it. Just try searching for a OpenGL or DirectX (whichever you plan on using) tutorial and work from there.

Second, I need to point out that, especially since you're beginning, Dev-C++ is probably one of the worst choices you could make for a C++ IDE. It lacks many features that you are really going to need when your project starts growing. I'd strongly recommend an IDE like Visual C++ 2005/2008 Express (free), or at the very least Code::Blocks if you for some reason hate Microsoft products (even good ones).

In addition, I have another question. Can I draw graphics (sprites, animations, rotations, etc.) without using OpenGL, DirectX, or some equivalent?

There are probably many really good 2D accelerated graphics libraries out there for C++, but unfortunately I don't know of any since I work mainly with 3D in C++. Look around, try googling "2D c++ game engine" or "2D c++ graphics engine" and you'll probably find something.

Edit: I found this from GameDev.net:
http://www.twilightsembrace.com/personal/gamelibs.php

Is there an easy way to learn OpenGL or DirectX?

I don't know about OpenGL, but I found the tutorials included with DirectX to be quite adequate. Just make sure you have a very good understanding of C and C++ features (pointers, arrays, defines, and enums mostly) first or you will get totally lost.

Why is there nothing on the internet? All of the "programmer wanted" job listings call for years of C++ experience, but there doesn't seem to be much of an online community.

You just need to know where to look. If you want info about C++ programming itself, there are plenty of forums for that, but normally (once you've learned C++) you check the forums of the various libraries that you use. For example, the OGRE 3D graphics engine is the main component in my game, so I often check the Ogre community forums, etc. There are also very active library-neutral forums (like GameDev) devoted to game programming, which are useful.

It's worth browsing the Devpaks Repository to see what libraries are knocking around for DevC++. It's the easiest system for getting them up and running also.

While Visual Studio is clearly a more powerful IDE and compiler in the long run, I do think there's something to be said for Dev C++ when you're starting out. Visual Studio is remarkably intimidating in my opinion, and even seasoned professionals will admit that it's a little tricky and quirky at times. Dev C++ is the Blitz3D of C++. It's a small, uncluttered IDE with basic functionality, a small memory footprint and allows the novice and intermediate C++ programmer to get into writing some code quickly without having to learn the interface. Heck, it still has basic intellisense, so if you've been using the official IDE's for Blitz3D or BlitzPlus until recently, it will still be a small step up.

Can I draw graphics (sprites, animations, rotations, etc.) without using OpenGL, DirectX, or some equivalent?

Sure, you can draw straight to a window context (via GDI or whatnot).
Not very efficient though, unless you do it through something like Quartz (on Mac) which can be GL accelerated.

wxWidgets, the small C++ library, has one or two functions to help you create Windows and stuff, using a nice, simple API - and is also cross-platform, if you into things like that.

I find it hard to believe there's "nothing on the internet" about C++ libs for gaming though...

If you use a gfx engine like irrlicht or something there is usually some simple get you started stuff in the wiki/forums/examples.

I too have recently started dabbling in c++ again after many many years away from it, using "Code::blocks" (a very nice c++ ide for linux/windows) and have found irrlicht quite easy to get into on a basic level, as it seems to be a complete kit as far as gfx are concerned.

From Dabz:

I'm using Visual Studio Express 2008...

If the poster isnt too keen on 2D development with DirectX or OpenGL, GDI/GDI+ is a perfectly reasonable way to create 2D, granted, you'll get nothing flash, but you can do the double buffer thing, transparent images, primitive drawing etc etc, and winmm.h is enough for sound (Wav and midi).


http://www.microsoft.com/express/samples/GameCreators/

A good way of getting started without spending money. You get to use the language of C++ without the headache of an engine.

Once you outgrow it (if you do) you can move on...

Is GDI/GDI+ fast enough to make games with? Is it comparable (in terms of speed) with OpenGL/DirectX?

Can it do simple operations like image transformations?

If you are looking for a good 2D engine look here:
http://hge.relishgames.com/
or
http://www.allegro.cc/

If you want a small and fast IDE (+minGW):
http://www.codeblocks.org/

You really dont need GDI to have a simple and goog framework.

bye

Dabz reckons this site is worth a look for going GDI stuff:
http://www.bringyou.to/games/

HGE seems very impressive, and ideal for my needs - thanks for the info. :-)

Thanks all. Those links all look pretty good.

I've just started using Visual C++ 2008 Express and it seems very good indeed.

http://www.microsoft.com/express/product/default.aspx

I found this:

http://lazyfoo.net/SDL_tutorials/index.php

very useful for the basics of 2d using c++ and sdl

I use mingw for compiling and all the source from these tutorials worked fine iirc