-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdraw-image.cpp
More file actions
32 lines (31 loc) · 858 Bytes
/
Copy pathdraw-image.cpp
File metadata and controls
32 lines (31 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <SFML/Graphics.hpp>
int main() {
sf::Texture texture;
// il faut bien préciser l'arborescence de l'image que l'on veut ouvrir
if (!texture.loadFromFile("C:/Users/Matthieu/Pictures/Saved Pictures/Berserk Wallpaper 2.jpg"))
{
// erreur...
}
sf::Sprite sprite;
sprite.setTexture(texture);
// Création de la fenêtre
sf::Vector2u sz = texture.getSize();
sf::RenderWindow window(sf::VideoMode(sz.y, sz.x), "image"); // Boucle principale
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event)) {
// Demande de fermeture de la fenêtre
if (event.type == sf::Event::Closed)
window.close();
}
// On efface la fenêtre (en blanc)
window.clear(sf::Color::White);
// Affichage du sprite
window.draw(sprite);
// Mise à jour de la fenêtre
window.display();
}
return 0;
}