Merge pull request #243 from OdyX/dev-fix-textures-loading

Fix the detection of alpha-channel in textures as created by IMG_Load
dev-ui
Piotr Dziwiński 2013-10-28 10:11:54 -07:00
commit 75871cc9ca
2 changed files with 7 additions and 3 deletions

View File

@ -276,7 +276,7 @@ bool CEngine::Create()
Math::LoadOrthoProjectionMatrix(m_matProjInterface, 0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f);
TextureCreateParams params;
params.format = TEX_IMG_RGB;
params.format = TEX_IMG_AUTO;
params.minFilter = TEX_MIN_FILTER_NEAREST;
params.magFilter = TEX_MAG_FILTER_NEAREST;
params.mipmap = false;

View File

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