summaryrefslogtreecommitdiffstats
path: root/src/graphics
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2012-07-25 20:27:13 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2012-07-25 20:27:13 +0200
commitbc1c9b5284c10d8aafc04bcd6c3597b3626a782f (patch)
tree88f432699953fba513dc78155252ce20f83d5b05 /src/graphics
parent9cd28e26e90ecbce239991e054293f748895fb98 (diff)
downloadcolobot-bc1c9b5284c10d8aafc04bcd6c3597b3626a782f.tar.gz
colobot-bc1c9b5284c10d8aafc04bcd6c3597b3626a782f.tar.bz2
colobot-bc1c9b5284c10d8aafc04bcd6c3597b3626a782f.zip
Fixed bug in texturing
Diffstat (limited to 'src/graphics')
-rw-r--r--src/graphics/opengl/gldevice.cpp20
-rw-r--r--src/graphics/opengl/test/CMakeLists.txt3
-rw-r--r--src/graphics/opengl/test/texture_test.cpp10
3 files changed, 20 insertions, 13 deletions
diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp
index a3668da..fc6e9b6 100644
--- a/src/graphics/opengl/gldevice.cpp
+++ b/src/graphics/opengl/gldevice.cpp
@@ -516,19 +516,19 @@ void Gfx::CGLDevice::SetTextureStageParams(int index, const Gfx::TextureStagePar
if (params.colorOperation == Gfx::TEX_MIX_OPER_DEFAULT)
{
+ glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_TEXTURE);
- glTexEnvi(GL_TEXTURE_2D, GL_COMBINE_RGB, GL_MODULATE);
goto after_tex_color;
}
else if (params.colorOperation == Gfx::TEX_MIX_OPER_REPLACE)
- glTexEnvi(GL_TEXTURE_2D, GL_COMBINE_RGB, GL_REPLACE);
+ glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE);
else if (params.colorOperation == Gfx::TEX_MIX_OPER_MODULATE)
- glTexEnvi(GL_TEXTURE_2D, GL_COMBINE_RGB, GL_MODULATE);
+ glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
else if (params.colorOperation == Gfx::TEX_MIX_OPER_ADD)
- glTexEnvi(GL_TEXTURE_2D, GL_COMBINE_RGB, GL_ADD);
+ glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_ADD);
else if (params.colorOperation == Gfx::TEX_MIX_OPER_SUBTRACT)
- glTexEnvi(GL_TEXTURE_2D, GL_COMBINE_RGB, GL_SUBTRACT);
+ glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_SUBTRACT);
else assert(false);
// Color arg1
@@ -559,19 +559,19 @@ after_tex_color:
// Alpha operation
if (params.alphaOperation == Gfx::TEX_MIX_OPER_DEFAULT)
{
- glTexEnvi(GL_TEXTURE_2D, GL_COMBINE_ALPHA, GL_MODULATE);
+ glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_TEXTURE);
goto after_tex_operations;
}
else if (params.colorOperation == Gfx::TEX_MIX_OPER_REPLACE)
- glTexEnvi(GL_TEXTURE_2D, GL_COMBINE_ALPHA, GL_REPLACE);
+ glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
else if (params.alphaOperation == Gfx::TEX_MIX_OPER_MODULATE)
- glTexEnvi(GL_TEXTURE_2D, GL_COMBINE_ALPHA, GL_MODULATE);
+ glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
else if (params.alphaOperation == Gfx::TEX_MIX_OPER_ADD)
- glTexEnvi(GL_TEXTURE_2D, GL_COMBINE_ALPHA, GL_ADD);
+ glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_ADD);
else if (params.alphaOperation == Gfx::TEX_MIX_OPER_SUBTRACT)
- glTexEnvi(GL_TEXTURE_2D, GL_COMBINE_ALPHA, GL_SUBTRACT);
+ glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_SUBTRACT);
else assert(false);
// Alpha arg1
diff --git a/src/graphics/opengl/test/CMakeLists.txt b/src/graphics/opengl/test/CMakeLists.txt
index 58c4714..f49fbac 100644
--- a/src/graphics/opengl/test/CMakeLists.txt
+++ b/src/graphics/opengl/test/CMakeLists.txt
@@ -30,7 +30,6 @@ configure_file(../../../common/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/common
set(TEXTURE_SOURCES
../gldevice.cpp
-../../common/device.cpp
../../../common/logger.cpp
../../../common/image.cpp
texture_test.cpp
@@ -38,7 +37,6 @@ texture_test.cpp
set(MODEL_SOURCES
../gldevice.cpp
-../../common/device.cpp
../../common/modelfile.cpp
../../../common/logger.cpp
../../../common/image.cpp
@@ -50,7 +48,6 @@ model_test.cpp
set(TRANSFORM_SOURCES
../gldevice.cpp
-../../common/device.cpp
../../../common/logger.cpp
../../../common/image.cpp
../../../common/iman.cpp
diff --git a/src/graphics/opengl/test/texture_test.cpp b/src/graphics/opengl/test/texture_test.cpp
index aa9817e..c3c568b 100644
--- a/src/graphics/opengl/test/texture_test.cpp
+++ b/src/graphics/opengl/test/texture_test.cpp
@@ -108,6 +108,16 @@ void Render(Gfx::CGLDevice *device)
device->SetTextureEnabled(0, true);
device->SetTextureEnabled(1, true);
+ tex1StageParams.colorOperation = Gfx::TEX_MIX_OPER_DEFAULT;
+ tex1StageParams.alphaOperation = Gfx::TEX_MIX_OPER_DEFAULT;
+ device->SetTextureStageParams(0, tex1StageParams);
+
+ tex2StageParams.colorOperation = Gfx::TEX_MIX_OPER_ADD;
+ tex2StageParams.colorArg1 = Gfx::TEX_MIX_ARG_COMPUTED_COLOR;
+ tex2StageParams.colorArg2 = Gfx::TEX_MIX_ARG_TEXTURE;
+ tex2StageParams.alphaOperation = Gfx::TEX_MIX_OPER_DEFAULT;
+ device->SetTextureStageParams(1, tex2StageParams);
+
device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLES, quad, 6);
device->EndScene();