Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 KB | None | 0 0
  1.  
  2. #include <SDL/SDL.h>
  3. #include <Windows.h>
  4. #include <gl/GL.h>
  5. #include <gl/GLU.h>
  6. #include <iostream>
  7.  
  8. #ifdef main
  9. #undef main
  10. #endif
  11.  
  12. #pragma comment (lib, "sdl.lib")
  13. #pragma comment (lib, "opengl32.lib")
  14. #pragma comment (lib, "glu32.lib")
  15.  
  16. int main () {
  17.  
  18.     SDL_Init (SDL_INIT_EVERYTHING);
  19.  
  20.     SDL_SetVideoMode (800, 600, 32, SDL_OPENGL);
  21.  
  22.     glViewport (0, 0, 800, 600);
  23.     glClearColor (1.f, 1.f, 1.f, 1.f);
  24.    
  25.     glMatrixMode (GL_PROJECTION);
  26.     glLoadIdentity ();
  27.     //glOrtho (0.f, 800.f, 600.f, 0.f, 0.f, 1.f);
  28.     gluPerspective (45.f, 800.f/600.f, 0.1f, 1000.f);
  29.  
  30.     glMatrixMode (GL_MODELVIEW);
  31.     glLoadIdentity ();
  32.  
  33.     glDisable (GL_DEPTH_TEST);
  34.  
  35.     bool quit = false;
  36.     while (!quit) {
  37.  
  38.         SDL_Event ev;
  39.         SDL_PumpEvents ();
  40.         while (SDL_PollEvent (&ev)) {
  41.             if (ev.type == SDL_QUIT)
  42.                 quit = true;
  43.         }
  44.  
  45.         Sleep (16);
  46.         glClear (GL_COLOR_BUFFER_BIT);
  47.  
  48.         glRotatef (0.5f, 0.f, 0.f, 1.f);
  49.  
  50.         glBegin (GL_QUADS);
  51.             glColor3f (1.f, 0.f, 0.f);
  52.             glVertex3f (-1.f,  1.f, -10.f);
  53.             glVertex3f ( 1.f,  1.f, -10.f);
  54.             glVertex3f ( 1.f, -1.f, -10.f);
  55.             glVertex3f (-1.f, -1.f, -10.f);
  56.         glEnd ();
  57.  
  58.         SDL_GL_SwapBuffers ();
  59.     }
  60.  
  61.     return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement