Advertisement
Guest User

Untitled

a guest
Jun 30th, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. #include <SFML/Window.hpp>
  2. #include <SFML/OpenGL.hpp>
  3.  
  4. int main()
  5. {
  6.     // crée la fenêtre
  7.     sf::Window window(sf::VideoMode(800, 600), "OpenGL", sf::Style::Default, sf::ContextSettings(32));
  8.     window.setVerticalSyncEnabled(true);
  9.  
  10.     // chargement des ressources, initialisation des états OpenGL, ...
  11.  
  12.     // la boucle principale
  13.     bool running = true;
  14.     while (running)
  15.     {
  16.         // gestion des évènements
  17.         sf::Event event;
  18.         while (window.pollEvent(event))
  19.         {
  20.             if (event.type == sf::Event::Closed)
  21.             {
  22.                 // on stoppe le programme
  23.                 running = false;
  24.             }
  25.             else if (event.type == sf::Event::Resized)
  26.             {
  27.                 // on ajuste le viewport lorsque la fenêtre est redimensionnée
  28.                 glViewport(0, 0, event.size.width, event.size.height);
  29.             }
  30.         }
  31.  
  32.         // effacement les tampons de couleur/profondeur
  33.         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  34.  
  35.         // dessin...
  36.  
  37.         // termine la trame courante (en interne, échange les deux tampons de rendu)
  38.         window.display();
  39.     }
  40.  
  41.     // libération des ressources...
  42.  
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement