Fixed bug in texturing
parent
9cd28e26e9
commit
bc1c9b5284
|
@ -516,19 +516,19 @@ void Gfx::CGLDevice::SetTextureStageParams(int index, const Gfx::TextureStagePar
|
||||||
|
|
||||||
if (params.colorOperation == Gfx::TEX_MIX_OPER_DEFAULT)
|
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_SOURCE0_RGB, GL_PREVIOUS);
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_TEXTURE);
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_TEXTURE);
|
||||||
glTexEnvi(GL_TEXTURE_2D, GL_COMBINE_RGB, GL_MODULATE);
|
|
||||||
goto after_tex_color;
|
goto after_tex_color;
|
||||||
}
|
}
|
||||||
else if (params.colorOperation == Gfx::TEX_MIX_OPER_REPLACE)
|
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)
|
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)
|
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)
|
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);
|
else assert(false);
|
||||||
|
|
||||||
// Color arg1
|
// Color arg1
|
||||||
|
@ -559,19 +559,19 @@ after_tex_color:
|
||||||
// Alpha operation
|
// Alpha operation
|
||||||
if (params.alphaOperation == Gfx::TEX_MIX_OPER_DEFAULT)
|
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_SOURCE0_ALPHA, GL_PREVIOUS);
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_TEXTURE);
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_TEXTURE);
|
||||||
goto after_tex_operations;
|
goto after_tex_operations;
|
||||||
}
|
}
|
||||||
else if (params.colorOperation == Gfx::TEX_MIX_OPER_REPLACE)
|
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)
|
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)
|
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)
|
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);
|
else assert(false);
|
||||||
|
|
||||||
// Alpha arg1
|
// Alpha arg1
|
||||||
|
|
|
@ -30,7 +30,6 @@ configure_file(../../../common/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/common
|
||||||
|
|
||||||
set(TEXTURE_SOURCES
|
set(TEXTURE_SOURCES
|
||||||
../gldevice.cpp
|
../gldevice.cpp
|
||||||
../../common/device.cpp
|
|
||||||
../../../common/logger.cpp
|
../../../common/logger.cpp
|
||||||
../../../common/image.cpp
|
../../../common/image.cpp
|
||||||
texture_test.cpp
|
texture_test.cpp
|
||||||
|
@ -38,7 +37,6 @@ texture_test.cpp
|
||||||
|
|
||||||
set(MODEL_SOURCES
|
set(MODEL_SOURCES
|
||||||
../gldevice.cpp
|
../gldevice.cpp
|
||||||
../../common/device.cpp
|
|
||||||
../../common/modelfile.cpp
|
../../common/modelfile.cpp
|
||||||
../../../common/logger.cpp
|
../../../common/logger.cpp
|
||||||
../../../common/image.cpp
|
../../../common/image.cpp
|
||||||
|
@ -50,7 +48,6 @@ model_test.cpp
|
||||||
|
|
||||||
set(TRANSFORM_SOURCES
|
set(TRANSFORM_SOURCES
|
||||||
../gldevice.cpp
|
../gldevice.cpp
|
||||||
../../common/device.cpp
|
|
||||||
../../../common/logger.cpp
|
../../../common/logger.cpp
|
||||||
../../../common/image.cpp
|
../../../common/image.cpp
|
||||||
../../../common/iman.cpp
|
../../../common/iman.cpp
|
||||||
|
|
|
@ -108,6 +108,16 @@ void Render(Gfx::CGLDevice *device)
|
||||||
device->SetTextureEnabled(0, true);
|
device->SetTextureEnabled(0, true);
|
||||||
device->SetTextureEnabled(1, 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->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLES, quad, 6);
|
||||||
|
|
||||||
device->EndScene();
|
device->EndScene();
|
||||||
|
|
Loading…
Reference in New Issue