SFML 3.0.1
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>
#include <SFML/Graphics.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();
}
}
Audio.hpp
Graphics.hpp
sf::Font
Class for loading and manipulating character fonts.
Definition Font.hpp:58
sf::Music
Streamed music played from an audio file.
Definition Music.hpp:53
sf::RenderTarget::draw
void draw(const Drawable &drawable, const RenderStates &states=RenderStates::Default)
Draw a drawable object to the render target.
sf::RenderTarget::clear
void clear(Color color=Color::Black)
Clear the entire target with a single color.
sf::RenderWindow
Window that can serve as a target for 2D drawing.
Definition RenderWindow.hpp:55
sf::Sprite
Drawable representation of a texture, with its own transformations, color, etc.
Definition Sprite.hpp:51
sf::Text
Graphical text that can be drawn to a render target.
Definition Text.hpp:57
sf::Texture
Image living on the graphics card that can be used for drawing.
Definition Texture.hpp:56
sf::VideoMode
VideoMode defines a video mode (size, bpp)
Definition VideoMode.hpp:44
sf::WindowBase::pollEvent
std::optional< Event > pollEvent()
Pop the next event from the front of the FIFO event queue, if any, and return it.
sf::WindowBase::isOpen
bool isOpen() const
Tell whether or not the window is open.
sf::Window::close
void close() override
Close the window and destroy all the attached resources.
sf::Window::display
void display()
Display on screen what has been rendered to the window so far.
sf::Event::Closed
Closed event subtype.
Definition Event.hpp:55