Fix the detection of alpha-channel in textures as created by IMG_Load

This fixes the textures loading under Mac OS X
dev-ui
Didier 'OdyX' Raboud 2013-10-28 15:18:45 +01:00 committed by Didier Raboud
parent 19a7196b61
commit 9e439d88bf
1 changed files with 6 additions and 2 deletions

View File

@ -606,7 +606,7 @@ Texture CGLDevice::CreateTexture(ImageData *data, const TextureCreateParams &par
} }
else if (params.format == TEX_IMG_AUTO) else if (params.format == TEX_IMG_AUTO)
{ {
if (data->surface->format->Amask != 0) if (data->surface->format->BytesPerPixel == 4)
{ {
if ((data->surface->format->Amask == 0xFF000000) && if ((data->surface->format->Amask == 0xFF000000) &&
(data->surface->format->Rmask == 0x00FF0000) && (data->surface->format->Rmask == 0x00FF0000) &&
@ -630,7 +630,7 @@ Texture CGLDevice::CreateTexture(ImageData *data, const TextureCreateParams &par
convert = true; convert = true;
} }
} }
else else if (data->surface->format->BytesPerPixel == 3)
{ {
if ((data->surface->format->Rmask == 0xFF0000) && if ((data->surface->format->Rmask == 0xFF0000) &&
(data->surface->format->Gmask == 0x00FF00) && (data->surface->format->Gmask == 0x00FF00) &&
@ -652,6 +652,10 @@ Texture CGLDevice::CreateTexture(ImageData *data, const TextureCreateParams &par
convert = true; convert = true;
} }
} }
else {
GetLogger()->Error("Unknown data surface format");
assert(false);
}
} }
else else
assert(false); assert(false);