Documentation de SFML 2.6.1

Attention: cette page se réfère à une ancienne version de SFML. Cliquez ici pour passer à la dernière version.
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
sf::Texture texture;
if (!texture.loadFromFile("cute_image.jpg"))
return EXIT_FAILURE;
sf::Sprite sprite(texture);
// Create a graphical text to display
sf::Font font;
if (!font.loadFromFile("arial.ttf"))
return EXIT_FAILURE;
sf::Text text("Hello SFML", font, 50);
// Load a music to play
sf::Music music;
if (!music.openFromFile("nice_music.ogg"))
return EXIT_FAILURE;
// Play the music
music.play();
// Start the game loop
while (window.isOpen())
{
// Process events
sf::Event event;
while (window.pollEvent(event))
{
// Close window: exit
if (event.type == 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();
}
return EXIT_SUCCESS;
}
Defines a system event and its parameters.
Definition Event.hpp:45
EventType type
Type of the event.
Definition Event.hpp:220
@ Closed
The window requested to be closed (no data)
Definition Event.hpp:190
Class for loading and manipulating character fonts.
Definition Font.hpp:49
bool loadFromFile(const std::string &filename)
Load the font from a file.
Streamed music played from an audio file.
Definition Music.hpp:49
bool openFromFile(const std::string &filename)
Open a music from an audio file.
Window that can serve as a target for 2D drawing.
void play()
Start or resume playing the audio stream.
Drawable representation of a texture, with its own transformations, color, etc.
Definition Sprite.hpp:48
Graphical text that can be drawn to a render target.
Definition Text.hpp:49
Image living on the graphics card that can be used for drawing.
Definition Texture.hpp:49
bool loadFromFile(const std::string &filename, const IntRect &area=IntRect())
Load the texture from a file on disk.
VideoMode defines a video mode (width, height, bpp)
Definition VideoMode.hpp:42