summaryrefslogtreecommitdiffstats
path: root/src/graphics/opengl/gldevice.cpp
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2012-09-09 12:56:09 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2012-09-09 12:56:09 +0200
commitc6673b9aee483cfa64b49395c5c96b023bb09549 (patch)
tree5a469b1ce32a149b28c327cff38ba43b6d984b75 /src/graphics/opengl/gldevice.cpp
parentc2c1294ec99e3dae593bb31d2f331738d5be91d5 (diff)
downloadcolobot-c6673b9aee483cfa64b49395c5c96b023bb09549.tar.gz
colobot-c6673b9aee483cfa64b49395c5c96b023bb09549.tar.bz2
colobot-c6673b9aee483cfa64b49395c5c96b023bb09549.zip
Texture format detection; minor fixes
- detection of texture format - fixed depth mask bug - minor refactoring
Diffstat (limited to 'src/graphics/opengl/gldevice.cpp')
-rw-r--r--src/graphics/opengl/gldevice.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp
index 7221421..a779a5f 100644
--- a/src/graphics/opengl/gldevice.cpp
+++ b/src/graphics/opengl/gldevice.cpp
@@ -187,6 +187,7 @@ void Gfx::CGLDevice::EndScene()
void Gfx::CGLDevice::Clear()
{
+ glDepthMask(GL_TRUE);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
@@ -454,6 +455,55 @@ Gfx::Texture Gfx::CGLDevice::CreateTexture(ImageData *data, const Gfx::TextureCr
sourceFormat = GL_BGRA;
result.alpha = true;
}
+ else if (params.format == Gfx::TEX_IMG_AUTO)
+ {
+ if (data->surface->format->Amask != 0)
+ {
+ if ((data->surface->format->Rmask == 0xFF000000) &&
+ (data->surface->format->Gmask == 0x00FF0000) &&
+ (data->surface->format->Bmask == 0x0000FF00) &&
+ (data->surface->format->Amask == 0x000000FF))
+ {
+ sourceFormat = GL_BGRA;
+ result.alpha = true;
+ }
+ else if ((data->surface->format->Bmask == 0xFF000000) &&
+ (data->surface->format->Gmask == 0x00FF0000) &&
+ (data->surface->format->Rmask == 0x0000FF00) &&
+ (data->surface->format->Amask == 0x000000FF))
+ {
+ sourceFormat = GL_RGBA;
+ result.alpha = true;
+ }
+ else
+ {
+ GetLogger()->Error("Auto texture format failed\n");
+ return Gfx::Texture(); // other format?
+ }
+ }
+ else
+ {
+ if ((data->surface->format->Rmask == 0xFF0000) &&
+ (data->surface->format->Gmask == 0x00FF00) &&
+ (data->surface->format->Bmask == 0x0000FF))
+ {
+ sourceFormat = GL_BGR;
+ result.alpha = false;
+ }
+ else if ((data->surface->format->Bmask == 0xFF0000) &&
+ (data->surface->format->Gmask == 0x00FF00) &&
+ (data->surface->format->Rmask == 0x0000FF))
+ {
+ sourceFormat = GL_RGB;
+ result.alpha = false;
+ }
+ else
+ {
+ GetLogger()->Error("Auto texture format failed\n");
+ return Gfx::Texture(); // other format?
+ }
+ }
+ }
else
assert(false);