| 255 | } |
| 256 | |
| 257 | SDL_Surface *fixsurfaceformat(SDL_Surface *s) |
| 258 | { |
| 259 | if(!s) return NULL; |
| 260 | if(!s->pixels || min(s->w, s->h) <= 0 || s->format->BytesPerPixel <= 0) |
| 261 | { |
| 262 | SDL_FreeSurface(s); |
| 263 | return NULL; |
| 264 | } |
| 265 | static const uint rgbmasks[] = { RGBMASKS }, rgbamasks[] = { RGBAMASKS }; |
| 266 | switch(s->format->BytesPerPixel) |
| 267 | { |
| 268 | case 1: |
| 269 | if(!checkgrayscale(s)) |
| 270 | { |
| 271 | Uint32 ck; |
| 272 | SDL_GetColorKey(s, &ck); |
| 273 | return ck ? forcergbasurface(s) : forcergbsurface(s); |
| 274 | } |
| 275 | break; |
| 276 | case 3: |
| 277 | if(s->format->Rmask != rgbmasks[0] || s->format->Gmask != rgbmasks[1] || s->format->Bmask != rgbmasks[2]) |
| 278 | return forcergbsurface(s); |
| 279 | break; |
| 280 | case 4: |
| 281 | if(s->format->Rmask != rgbamasks[0] || s->format->Gmask != rgbamasks[1] || s->format->Bmask != rgbamasks[2] || s->format->Amask != rgbamasks[3]) |
| 282 | return s->format->Amask ? forcergbasurface(s) : forcergbsurface(s); |
| 283 | break; |
| 284 | } |
| 285 | return s; |
| 286 | } |
| 287 | |
| 288 | GLenum texformat(int bpp) |
| 289 | { |
no test coverage detected