Loading...
Searching...
No Matches
SFML Documentation

Welcome

Welcome to the official SFML documentation. Here you will find a detailed view of all the SFML classes and functions.
If you are looking for tutorials, you can visit the official website at www.sfml-dev.org.

Short example

Here is a short example, to show you how simple it is to use SFML:

#include <SFML/Audio.hpp>
int main()
{
// Create the main window
sf::RenderWindow window(sf::VideoMode({800, 600}), "SFML window");
// Load a sprite to display
const sf::Texture texture("cute_image.jpg");
sf::Sprite sprite(texture);
// Create a graphical text to display
const sf::Font font("arial.ttf");
sf::Text text(font, "Hello SFML", 50);
// Load a music to play
sf::Music music("nice_music.ogg");
// Play the music
music.play();
// Start the game loop
while (window.isOpen())
{
// Process events
while (const std::optional event = window.pollEvent())
{
// Close window: exit
if (event->is<sf::Event::Closed>())
window.close();
}
// Clear screen
window.clear();
// Draw the sprite
window.draw(sprite);
// Draw the string
window.draw(text);
// Update the window
window.display();
}
}
Class for loading and manipulating character fonts.
Definition Font.hpp:58
Streamed music played from an audio file.
Definition Music.hpp:53
Window that can serve as a target for 2D drawing.
Drawable representation of a texture, with its own transformations, color, etc.
Definition Sprite.hpp:51
Graphical text that can be drawn to a render target.
Definition Text.hpp:57
Image living on the graphics card that can be used for drawing.
Definition Texture.hpp:56
VideoMode defines a video mode (size, bpp)
Definition VideoMode.hpp:44
Closed event subtype.
Definition Event.hpp:55