Advertisement
Benjamin_Loison

File main.cpp Tutorial C++ SDL2.0 OpenGL (CodeBlocks)

Apr 13th, 2017
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <SDL.h>
  2. #include <GL/gl.h>
  3. #include <GL/glu.h>
  4.  
  5. int main(int argc, char *argv[])
  6. {
  7.     SDL_Init(SDL_INIT_VIDEO);
  8.     SDL_Window *screen = SDL_CreateWindow("Ma fenetre de jeu", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_OPENGL);
  9.     SDL_GLContext glcontext = SDL_GL_CreateContext(screen);
  10.     SDL_Event event;
  11.  
  12.     while (continuer)
  13.     {
  14.         SDL_WaitEvent(&event);
  15.         switch(event.type)
  16.         {
  17.             case SDL_QUIT:
  18.                 continuer = false;
  19.         }
  20.  
  21.         glClear(GL_COLOR_BUFFER_BIT);
  22.  
  23.         glBegin(GL_TRIANGLES);
  24.             glColor3ub(255,0,0);    glVertex2d(-0.75,-0.75);
  25.             glColor3ub(0,255,0);    glVertex2d(0,0.75);
  26.             glColor3ub(0,0,255);    glVertex2d(0.75,-0.75);
  27.         glEnd();
  28.  
  29.         glFlush();
  30.         SDL_GL_SwapWindow(screen);
  31.     }
  32.  
  33.     SDL_Quit();
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement