Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Added code to make testshape switch shapes on keystrokes and exit on …
Browse files Browse the repository at this point in the history
…an ESC keystroke.
  • Loading branch information
Eli Gottlieb committed Jul 19, 2010
1 parent 60382ee commit 295886f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions test/testshape.c
Expand Up @@ -5,6 +5,7 @@
#include <SDL_pixels.h>
#include <SDL_video.h>
#include <SDL_shape.h>
#include <SDL_keysym.h>

#define SHAPED_WINDOW_X 150
#define SHAPED_WINDOW_Y 150
Expand Down Expand Up @@ -86,7 +87,7 @@ int main(int argc,char** argv) {
event_pending = SDL_PollEvent(&event);
unsigned int current_picture = 0;
SDL_WindowShapeMode mode = {ShapeModeDefault,1};
int mouse_down = 0;
int button_down = 0;
Uint32 format = 0,access = 0;
SDL_Rect texture_dimensions = {0,0,0,0};
SDL_QueryTexture(textures[current_picture],&format,&access,&texture_dimensions.w,&texture_dimensions.h);
Expand All @@ -95,10 +96,13 @@ int main(int argc,char** argv) {
while(should_exit == 0) {
event_pending = SDL_PollEvent(&event);
if(event_pending == 1) {
if(event.type == SDL_MOUSEBUTTONDOWN)
mouse_down = 1;
if(mouse_down && event.type == SDL_MOUSEBUTTONUP) {
mouse_down = 0;
if(event.type == SDL_KEYDOWN) {
button_down = 1;
if(event.key.keysym.sym == SDLK_ESCAPE)
should_exit = 1;
}
if(button_down && event.type == SDL_KEYUP) {
button_down = 0;
current_picture += 1;
if(current_picture >= num_pictures)
current_picture = 0;
Expand Down

0 comments on commit 295886f

Please sign in to comment.