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
// Load a sprite to display
sf::Sprite sprite(texture);
// Create a graphical text to display
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
{
// 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();
}
}
void draw(const Drawable &drawable, const RenderStates &states=RenderStates::Default)
Draw a drawable object to the render target.
void clear(Color color=Color::Black)
Clear the entire target with a single color.
Drawable representation of a texture, with its own transformations, color, etc.
Definition Sprite.hpp:51
std::optional< Event > pollEvent()
Pop the next event from the front of the FIFO event queue, if any, and return it.