Fix for transparent objects and fadeouts
parent
5a751d9c0d
commit
4193f8a3a9
|
@ -307,11 +307,6 @@ public:
|
|||
//! Sets only the texture wrap modes (for faster than thru stage params)
|
||||
virtual void SetTextureStageWrap(int index, TexWrapMode wrapS, TexWrapMode wrapT) = 0;
|
||||
|
||||
//! Sets the texture factor to the given color value
|
||||
virtual void SetTextureFactor(const Color &color) = 0;
|
||||
//! Returns the current texture factor
|
||||
virtual Color GetTextureFactor() = 0;
|
||||
|
||||
//! Renders primitive composed of vertices with single texture
|
||||
virtual void DrawPrimitive(PrimitiveType type, const Vertex *vertices , int vertexCount) = 0;
|
||||
//! Renders primitive composed of vertices with color information and single texture
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#include "graphics/core/color.h"
|
||||
|
||||
#include "math/intpoint.h"
|
||||
|
||||
|
||||
|
@ -175,6 +177,8 @@ struct TextureStageParams
|
|||
TexWrapMode wrapS;
|
||||
//! Wrap mode for 2nd tex coord
|
||||
TexWrapMode wrapT;
|
||||
//! Constant color factor (for TEX_MIX_ARG_FACTOR)
|
||||
Color factor;
|
||||
|
||||
//! Constructor; calls LoadDefault()
|
||||
TextureStageParams()
|
||||
|
|
|
@ -181,9 +181,6 @@ CEngine::CEngine(CInstanceManager *iMan, CApplication *app)
|
|||
|
||||
m_alphaMode = 1;
|
||||
|
||||
m_forceStateColor = true;
|
||||
m_stateColor = false;
|
||||
|
||||
m_updateGeometry = false;
|
||||
|
||||
m_interfaceMode = false;
|
||||
|
@ -1851,13 +1848,12 @@ void CEngine::SetState(int state, const Color& color)
|
|||
m_device->SetRenderState(RENDER_STATE_BLENDING, true);
|
||||
m_device->SetBlendFunc(BLEND_ONE, BLEND_INV_SRC_COLOR);
|
||||
|
||||
m_device->SetTextureFactor(color);
|
||||
|
||||
TextureStageParams params;
|
||||
params.colorOperation = TEX_MIX_OPER_MODULATE;
|
||||
params.colorArg1 = TEX_MIX_ARG_TEXTURE;
|
||||
params.colorArg2 = TEX_MIX_ARG_FACTOR;
|
||||
params.alphaOperation = TEX_MIX_OPER_DEFAULT; // TODO: replace with src color ?
|
||||
params.factor = color;
|
||||
|
||||
m_device->SetTextureEnabled(0, true);
|
||||
m_device->SetTextureStageParams(0, params);
|
||||
|
@ -1871,13 +1867,12 @@ void CEngine::SetState(int state, const Color& color)
|
|||
m_device->SetRenderState(RENDER_STATE_BLENDING, true);
|
||||
m_device->SetBlendFunc(BLEND_DST_COLOR, BLEND_ZERO);
|
||||
|
||||
m_device->SetTextureFactor(color.Inverse());
|
||||
|
||||
TextureStageParams params;
|
||||
params.colorOperation = TEX_MIX_OPER_ADD;
|
||||
params.colorArg1 = TEX_MIX_ARG_TEXTURE;
|
||||
params.colorArg2 = TEX_MIX_ARG_FACTOR;
|
||||
params.alphaOperation = TEX_MIX_OPER_DEFAULT; // TODO: replace with src color ?
|
||||
params.factor = color.Inverse();
|
||||
|
||||
m_device->SetTextureEnabled(0, true);
|
||||
m_device->SetTextureStageParams(0, params);
|
||||
|
@ -1963,14 +1958,13 @@ void CEngine::SetState(int state, const Color& color)
|
|||
|
||||
m_device->SetAlphaTestFunc(COMP_FUNC_GREATER, 0.5f);
|
||||
|
||||
m_device->SetTextureFactor(color);
|
||||
|
||||
TextureStageParams params;
|
||||
params.colorOperation = TEX_MIX_OPER_MODULATE;
|
||||
params.colorArg1 = TEX_MIX_ARG_TEXTURE;
|
||||
params.colorArg2 = TEX_MIX_ARG_SRC_COLOR;
|
||||
params.alphaOperation = TEX_MIX_OPER_REPLACE;
|
||||
params.alphaArg1 = TEX_MIX_ARG_TEXTURE;
|
||||
params.factor = color;
|
||||
|
||||
m_device->SetTextureEnabled(0, true);
|
||||
m_device->SetTextureStageParams(0, params);
|
||||
|
@ -2348,11 +2342,6 @@ bool CEngine::GetFog()
|
|||
return m_fog;
|
||||
}
|
||||
|
||||
bool CEngine::GetStateColor()
|
||||
{
|
||||
return m_stateColor;
|
||||
}
|
||||
|
||||
void CEngine::SetSecondTexture(int texNum)
|
||||
{
|
||||
m_secondTexNum = texNum;
|
||||
|
@ -2964,18 +2953,8 @@ void CEngine::Draw3DScene()
|
|||
|
||||
if (transparent)
|
||||
{
|
||||
int tState = 0;
|
||||
Color tColor;
|
||||
if (m_stateColor)
|
||||
{
|
||||
tState = ENG_RSTATE_TTEXTURE_BLACK | ENG_RSTATE_2FACE;
|
||||
tColor = Color(68.0f / 255.0f, 68.0f / 255.0f, 68.0f / 255.0f, 68.0f / 255.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
tState = ENG_RSTATE_TCOLOR_BLACK;
|
||||
tColor = Color(136.0f / 255.0f, 136.0f / 255.0f, 136.0f / 255.0f, 136.0f / 255.0f);
|
||||
}
|
||||
int tState = ENG_RSTATE_TTEXTURE_BLACK | ENG_RSTATE_2FACE;
|
||||
Color tColor = Color(68.0f / 255.0f, 68.0f / 255.0f, 68.0f / 255.0f, 68.0f / 255.0f);
|
||||
|
||||
for (int l1 = 0; l1 < static_cast<int>( m_objectTree.size() ); l1++)
|
||||
{
|
||||
|
@ -3551,8 +3530,6 @@ void CEngine::DrawForegroundImage()
|
|||
// Status: PART_TESTED
|
||||
void CEngine::DrawOverColor()
|
||||
{
|
||||
if (! m_stateColor) return;
|
||||
|
||||
// TODO: fuzzy compare?
|
||||
if ( (m_overColor == Color(0.0f, 0.0f, 0.0f, 0.0f) && m_overMode == ENG_RSTATE_TCOLOR_BLACK) ||
|
||||
(m_overColor == Color(1.0f, 1.0f, 1.0f, 1.0f) && m_overMode == ENG_RSTATE_TCOLOR_WHITE) ) return;
|
||||
|
|
|
@ -1291,8 +1291,6 @@ protected:
|
|||
int m_statisticTriangle;
|
||||
bool m_updateGeometry;
|
||||
int m_alphaMode;
|
||||
bool m_stateColor;
|
||||
bool m_forceStateColor;
|
||||
bool m_groundSpotVisible;
|
||||
bool m_shadowVisible;
|
||||
bool m_dirty;
|
||||
|
|
|
@ -684,6 +684,8 @@ void CGLDevice::SetTextureStageParams(int index, const TextureStageParams ¶m
|
|||
|
||||
glActiveTexture(GL_TEXTURE0 + index);
|
||||
|
||||
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, params.factor.Array());
|
||||
|
||||
// To save some trouble
|
||||
if ( (params.colorOperation == TEX_MIX_OPER_DEFAULT) &&
|
||||
(params.alphaOperation == TEX_MIX_OPER_DEFAULT) )
|
||||
|
@ -836,27 +838,6 @@ TextureStageParams CGLDevice::GetTextureStageParams(int index)
|
|||
return m_textureStageParams[index];
|
||||
}
|
||||
|
||||
void CGLDevice::SetTextureFactor(const Color &color)
|
||||
{
|
||||
// Needs to be set for all texture stages
|
||||
for (int index = 0; index < static_cast<int>( m_currentTextures.size() ); ++index)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + index);
|
||||
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color.Array());
|
||||
}
|
||||
}
|
||||
|
||||
Color CGLDevice::GetTextureFactor()
|
||||
{
|
||||
// Get from 1st stage (should be the same for all stages)
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
GLfloat color[4] = { 0.0f };
|
||||
glGetTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);
|
||||
|
||||
return Color(color[0], color[1], color[2], color[3]);
|
||||
}
|
||||
|
||||
GLenum TranslateGfxPrimitive(PrimitiveType type)
|
||||
{
|
||||
GLenum flag = 0;
|
||||
|
|
|
@ -119,9 +119,6 @@ public:
|
|||
|
||||
virtual void SetTextureStageWrap(int index, Gfx::TexWrapMode wrapS, Gfx::TexWrapMode wrapT);
|
||||
|
||||
virtual void SetTextureFactor(const Color &color);
|
||||
virtual Color GetTextureFactor();
|
||||
|
||||
virtual void DrawPrimitive(PrimitiveType type, const Vertex *vertices, int vertexCount);
|
||||
virtual void DrawPrimitive(PrimitiveType type, const VertexCol *vertices, int vertexCount);
|
||||
virtual void DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, int vertexCount);
|
||||
|
|
Loading…
Reference in New Issue