Advertisement
Guest User

Untitled

a guest
Apr 27th, 2018
614
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. /*This source code copyrighted by Lazy Foo' Productions (2004-2015)
  2. and may not be redistributed without written permission.*/
  3.  
  4. //Using SDL and standard IO
  5. #include <SDL.h>
  6. #include <stdio.h>
  7.  
  8. //Screen dimension constants
  9. const int SCREEN_WIDTH = 640;
  10. const int SCREEN_HEIGHT = 480;
  11.  
  12. int main( int argc, char* args[] )
  13. {
  14. //The window we'll be rendering to
  15. SDL_Window* window = NULL;
  16.  
  17. //The surface contained by the window
  18. SDL_Surface* screenSurface = NULL;
  19.  
  20. //Initialize SDL
  21. if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
  22. {
  23. printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() );
  24. }
  25. else
  26. {
  27. //Create window
  28. window = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
  29. if( window == NULL )
  30. {
  31. printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() );
  32. }
  33. else
  34. {
  35. //Get window surface
  36. screenSurface = SDL_GetWindowSurface( window );
  37.  
  38. //Fill the surface white
  39. SDL_FillRect( screenSurface, NULL, SDL_MapRGB( screenSurface->format, 0xFF, 0xFF, 0xFF ) );
  40.  
  41. //Update the surface
  42. SDL_UpdateWindowSurface( window );
  43.  
  44. //Wait two seconds
  45. SDL_Delay( 2000 );
  46. }
  47. }
  48.  
  49. //Destroy window
  50. SDL_DestroyWindow( window );
  51.  
  52. //Quit SDL subsystems
  53. SDL_Quit();
  54.  
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement