June 2013
Beginner to intermediate
296 pages
6h 50m
English
Now let's get something interesting on the screen. Instead of just rendering a boring single color circle to the screen, let's actually render an image. To do this, SFML provides a couple of tools to make your life easy. First we have the
sf::Texture class that holds the actual image data loaded from the hard drive. Next is the sf::Sprite class that represents an instance with position and orientation in the scene. The texture describes the image, while the sprite describes where and how to put one on the screen.
A simple example of their relationship is as follows:
sf::Texture texture; if (!texture.loadFromFile("path/to/file.png")) { // Handle loading error } sf::Sprite sprite(texture); sprite.setPosition(100.f, ...Read now
Unlock full access