Advertisement
RedReaper132

Episode 2

Jun 7th, 2011
2,496
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.32 KB | None | 0 0
  1. /*
  2. Compile command:
  3. g++ -o test main.cpp -lSDLmain -lSDL -lGL -lSDL_image
  4.  
  5. Windows users:
  6. Linker parameters:
  7. -lmingw32 -lSDLmain -lSDL -lopengl32 -lglu32
  8.  */
  9.  
  10. // specific headers
  11. #include "SDL/SDL.h"
  12. #include "SDL/SDL_opengl.h"
  13. #include "SDL/SDL_image.h"
  14. #include <iostream>
  15. #include <string>
  16.  
  17. int main( int agrc, char* args[] )
  18. {
  19.   SDL_Init(SDL_INIT_EVERYTHING);
  20.  
  21.   //Set OpenGL memory usage
  22.   SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );
  23.   SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8);
  24.   SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );
  25.   SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8);
  26.   SDL_GL_SetAttribute( SDL_GL_BUFFER_SIZE, 32);
  27.   SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
  28.   SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
  29.  
  30.   //Caption of the window
  31.   SDL_WM_SetCaption( "Our first game", NULL );
  32.  
  33.   //Size of the window
  34.   SDL_SetVideoMode(600,400,32, SDL_OPENGL );
  35.  
  36.   //Specific the clear color
  37.   glClearColor(1,1,1,1); //RED,GREEN,BLUE,ALPHA
  38.  
  39.   //What portion of the screen we will display
  40.   glViewport(0,0,600,400);
  41.  
  42.   //2D rendering
  43.   glMatrixMode(GL_PROJECTION);
  44.  
  45.   //"Save" it
  46.   glLoadIdentity();
  47.  
  48.   //Disable depth checking
  49.   glDisable(GL_DEPTH_TEST);
  50.  
  51.   std::cout << "OpenGL is running" << std::endl;
  52.  
  53.   //Wait 5 seconds
  54.   SDL_Delay(5000);
  55.  
  56.   //Quit SDL
  57.   SDL_Quit();
  58.  
  59.   return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement