pull/54/merge
parent
efbbcd3786
commit
a3c1a5eaa3
6 changed files with 33 additions and 35 deletions
@ -1,31 +0,0 @@ |
||||
#include<SDL.h> |
||||
|
||||
int main(int argc, char **argv) { |
||||
SDL_Window *window; |
||||
SDL_Surface *screenSurface; |
||||
SDL_Event e; |
||||
int keepGoing = 1; |
||||
if(SDL_Init( SDL_INIT_VIDEO ) < 0) { |
||||
printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() ); |
||||
} |
||||
|
||||
window = SDL_CreateWindow( "My application", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN ); |
||||
|
||||
screenSurface = SDL_GetWindowSurface( window ); |
||||
|
||||
while(keepGoing) { |
||||
while(SDL_PollEvent(&e) != 0) { |
||||
if(e.type == SDL_QUIT) { |
||||
keepGoing = 0; |
||||
break; |
||||
} |
||||
} |
||||
SDL_FillRect( screenSurface, NULL, SDL_MapRGB( screenSurface->format, 0xFF, 0x00, 0x00 ) );
|
||||
SDL_UpdateWindowSurface( window ); |
||||
SDL_Delay(100); |
||||
} |
||||
|
||||
SDL_DestroyWindow(window); |
||||
SDL_Quit(); |
||||
return 0; |
||||
} |
@ -0,0 +1,29 @@ |
||||
#include<SDL.h> |
||||
#include<memory> |
||||
|
||||
int main(int argc, char **argv) { |
||||
SDL_Surface *screenSurface; |
||||
SDL_Event e; |
||||
int keepGoing = 1; |
||||
if(SDL_Init( SDL_INIT_VIDEO ) < 0) { |
||||
printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() ); |
||||
} |
||||
atexit(SDL_Quit); |
||||
|
||||
std::unique_ptr<SDL_Window, void(*)(SDL_Window*)> window(SDL_CreateWindow( "My application", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN), SDL_DestroyWindow); |
||||
screenSurface = SDL_GetWindowSurface(window.get()); |
||||
|
||||
while(keepGoing) { |
||||
while(SDL_PollEvent(&e) != 0) { |
||||
if(e.type == SDL_QUIT) { |
||||
keepGoing = 0; |
||||
break; |
||||
} |
||||
} |
||||
SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF, 0x00, 0x00)); |
||||
SDL_UpdateWindowSurface(window.get()); |
||||
SDL_Delay(100); |
||||
} |
||||
|
||||
return 0; |
||||
} |
Loading…
Reference in new issue