test/testeyes.c
changeset 4798 980614a70cfc
parent 4795 6f0bc179771c
equal deleted inserted replaced
4797:2a71f02323c7 4798:980614a70cfc
   128 	if(SDL_VideoInit(NULL,0) == -1) {
   128 	if(SDL_VideoInit(NULL,0) == -1) {
   129 		printf("Could not initialize SDL video.\n");
   129 		printf("Could not initialize SDL video.\n");
   130 		exit(-1);
   130 		exit(-1);
   131 	}
   131 	}
   132 	
   132 	
   133 	SDL_Window *window = SDL_CreateShapedWindow("Big Brother is watching you.",eyes_x_hot,eyes_y_hot,eyes_width,eyes_height,SDL_WINDOW_RESIZABLE);
   133 	SDL_Window *window = SDL_CreateShapedWindow("Big Brother is watching you.",eyes_x_hot,eyes_y_hot,eyes_width,eyes_height,SDL_WINDOW_RESIZABLE | SDL_WINDOW_SHOWN);
   134 	if(window == NULL) {
   134 	if(window == NULL) {
   135 		SDL_VideoQuit();
   135 		SDL_VideoQuit();
   136 		printf("Could not create shaped window for eyes.\n");
   136 		printf("Could not create shaped window for eyes.\n");
   137 		exit(-2);
   137 		exit(-2);
   138 	}
   138 	}
   167 			Uint8 brightness = *(Uint8*)(eyes_bits+(eyes_width/8)*y+(x/8)) & (1 << (7 - x % 8)) ? 255 : 0;
   167 			Uint8 brightness = *(Uint8*)(eyes_bits+(eyes_width/8)*y+(x/8)) & (1 << (7 - x % 8)) ? 255 : 0;
   168 			*(Uint16*)(pixels+pitch*y+x*16/8) = SDL_MapRGBA(eyes->format,brightness,brightness,brightness,255);
   168 			*(Uint16*)(pixels+pitch*y+x*16/8) = SDL_MapRGBA(eyes->format,brightness,brightness,brightness,255);
   169 		}
   169 		}
   170 	if(SDL_MUSTLOCK(eyes))
   170 	if(SDL_MUSTLOCK(eyes))
   171 		SDL_UnlockSurface(eyes);
   171 		SDL_UnlockSurface(eyes);
   172 	SDL_Texture *eyes_texture = SDL_CreateTextureFromSurface(SDL_PIXELFORMAT_ARGB4444,eyes);
   172 	SDL_Texture *eyes_texture = SDL_CreateTextureFromSurface(0,eyes);
   173 	if(eyes_texture == NULL) {
   173 	if(eyes_texture == NULL) {
   174 		SDL_FreeSurface(eyes);
   174 		SDL_FreeSurface(eyes);
   175 		SDL_DestroyRenderer(window);
   175 		SDL_DestroyRenderer(window);
   176 		SDL_DestroyWindow(window);
   176 		SDL_DestroyWindow(window);
   177 		SDL_VideoQuit();
   177 		SDL_VideoQuit();