- Moved setBasicRenderStates methods calls in shader based material renderers to the same place as in standard fixed pipeline material renderers (first lines of OnSetMaterial method).
- Fixed bug with texture states in OpenGL. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4561 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
5cfeba46c0
commit
e1675c83ce
|
@ -112,6 +112,8 @@ bool CD3D8ShaderMaterialRenderer::OnRender(IMaterialRendererServices* service, E
|
|||
void CD3D8ShaderMaterialRenderer::OnSetMaterial(const video::SMaterial& material, const video::SMaterial& lastMaterial,
|
||||
bool resetAllRenderstates, video::IMaterialRendererServices* services)
|
||||
{
|
||||
services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
|
||||
|
||||
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
|
||||
{
|
||||
if (VertexShader)
|
||||
|
@ -135,13 +137,10 @@ void CD3D8ShaderMaterialRenderer::OnSetMaterial(const video::SMaterial& material
|
|||
|
||||
if (BaseMaterial)
|
||||
BaseMaterial->OnSetMaterial(material, material, true, services);
|
||||
|
||||
if (CallBack)
|
||||
CallBack->OnSetMaterial(material);
|
||||
}
|
||||
|
||||
//let callback know used material
|
||||
if (CallBack)
|
||||
CallBack->OnSetMaterial(material);
|
||||
|
||||
services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
|
||||
}
|
||||
|
||||
void CD3D8ShaderMaterialRenderer::OnUnsetMaterial()
|
||||
|
|
|
@ -75,6 +75,8 @@ bool CD3D9CgMaterialRenderer::isTransparent() const
|
|||
|
||||
void CD3D9CgMaterialRenderer::OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates, IMaterialRendererServices* services)
|
||||
{
|
||||
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
|
||||
|
||||
Material = material;
|
||||
|
||||
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
|
||||
|
@ -85,17 +87,12 @@ void CD3D9CgMaterialRenderer::OnSetMaterial(const SMaterial& material, const SMa
|
|||
if (FragmentProgram)
|
||||
cgD3D9BindProgram(FragmentProgram);
|
||||
|
||||
/*if (GeometryProgram)
|
||||
cgD3D9BindProgram(GeometryProgram);*/
|
||||
|
||||
if (BaseMaterial)
|
||||
BaseMaterial->OnSetMaterial(material, material, true, this);
|
||||
|
||||
if (CallBack)
|
||||
CallBack->OnSetMaterial(material);
|
||||
}
|
||||
|
||||
if (CallBack)
|
||||
CallBack->OnSetMaterial(material);
|
||||
|
||||
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
|
||||
}
|
||||
|
||||
bool CD3D9CgMaterialRenderer::OnRender(IMaterialRendererServices* services, E_VERTEX_TYPE vtxtype)
|
||||
|
|
|
@ -112,6 +112,8 @@ bool CD3D9ShaderMaterialRenderer::OnRender(IMaterialRendererServices* service, E
|
|||
void CD3D9ShaderMaterialRenderer::OnSetMaterial(const video::SMaterial& material, const video::SMaterial& lastMaterial,
|
||||
bool resetAllRenderstates, video::IMaterialRendererServices* services)
|
||||
{
|
||||
services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
|
||||
|
||||
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
|
||||
{
|
||||
if (VertexShader)
|
||||
|
@ -133,13 +135,10 @@ void CD3D9ShaderMaterialRenderer::OnSetMaterial(const video::SMaterial& material
|
|||
|
||||
if (BaseMaterial)
|
||||
BaseMaterial->OnSetMaterial(material, material, true, services);
|
||||
|
||||
if (CallBack)
|
||||
CallBack->OnSetMaterial(material);
|
||||
}
|
||||
|
||||
//let callback know used material
|
||||
if (CallBack)
|
||||
CallBack->OnSetMaterial(material);
|
||||
|
||||
services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -93,6 +93,8 @@ void COpenGLCgMaterialRenderer::OnSetMaterial(const SMaterial& material, const S
|
|||
else
|
||||
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE);
|
||||
|
||||
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
|
||||
|
||||
Material = material;
|
||||
|
||||
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
|
||||
|
@ -121,8 +123,6 @@ void COpenGLCgMaterialRenderer::OnSetMaterial(const SMaterial& material, const S
|
|||
if (CallBack)
|
||||
CallBack->OnSetMaterial(material);
|
||||
}
|
||||
|
||||
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
|
||||
}
|
||||
|
||||
bool COpenGLCgMaterialRenderer::OnRender(IMaterialRendererServices* services, E_VERTEX_TYPE vtxtype)
|
||||
|
|
|
@ -2834,16 +2834,18 @@ GLint COpenGLDriver::getTextureWrapMode(const u8 clamp)
|
|||
}
|
||||
|
||||
|
||||
//! OpenGL version of setBasicRenderStates method.
|
||||
void COpenGLDriver::setOpenGLBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial,
|
||||
//! Can be called by an IMaterialRenderer to make its work easier.
|
||||
void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial,
|
||||
bool resetAllRenderStates)
|
||||
{
|
||||
// Fixed pipeline isn't important for shader based materials
|
||||
|
||||
if (resetAllRenderStates || FixedPipelineState == EOFPS_ENABLE || FixedPipelineState == EOFPS_DISABLE_TO_ENABLE)
|
||||
E_OPENGL_FIXED_PIPELINE_STATE tempState = FixedPipelineState;
|
||||
|
||||
if (resetAllRenderStates || tempState == EOFPS_ENABLE || tempState == EOFPS_DISABLE_TO_ENABLE)
|
||||
{
|
||||
// material colors
|
||||
if (resetAllRenderStates || FixedPipelineState == EOFPS_DISABLE_TO_ENABLE ||
|
||||
if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE ||
|
||||
lastmaterial.ColorMaterial != material.ColorMaterial)
|
||||
{
|
||||
switch (material.ColorMaterial)
|
||||
|
@ -2871,7 +2873,7 @@ void COpenGLDriver::setOpenGLBasicRenderStates(const SMaterial& material, const
|
|||
glEnable(GL_COLOR_MATERIAL);
|
||||
}
|
||||
|
||||
if (resetAllRenderStates || FixedPipelineState == EOFPS_DISABLE_TO_ENABLE ||
|
||||
if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE ||
|
||||
lastmaterial.AmbientColor != material.AmbientColor ||
|
||||
lastmaterial.DiffuseColor != material.DiffuseColor ||
|
||||
lastmaterial.EmissiveColor != material.EmissiveColor ||
|
||||
|
@ -2911,7 +2913,7 @@ void COpenGLDriver::setOpenGLBasicRenderStates(const SMaterial& material, const
|
|||
}
|
||||
}
|
||||
|
||||
if (resetAllRenderStates || FixedPipelineState == EOFPS_DISABLE_TO_ENABLE ||
|
||||
if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE ||
|
||||
lastmaterial.SpecularColor != material.SpecularColor ||
|
||||
lastmaterial.Shininess != material.Shininess ||
|
||||
lastmaterial.ColorMaterial != material.ColorMaterial)
|
||||
|
@ -2941,7 +2943,7 @@ void COpenGLDriver::setOpenGLBasicRenderStates(const SMaterial& material, const
|
|||
}
|
||||
|
||||
// shademode
|
||||
if (resetAllRenderStates || FixedPipelineState == EOFPS_DISABLE_TO_ENABLE ||
|
||||
if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE ||
|
||||
lastmaterial.GouraudShading != material.GouraudShading)
|
||||
{
|
||||
if (material.GouraudShading)
|
||||
|
@ -2951,7 +2953,7 @@ void COpenGLDriver::setOpenGLBasicRenderStates(const SMaterial& material, const
|
|||
}
|
||||
|
||||
// lighting
|
||||
if (resetAllRenderStates || FixedPipelineState == EOFPS_DISABLE_TO_ENABLE ||
|
||||
if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE ||
|
||||
lastmaterial.Lighting != material.Lighting)
|
||||
{
|
||||
if (material.Lighting)
|
||||
|
@ -2961,7 +2963,7 @@ void COpenGLDriver::setOpenGLBasicRenderStates(const SMaterial& material, const
|
|||
}
|
||||
|
||||
// fog
|
||||
if (resetAllRenderStates || FixedPipelineState == EOFPS_DISABLE_TO_ENABLE ||
|
||||
if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE ||
|
||||
lastmaterial.FogEnable != material.FogEnable)
|
||||
{
|
||||
if (material.FogEnable)
|
||||
|
@ -2971,7 +2973,7 @@ void COpenGLDriver::setOpenGLBasicRenderStates(const SMaterial& material, const
|
|||
}
|
||||
|
||||
// normalization
|
||||
if (resetAllRenderStates || FixedPipelineState == EOFPS_DISABLE_TO_ENABLE ||
|
||||
if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE ||
|
||||
lastmaterial.NormalizeNormals != material.NormalizeNormals)
|
||||
{
|
||||
if (material.NormalizeNormals)
|
||||
|
@ -2981,9 +2983,9 @@ void COpenGLDriver::setOpenGLBasicRenderStates(const SMaterial& material, const
|
|||
}
|
||||
|
||||
// Set fixed pipeline as active.
|
||||
FixedPipelineState = EOFPS_ENABLE;
|
||||
tempState = EOFPS_ENABLE;
|
||||
}
|
||||
else if (FixedPipelineState == EOFPS_ENABLE_TO_DISABLE)
|
||||
else if (tempState == EOFPS_ENABLE_TO_DISABLE)
|
||||
{
|
||||
glDisable(GL_COLOR_MATERIAL);
|
||||
glDisable(GL_LIGHTING);
|
||||
|
@ -2991,10 +2993,10 @@ void COpenGLDriver::setOpenGLBasicRenderStates(const SMaterial& material, const
|
|||
glDisable(GL_NORMALIZE);
|
||||
|
||||
// Set programmable pipeline as active.
|
||||
FixedPipelineState = EOFPS_DISABLE;
|
||||
tempState = EOFPS_DISABLE;
|
||||
}
|
||||
|
||||
// FixedPipelineState == EOFPS_DISABLE - driver doesn't calls functions related to fixed pipeline.
|
||||
// tempState == EOFPS_DISABLE - driver doesn't calls functions related to fixed pipeline.
|
||||
|
||||
// fillmode - fixed pipeline call, but it emulate GL_LINES behaviour in rendering, so it stay here.
|
||||
if (resetAllRenderStates || (lastmaterial.Wireframe != material.Wireframe) || (lastmaterial.PointCloud != material.PointCloud))
|
||||
|
@ -3270,8 +3272,10 @@ void COpenGLDriver::setOpenGLBasicRenderStates(const SMaterial& material, const
|
|||
}
|
||||
}
|
||||
|
||||
// be sure to leave in texture stage 0
|
||||
BridgeCalls->setActiveTexture(GL_TEXTURE0_ARB);
|
||||
setTextureRenderStates(material, resetAllRenderStates);
|
||||
|
||||
// set current fixed pipeline state
|
||||
FixedPipelineState = tempState;
|
||||
}
|
||||
|
||||
//! Compare in SMaterial doesn't check texture parameters, so we should call this on each OnRender call.
|
||||
|
@ -3417,6 +3421,9 @@ void COpenGLDriver::setTextureRenderStates(const SMaterial& material, bool reset
|
|||
|
||||
tmpTexture->getStatesCache().IsCached = true;
|
||||
}
|
||||
|
||||
// be sure to leave in texture stage 0
|
||||
BridgeCalls->setActiveTexture(GL_TEXTURE0_ARB);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -286,15 +286,7 @@ namespace video
|
|||
|
||||
//! Can be called by an IMaterialRenderer to make its work easier.
|
||||
virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial,
|
||||
bool resetAllRenderstates) _IRR_OVERRIDE_
|
||||
{
|
||||
setOpenGLBasicRenderStates(material, lastmaterial, resetAllRenderstates);
|
||||
setTextureRenderStates(material, resetAllRenderstates);
|
||||
}
|
||||
|
||||
//! OpenGL version of setBasicRenderStates method.
|
||||
void setOpenGLBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial,
|
||||
bool resetAllRenderstates);
|
||||
bool resetAllRenderstates) _IRR_OVERRIDE_;
|
||||
|
||||
//! Compare in SMaterial doesn't check texture parameters, so we should call this on each OnRender call.
|
||||
virtual void setTextureRenderStates(const SMaterial& material, bool resetAllRenderstates);
|
||||
|
|
|
@ -221,6 +221,8 @@ void COpenGLSLMaterialRenderer::OnSetMaterial(const video::SMaterial& material,
|
|||
else
|
||||
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE);
|
||||
|
||||
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
|
||||
|
||||
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
|
||||
{
|
||||
if (Program2)
|
||||
|
@ -234,8 +236,6 @@ void COpenGLSLMaterialRenderer::OnSetMaterial(const video::SMaterial& material,
|
|||
if (CallBack)
|
||||
CallBack->OnSetMaterial(material);
|
||||
}
|
||||
|
||||
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -138,6 +138,8 @@ void COpenGLShaderMaterialRenderer::OnSetMaterial(const video::SMaterial& materi
|
|||
else
|
||||
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE);
|
||||
|
||||
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
|
||||
|
||||
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
|
||||
{
|
||||
if (VertexShader)
|
||||
|
@ -184,8 +186,6 @@ void COpenGLShaderMaterialRenderer::OnSetMaterial(const video::SMaterial& materi
|
|||
if (CallBack)
|
||||
CallBack->OnSetMaterial(material);
|
||||
}
|
||||
|
||||
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue