Created
January 10, 2013 22:17
-
-
Save hobnob/4506292 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,2c1,3 | |
< #include <SDL/SDL.h> | |
< #include <SDL/SDL_image.h> | |
--- | |
> #include <SDL2/SDL.h> | |
> #include <SDL2/SDL_image.h> | |
> | |
8,9c9,11 | |
< SDL_Surface* Surf_Display; | |
< SDL_Surface* Surf_Image; | |
--- | |
> SDL_Window* window; // Declare a pointer to an SDL_Window | |
> SDL_Texture* Surf_Image; | |
> SDL_Renderer* renderer; | |
21,24d22 | |
< | |
< if((Surf_Display = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE | SDL_DOUBLEBUF)) == NULL) { | |
< //return false; | |
< } | |
25a24,32 | |
> // Create an application window with the following settings: | |
> window = SDL_CreateWindow( | |
> "An SDL2 window", // window title | |
> SDL_WINDOWPOS_UNDEFINED, // initial x position | |
> SDL_WINDOWPOS_UNDEFINED, // initial y position | |
> 640, // width, in pixels | |
> 480, // height, in pixels | |
> SDL_WINDOW_SHOWN|SDL_WINDOW_OPENGL // flags - see below | |
> ); | |
27c34 | |
< SDL_Surface* Surf_Temp = NULL; | |
--- | |
> renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); | |
29,35c36,51 | |
< if((Surf_Temp = IMG_Load("loading-text.png")) == NULL) { | |
< Running = false; | |
< } | |
< else | |
< { | |
< Surf_Image = SDL_DisplayFormatAlpha(Surf_Temp); | |
< SDL_FreeSurface(Surf_Temp); | |
--- | |
> /** | |
> SDL_WINDOW_FULLSCREEN | |
> SDL_WINDOW_OPENGL | |
> SDL_WINDOW_SHOWN | |
> SDL_WINDOW_BORDERLESS | |
> SDL_WINDOW_RESIZABLE | |
> SDL_WINDOW_MAXIMIZED | |
> SDL_WINDOW_MINIMIZED | |
> SDL_WINDOW_INPUT_GRABBED | |
> **/ | |
> | |
> //SDL_Surface* Surf_Temp = NULL; | |
> | |
> if((Surf_Image = IMG_LoadTexture(renderer, "loading-text.png")) == NULL) { | |
> printf("IMG_Load: %s\n", IMG_GetError()); | |
> //Running = false; | |
68,70c84 | |
< //Clear the screen | |
< SDL_Rect r={0,0,640,480}; | |
< SDL_FillRect( Surf_Display, &r, -1 ); | |
--- | |
> SDL_Rect SrcR; | |
72,73c86,89 | |
< //Paint the screen | |
< SDL_BlitSurface(Surf_Image, NULL, Surf_Display, &DestR); | |
--- | |
> SrcR.x = 0; | |
> SrcR.y = 0; | |
> SrcR.w = DestR.w = 210; | |
> SrcR.h = DestR.h = 79; | |
75,76c91,93 | |
< //Bring the backbuffer forward | |
< SDL_Flip(Surf_Display); | |
--- | |
> SDL_RenderClear(renderer); | |
> SDL_RenderCopy (renderer,Surf_Image,&SrcR,&DestR); | |
> SDL_RenderPresent(renderer); | |
82c99,103 | |
< SDL_FreeSurface(Surf_Display); | |
--- | |
> | |
> SDL_DestroyTexture(Surf_Image); | |
> SDL_DestroyRenderer(renderer); | |
> // Close and destroy the window | |
> SDL_DestroyWindow(window); | |
88c109 | |
< } | |
--- | |
> } | |
\ No newline at end of file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1c1 | |
< #include <SDL/SDL.h> | |
--- | |
> #include <SDL2/SDL.h> | |
\ No newline at end of file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3c3 | |
< g++ main.cpp -o main -lSDL -lSDL_image | |
--- | |
> g++ main.cpp -o main -lSDL2 -lSDL2_image -Wl,-rpath=/usr/local/lib | |
\ No newline at end of file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment