Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. #include <iostream>
  2. #include <SDL.h>
  3. #include <SDL_opengl.h>
  4.  
  5. int main ()
  6. {
  7. if ( SDL_Init( SDL_INIT_EVERYTHING ) < 0 )
  8. return 1;
  9.  
  10. atexit( SDL_Quit );
  11.  
  12. SDL_Window *pWindow = nullptr;
  13. SDL_GLContext pGLContext = nullptr;
  14.  
  15. pWindow = SDL_CreateWindow( "SDLTest", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL );
  16.  
  17. if ( pWindow == nullptr )
  18. {
  19. std::cout << SDL_GetError() << std::endl;
  20. return 1;
  21. }
  22.  
  23. pGLContext = SDL_GL_CreateContext( pWindow );
  24.  
  25. if ( pGLContext == nullptr )
  26. {
  27. std::cout << SDL_GetError() << std::endl;
  28. return 1;
  29. }
  30.  
  31. SDL_GL_SetSwapInterval( 0 );
  32.  
  33. SDL_Event event;
  34. bool bDone = false;
  35.  
  36. while ( !bDone )
  37. {
  38. while ( SDL_PollEvent( &event ) )
  39. {
  40. if ( event.type == SDL_QUIT )
  41. bDone = true;
  42. }
  43. glClear( GL_COLOR_BUFFER_BIT );
  44. SDL_GL_SwapWindow( pWindow );
  45. }
  46.  
  47. SDL_GL_DeleteContext( pGLContext );
  48. SDL_DestroyWindow( pWindow );
  49.  
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement