Mercurial > sdl-ios-xcode
comparison test/testshape.c @ 4817:c68e7490e4cf
Fixed a couple of bugs in the general and X11 shape code, and fixed a bug in testshape that was keeping it from recognizing surfaces without alpha. Thanks to Andreas's bit-bashing tip, X11 shaped windows now work entirely, AFAICT.
author | Eli Gottlieb <eligottlieb@gmail.com> |
---|---|
date | Sun, 01 Aug 2010 21:10:42 -0400 |
parents | eb433f0d2ac5 |
children | 2e446923c9fb |
comparison
equal
deleted
inserted
replaced
4816:eb433f0d2ac5 | 4817:c68e7490e4cf |
---|---|
41 | 41 |
42 int main(int argc,char** argv) { | 42 int main(int argc,char** argv) { |
43 Uint8 num_pictures; | 43 Uint8 num_pictures; |
44 LoadedPicture* pictures; | 44 LoadedPicture* pictures; |
45 int i, j; | 45 int i, j; |
46 SDL_PixelFormat* format; | 46 SDL_PixelFormat* format = NULL; |
47 Uint32 format_enum; | 47 Uint32 format_enum; |
48 SDL_Window *window; | 48 SDL_Window *window; |
49 SDL_Color black = {0,0,0,0xff}; | 49 SDL_Color black = {0,0,0,0xff}; |
50 SDL_Event event; | 50 SDL_Event event; |
51 int event_pending = 0; | 51 int event_pending = 0; |
52 int should_exit = 0; | 52 int should_exit = 0; |
53 unsigned int current_picture; | 53 unsigned int current_picture; |
54 int button_down; | 54 int button_down; |
55 Uint32 pixelFormat; | 55 Uint32 pixelFormat = 0; |
56 int access; | 56 int access = 0; |
57 SDL_Rect texture_dimensions;; | 57 SDL_Rect texture_dimensions;; |
58 | 58 |
59 if(argc < 2) { | 59 if(argc < 2) { |
60 printf("SDL_Shape requires at least one bitmap file as argument.\n"); | 60 printf("SDL_Shape requires at least one bitmap file as argument.\n"); |
61 exit(-1); | 61 exit(-1); |
82 printf("Could not load surface from named bitmap file.\n"); | 82 printf("Could not load surface from named bitmap file.\n"); |
83 exit(-3); | 83 exit(-3); |
84 } | 84 } |
85 | 85 |
86 format = pictures[i].surface->format; | 86 format = pictures[i].surface->format; |
87 format_enum = SDL_MasksToPixelFormatEnum (format->BitsPerPixel,format->Rmask,format->Gmask, format->Bmask,format->Amask); | 87 if(format->Amask != 0) { |
88 if(SDL_ISPIXELFORMAT_ALPHA(format_enum)) { | |
89 pictures[i].mode.mode = ShapeModeBinarizeAlpha; | 88 pictures[i].mode.mode = ShapeModeBinarizeAlpha; |
90 pictures[i].mode.parameters.binarizationCutoff = 1; | 89 pictures[i].mode.parameters.binarizationCutoff = 1; |
91 } | 90 } |
92 else { | 91 else { |
93 pictures[i].mode.mode = ShapeModeColorKey; | 92 pictures[i].mode.mode = ShapeModeColorKey; |
137 event_pending = 0; | 136 event_pending = 0; |
138 should_exit = 0; | 137 should_exit = 0; |
139 event_pending = SDL_PollEvent(&event); | 138 event_pending = SDL_PollEvent(&event); |
140 current_picture = 0; | 139 current_picture = 0; |
141 button_down = 0; | 140 button_down = 0; |
142 format = 0,access = 0; | |
143 texture_dimensions.h = 0; | 141 texture_dimensions.h = 0; |
144 texture_dimensions.w = 0; | 142 texture_dimensions.w = 0; |
145 texture_dimensions.x = 0; | 143 texture_dimensions.x = 0; |
146 texture_dimensions.y = 0; | 144 texture_dimensions.y = 0; |
147 SDL_QueryTexture(pictures[current_picture].texture,(Uint32 *)&pixelFormat,(int *)&access,&texture_dimensions.w,&texture_dimensions.h); | 145 SDL_QueryTexture(pictures[current_picture].texture,(Uint32 *)&pixelFormat,(int *)&access,&texture_dimensions.w,&texture_dimensions.h); |