How to display Sprite/image in c++?

Sep 23, 2010 at 2:43am
What are the options to load the image from C++ for a small 2d game?
Sep 23, 2010 at 2:47am
Well avoid using the console as the platform for developing for starters. Try using one of the many libraries out there to handle graphics, audio, key presses, ect. Here are some of them:

SFML: http://www.sfml-dev.org/download.php
Tutorial: http://cpp.wikicomplete.info/tutorial:setting-up-sfml

SDL: http://www.libsdl.org/
Tutorial: http://lazyfoo.net/SDL_tutorials/lesson01/index.php

OpenGL: http://www.opengl.org/
Tutorial: http://www.glprogramming.com/red/about.html

Hope this helps.
Last edited on Sep 23, 2010 at 2:47am
Sep 23, 2010 at 2:59am
Again standard C++ libraries fail to provide an imaging library again. Try the above URL.

In Java SDK, there is a Java2D API built-in for manipulating images with operations like read/write, adjust contrast, texturing etc etc. Not efficient but good enough for a small 2D game :P
Sep 23, 2010 at 3:04am
+1 vote for SFML
Sep 23, 2010 at 3:30am
SFML is available for use in C, C++, D, .NET (C#, VB.net), Python, OCaml and Ruby.


I wonder why it is not available for Java. Perhaps Java SDK already has and they don't want duplication of effort ? Hmmm.....
Sep 28, 2010 at 8:04am
Thanks MottMan...I will go with OpenGL.

Sep 28, 2010 at 3:29pm
FWIW, you can use OpenGL directly with SFML, but SFML automates things like window creation, music playback, input, image loading, etc, etc, etc. Whereas OpenGL alone only does the graphics.

If you don't want to use SFML's graphics and prefer OpenGL, I'd still recommend SFML as it makes things overall much easier.

Also, SFML's rendering engine uses OpenGL under the hood, so it's not really that much slower than using OpenGL directly (and it's tons easier.
Sep 28, 2010 at 4:47pm
@MottMan, Disch,

I am on the graphics chapter of my C++ book. The author recommends FLTK for the GUI. Are the ones you mentioned good for beginners? Are they compatible with the VC++ IDE? I would like an extremely user friendly GUI so that I can concentrate on the C++ code rather than getting the GUI to install and work correctly.

Sep 28, 2010 at 7:22pm
SFML (from what I've skimmed) is very user friendly (as far as libs go). The one thing you may have trouble with is installing and setting up but most people would tell you it is worth it. I have used SDL which is quite easy to setup, but most of the function calls are clumsy or have odd syntax. SFML is great for everyone.

Oh, and yes, as far as I've heard you can use SFML fine with VC++.
Topic archived. No new replies allowed.