Merge r4559 from trunk:

Improved switch between fixed and programmable pipeline materials.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@4641 dfc29bdd-3216-0410-991c-e03cc46cb475
master
cutealien 2014-01-07 23:06:31 +00:00
parent d10d3799ea
commit dc91c57ddf
6 changed files with 181 additions and 51 deletions

View File

@ -70,6 +70,11 @@ COpenGLCgMaterialRenderer::~COpenGLCgMaterialRenderer()
void COpenGLCgMaterialRenderer::OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates, IMaterialRendererServices* services)
{
if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_ENABLE)
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE_TO_DISABLE);
else
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE);
Material = material;
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
@ -93,18 +98,18 @@ void COpenGLCgMaterialRenderer::OnSetMaterial(const SMaterial& material, const S
}
if (BaseMaterial)
BaseMaterial->OnSetMaterial(material, material, true, this);
}
BaseMaterial->OnSetBaseMaterial(material);
if (CallBack)
CallBack->OnSetMaterial(material);
if (CallBack)
CallBack->OnSetMaterial(material);
}
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
}
bool COpenGLCgMaterialRenderer::OnRender(IMaterialRendererServices* services, E_VERTEX_TYPE vtxtype)
{
Driver->setTextureRenderStates(Driver->getCurrentMaterial(), false, false);
Driver->setTextureRenderStates(Driver->getCurrentMaterial(), false);
if (CallBack && (VertexProgram || FragmentProgram || GeometryProgram))
CallBack->OnSetConstants(this, UserData);

View File

@ -52,6 +52,7 @@ COpenGLDriver::COpenGLDriver(const ::irr::SIrrlichtCreationParameters& params,
CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true),
AntiAlias(params.AntiAlias), RenderTargetTexture(0),
CurrentRendertargetSize(0,0), ColorFormat(ECF_R8G8B8),
FixedPipelineState(EOFPS_ENABLE),
CurrentTarget(ERT_FRAME_BUFFER), Params(params), BridgeCalls(0),
ContextManager(contextManager), DeviceType(EIDT_WIN32)
{
@ -91,6 +92,7 @@ COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params,
CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true),
AntiAlias(params.AntiAlias), RenderTargetTexture(0),
CurrentRendertargetSize(0,0), ColorFormat(ECF_R8G8B8),
FixedPipelineState(EOFPS_ENABLE),
CurrentTarget(ERT_FRAME_BUFFER), Params(params), BridgeCalls(0),
OSXDevice(device), DeviceType(EIDT_OSX)
{
@ -118,7 +120,8 @@ COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params,
BridgeCalls(0), CurrentRenderMode(ERM_NONE), ResetRenderStates(true),
Transformation3DChanged(true), AntiAlias(params.AntiAlias),
RenderTargetTexture(0), CurrentRendertargetSize(0,0),
ColorFormat(ECF_R8G8B8), CurrentTarget(ERT_FRAME_BUFFER), Params(params),
ColorFormat(ECF_R8G8B8), FixedPipelineState(EOFPS_ENABLE),
CurrentTarget(ERT_FRAME_BUFFER), Params(params),
X11Device(device), DeviceType(EIDT_X11)
{
#ifdef _DEBUG
@ -211,7 +214,8 @@ COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params,
CurrentRenderMode(ERM_NONE), ResetRenderStates(true),
Transformation3DChanged(true), AntiAlias(params.AntiAlias),
RenderTargetTexture(0), CurrentRendertargetSize(0,0),
ColorFormat(ECF_R8G8B8), CurrentTarget(ERT_FRAME_BUFFER), Params(params),
ColorFormat(ECF_R8G8B8), FixedPipelineState(EOFPS_ENABLE),
CurrentTarget(ERT_FRAME_BUFFER), Params(params),
BridgeCalls(0), SDLDevice(device), DeviceType(EIDT_SDL)
{
#ifdef _DEBUG
@ -2453,16 +2457,16 @@ GLint COpenGLDriver::getTextureWrapMode(const u8 clamp)
}
//! Can be called by an IMaterialRenderer to make its work easier.
void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial,
bool resetAllRenderStates, bool fixedPipeline)
//! OpenGL version of setBasicRenderStates method.
void COpenGLDriver::setOpenGLBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial,
bool resetAllRenderStates)
{
// Fixed pipeline isn't important for shader based materials
if(fixedPipeline || resetAllRenderStates)
if (resetAllRenderStates || FixedPipelineState == EOFPS_ENABLE || FixedPipelineState == EOFPS_DISABLE_TO_ENABLE)
{
// material colors
if (resetAllRenderStates ||
if (resetAllRenderStates || FixedPipelineState == EOFPS_DISABLE_TO_ENABLE ||
lastmaterial.ColorMaterial != material.ColorMaterial)
{
switch (material.ColorMaterial)
@ -2490,7 +2494,7 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
glEnable(GL_COLOR_MATERIAL);
}
if (resetAllRenderStates ||
if (resetAllRenderStates || FixedPipelineState == EOFPS_DISABLE_TO_ENABLE ||
lastmaterial.AmbientColor != material.AmbientColor ||
lastmaterial.DiffuseColor != material.DiffuseColor ||
lastmaterial.EmissiveColor != material.EmissiveColor ||
@ -2530,7 +2534,7 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
}
}
if (resetAllRenderStates ||
if (resetAllRenderStates || FixedPipelineState == EOFPS_DISABLE_TO_ENABLE ||
lastmaterial.SpecularColor != material.SpecularColor ||
lastmaterial.Shininess != material.Shininess ||
lastmaterial.ColorMaterial != material.ColorMaterial)
@ -2560,7 +2564,8 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
}
// shademode
if (resetAllRenderStates || (lastmaterial.GouraudShading != material.GouraudShading))
if (resetAllRenderStates || FixedPipelineState == EOFPS_DISABLE_TO_ENABLE ||
lastmaterial.GouraudShading != material.GouraudShading)
{
if (material.GouraudShading)
glShadeModel(GL_SMOOTH);
@ -2569,7 +2574,8 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
}
// lighting
if (resetAllRenderStates || (lastmaterial.Lighting != material.Lighting))
if (resetAllRenderStates || FixedPipelineState == EOFPS_DISABLE_TO_ENABLE ||
lastmaterial.Lighting != material.Lighting)
{
if (material.Lighting)
glEnable(GL_LIGHTING);
@ -2578,7 +2584,8 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
}
// fog
if (resetAllRenderStates || lastmaterial.FogEnable != material.FogEnable)
if (resetAllRenderStates || FixedPipelineState == EOFPS_DISABLE_TO_ENABLE ||
lastmaterial.FogEnable != material.FogEnable)
{
if (material.FogEnable)
glEnable(GL_FOG);
@ -2587,16 +2594,32 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
}
// normalization
if (resetAllRenderStates || lastmaterial.NormalizeNormals != material.NormalizeNormals)
if (resetAllRenderStates || FixedPipelineState == EOFPS_DISABLE_TO_ENABLE ||
lastmaterial.NormalizeNormals != material.NormalizeNormals)
{
if (material.NormalizeNormals)
glEnable(GL_NORMALIZE);
else
glDisable(GL_NORMALIZE);
}
// Set fixed pipeline as active.
FixedPipelineState = EOFPS_ENABLE;
}
else if (FixedPipelineState == EOFPS_ENABLE_TO_DISABLE)
{
glDisable(GL_COLOR_MATERIAL);
glDisable(GL_LIGHTING);
glDisable(GL_FOG);
glDisable(GL_NORMALIZE);
// Set programmable pipeline as active.
FixedPipelineState = EOFPS_DISABLE;
}
// fillmode
// FixedPipelineState == 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))
glPolygonMode(GL_FRONT_AND_BACK, material.Wireframe ? GL_LINE : material.PointCloud? GL_POINT : GL_FILL);
@ -2875,7 +2898,7 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
}
//! Compare in SMaterial doesn't check texture parameters, so we should call this on each OnRender call.
void COpenGLDriver::setTextureRenderStates(const SMaterial& material, bool resetAllRenderstates, bool fixedPipeline)
void COpenGLDriver::setTextureRenderStates(const SMaterial& material, bool resetAllRenderstates)
{
// Set textures to TU/TIU and apply filters to them
@ -2884,20 +2907,20 @@ void COpenGLDriver::setTextureRenderStates(const SMaterial& material, bool reset
const COpenGLTexture* tmpTexture = static_cast<const COpenGLTexture*>(CurrentTexture[i]);
GLenum tmpTextureType = (tmpTexture) ? tmpTexture->getOpenGLTextureType() : GL_TEXTURE_2D;
if(fixedPipeline)
if(FixedPipelineState == EOFPS_ENABLE || FixedPipelineState == EOFPS_DISABLE_TO_ENABLE)
{
if (i>0 && !MultiTextureExtension)
break;
if (!CurrentTexture[i])
{
BridgeCalls->setTexture(i, tmpTextureType, fixedPipeline);
BridgeCalls->setTexture(i, tmpTextureType, true);
continue;
}
else
{
BridgeCalls->setTexture(i, tmpTextureType, fixedPipeline);
BridgeCalls->setTexture(i, tmpTextureType, true);
setTransform ((E_TRANSFORMATION_STATE) (ETS_TEXTURE_0 + i), material.getTextureMatrix(i));
}
@ -2906,7 +2929,7 @@ void COpenGLDriver::setTextureRenderStates(const SMaterial& material, bool reset
{
if (CurrentTexture[i])
{
BridgeCalls->setTexture(i, tmpTextureType, fixedPipeline);
BridgeCalls->setTexture(i, tmpTextureType, false);
}
else
continue;
@ -3033,6 +3056,12 @@ void COpenGLDriver::enableMaterial2D(bool enable)
//! sets the needed renderstates
void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel)
{
// 2d methods uses fixed pipeline
if (FixedPipelineState == COpenGLDriver::EOFPS_DISABLE)
FixedPipelineState = COpenGLDriver::EOFPS_DISABLE_TO_ENABLE;
else
FixedPipelineState = COpenGLDriver::EOFPS_ENABLE;
if (CurrentRenderMode != ERM_2D || Transformation3DChanged)
{
// unset last 3d material
@ -3062,7 +3091,7 @@ void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaCh
}
if (!OverrideMaterial2DEnabled)
{
setBasicRenderStates(InitMaterial2D, LastMaterial, true, true);
setBasicRenderStates(InitMaterial2D, LastMaterial, true);
LastMaterial = InitMaterial2D;
}
BridgeCalls->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@ -3075,7 +3104,7 @@ void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaCh
if (OverrideMaterial2DEnabled)
{
OverrideMaterial2D.Lighting=false;
setBasicRenderStates(OverrideMaterial2D, LastMaterial, false, true);
setBasicRenderStates(OverrideMaterial2D, LastMaterial, false);
LastMaterial = OverrideMaterial2D;
}
@ -3097,9 +3126,9 @@ void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaCh
if (texture)
{
if (OverrideMaterial2DEnabled)
setTextureRenderStates(OverrideMaterial2D, false, true);
setTextureRenderStates(OverrideMaterial2D, false);
else
setTextureRenderStates(InitMaterial2D, false, true);
setTextureRenderStates(InitMaterial2D, false);
Material.setTexture(0, const_cast<video::ITexture*>(CurrentTexture[0]));
setTransform(ETS_TEXTURE_0, core::IdentityMatrix);
@ -4597,6 +4626,16 @@ GLenum COpenGLDriver::getZBufferBits() const
return bits;
}
COpenGLDriver::E_OPENGL_FIXED_PIPELINE_STATE COpenGLDriver::getFixedPipelineState() const
{
return FixedPipelineState;
}
void COpenGLDriver::setFixedPipelineState(COpenGLDriver::E_OPENGL_FIXED_PIPELINE_STATE state)
{
FixedPipelineState = state;
}
const SMaterial& COpenGLDriver::getCurrentMaterial() const
{
return Material;

View File

@ -42,6 +42,14 @@ namespace video
friend class COpenGLCallBridge;
friend class COpenGLTexture;
public:
// Information about state of fixed pipeline activity.
enum E_OPENGL_FIXED_PIPELINE_STATE
{
EOFPS_ENABLE = 0, // fixed pipeline.
EOFPS_DISABLE, // programmable pipeline.
EOFPS_ENABLE_TO_DISABLE, // switch from fixed to programmable pipeline.
EOFPS_DISABLE_TO_ENABLE // switch from programmable to fixed pipeline.
};
#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager);
@ -280,16 +288,16 @@ namespace video
virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial,
bool resetAllRenderstates) _IRR_OVERRIDE_
{
setBasicRenderStates(material, lastmaterial, resetAllRenderstates, true);
setTextureRenderStates(material, resetAllRenderstates, true);
setOpenGLBasicRenderStates(material, lastmaterial, resetAllRenderstates);
setTextureRenderStates(material, resetAllRenderstates);
}
//! Can be called by an IMaterialRenderer to make its work easier.
virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial,
bool resetAllRenderstates, bool fixedPipeline);
//! OpenGL version of setBasicRenderStates method.
void setOpenGLBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial,
bool resetAllRenderstates);
//! 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, bool fixedPipeline);
virtual void setTextureRenderStates(const SMaterial& material, bool resetAllRenderstates);
//! Get a vertex shader constant index.
virtual s32 getVertexShaderConstantID(const c8* name) _IRR_OVERRIDE_;
@ -419,6 +427,12 @@ namespace video
//! Get ZBuffer bits.
GLenum getZBufferBits() const;
//! Return info about fixed pipeline state.
E_OPENGL_FIXED_PIPELINE_STATE getFixedPipelineState() const;
//! Set info about fixed pipeline state.
void setFixedPipelineState(E_OPENGL_FIXED_PIPELINE_STATE state);
//! Get current material.
const SMaterial& getCurrentMaterial() const;
@ -588,6 +602,8 @@ namespace video
//! Color buffer format
ECOLOR_FORMAT ColorFormat;
E_OPENGL_FIXED_PIPELINE_STATE FixedPipelineState;
//! Render target type for render operations
E_RENDER_TARGET CurrentTarget;

View File

@ -38,7 +38,7 @@ public:
virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) _IRR_OVERRIDE_
{
Driver->setTextureRenderStates(Driver->getCurrentMaterial(), false, true);
Driver->setTextureRenderStates(Driver->getCurrentMaterial(), false);
return true;
}
@ -59,8 +59,13 @@ public:
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services) _IRR_OVERRIDE_
{
if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_DISABLE)
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE_TO_ENABLE);
else
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE);
Driver->disableTextures(1);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates, true);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (resetAllRenderstates || (material.MaterialType != lastMaterial.MaterialType))
{
@ -83,8 +88,13 @@ public:
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services) _IRR_OVERRIDE_
{
if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_DISABLE)
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE_TO_ENABLE);
else
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE);
Driver->disableTextures(1);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates, true);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
// if (material.MaterialType != lastMaterial.MaterialType ||
// material.MaterialTypeParam != lastMaterial.MaterialTypeParam ||
@ -209,8 +219,13 @@ public:
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services) _IRR_OVERRIDE_
{
if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_DISABLE)
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE_TO_ENABLE);
else
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE);
Driver->disableTextures(2);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates, true);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
@ -268,8 +283,13 @@ public:
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services) _IRR_OVERRIDE_
{
if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_DISABLE)
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE_TO_ENABLE);
else
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE);
Driver->disableTextures(1);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates, true);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if ((material.MaterialType != lastMaterial.MaterialType) || resetAllRenderstates)
{
@ -314,8 +334,13 @@ public:
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services) _IRR_OVERRIDE_
{
if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_DISABLE)
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE_TO_ENABLE);
else
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE);
Driver->disableTextures(1);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates, true);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
@ -383,6 +408,11 @@ public:
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services) _IRR_OVERRIDE_
{
if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_DISABLE)
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE_TO_ENABLE);
else
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE);
Driver->disableTextures(1);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
@ -457,8 +487,13 @@ public:
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services) _IRR_OVERRIDE_
{
if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_DISABLE)
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE_TO_ENABLE);
else
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE);
Driver->disableTextures(1);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates, true);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
@ -503,8 +538,13 @@ public:
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services) _IRR_OVERRIDE_
{
if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_DISABLE)
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE_TO_ENABLE);
else
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE);
Driver->disableTextures(2);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates, true);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
@ -619,8 +659,13 @@ public:
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services) _IRR_OVERRIDE_
{
if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_DISABLE)
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE_TO_ENABLE);
else
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE);
Driver->disableTextures(2);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates, true);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
@ -668,12 +713,17 @@ public:
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services) _IRR_OVERRIDE_
{
if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_DISABLE)
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE_TO_ENABLE);
else
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE);
Driver->disableTextures(1);
// texture needs to be flipped for OpenGL
core::matrix4 tmp = Driver->getTransform(ETS_TEXTURE_0);
tmp[5]*=-1;
Driver->setTransform(ETS_TEXTURE_0, tmp);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates, true);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
@ -704,8 +754,13 @@ public:
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services) _IRR_OVERRIDE_
{
if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_DISABLE)
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE_TO_ENABLE);
else
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE);
Driver->disableTextures(2);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates, true);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
@ -759,8 +814,13 @@ public:
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services) _IRR_OVERRIDE_
{
if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_DISABLE)
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE_TO_ENABLE);
else
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE);
Driver->disableTextures(2);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates, true);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{

View File

@ -201,7 +201,7 @@ void COpenGLSLMaterialRenderer::init(s32& outMaterialTypeNr,
bool COpenGLSLMaterialRenderer::OnRender(IMaterialRendererServices* service,
E_VERTEX_TYPE vtxtype)
{
Driver->setTextureRenderStates(Driver->getCurrentMaterial(), false, false);
Driver->setTextureRenderStates(Driver->getCurrentMaterial(), false);
// call callback to set shader constants
if (CallBack && (Program||Program2))
@ -216,7 +216,10 @@ void COpenGLSLMaterialRenderer::OnSetMaterial(const video::SMaterial& material,
bool resetAllRenderstates,
video::IMaterialRendererServices* services)
{
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates, false);
if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_ENABLE)
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE_TO_DISABLE);
else
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
@ -231,6 +234,8 @@ void COpenGLSLMaterialRenderer::OnSetMaterial(const video::SMaterial& material,
if (CallBack)
CallBack->OnSetMaterial(material);
}
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
}
@ -505,7 +510,7 @@ void COpenGLSLMaterialRenderer::setBasicRenderStates(const SMaterial& material,
bool resetAllRenderstates)
{
// forward
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates, false);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
}
s32 COpenGLSLMaterialRenderer::getVertexShaderConstantID(const c8* name)

View File

@ -120,7 +120,7 @@ void COpenGLShaderMaterialRenderer::init(s32& outMaterialTypeNr,
bool COpenGLShaderMaterialRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype)
{
Driver->setTextureRenderStates(Driver->getCurrentMaterial(), false, false);
Driver->setTextureRenderStates(Driver->getCurrentMaterial(), false);
// call callback to set shader constants
if (CallBack && (VertexShader || PixelShader[0]))
@ -133,7 +133,10 @@ bool COpenGLShaderMaterialRenderer::OnRender(IMaterialRendererServices* service,
void COpenGLShaderMaterialRenderer::OnSetMaterial(const video::SMaterial& material, const video::SMaterial& lastMaterial,
bool resetAllRenderstates, video::IMaterialRendererServices* services)
{
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates, false);
if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_ENABLE)
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE_TO_DISABLE);
else
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
@ -181,6 +184,8 @@ void COpenGLShaderMaterialRenderer::OnSetMaterial(const video::SMaterial& materi
if (CallBack)
CallBack->OnSetMaterial(material);
}
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
}