test/testgesture.c
changeset 6790 475f0a544157
parent 5535 96594ac5fd1a
child 6951 7833f01322b3
equal deleted inserted replaced
6789:7177d421bb07 6790:475f0a544157
    92   Uint8 r,g,b;
    92   Uint8 r,g,b;
    93   int x = (int)_x;
    93   int x = (int)_x;
    94   int y = (int)_y;
    94   int y = (int)_y;
    95   float a;
    95   float a;
    96   
    96   
    97   if(x < 0 || x > screen->w) return;
    97   if(x < 0 || x >= screen->w) return;
    98   if(y < 0 || y > screen->h) return;
    98   if(y < 0 || y >= screen->h) return;
    99 
    99 
   100   pixmem32 = (Uint32*) screen->pixels  + y*screen->pitch/BPP + x;
   100   pixmem32 = (Uint32*) screen->pixels  + y*screen->pitch/BPP + x;
   101   
   101   
   102   SDL_memcpy(&colour,pixmem32,screen->format->BytesPerPixel);
   102   SDL_memcpy(&colour,pixmem32,screen->format->BytesPerPixel);
   103 
   103 
   193 SDL_Surface* initScreen(int width,int height)
   193 SDL_Surface* initScreen(int width,int height)
   194 {
   194 {
   195   if (!window) {
   195   if (!window) {
   196     window = SDL_CreateWindow("Gesture Test",
   196     window = SDL_CreateWindow("Gesture Test",
   197                               SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
   197                               SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
   198                               WIDTH, HEIGHT, SDL_WINDOW_RESIZABLE);
   198                               width, height, SDL_WINDOW_RESIZABLE);
   199   }
   199   }
   200   if (!window) {
   200   if (!window) {
   201     return NULL;
   201     return NULL;
   202   }
   202   }
   203   return SDL_GetWindowSurface(window);
   203   return SDL_GetWindowSurface(window);
   255 		break;
   255 		break;
   256 	    }
   256 	    }
   257 	    break;
   257 	    break;
   258 	  case SDL_WINDOWEVENT:
   258 	  case SDL_WINDOWEVENT:
   259             if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
   259             if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
   260 	      if (!(screen = initScreen(0, 0)))
   260 	      if (!(screen = initScreen(event.window.data1, event.window.data2)))
   261 	      {
   261 	      {
   262 		SDL_Quit();
   262 		SDL_Quit();
   263 		return 1;
   263 		return 1;
   264 	      }
   264 	      }
   265             }
   265             }