Implement depth_check for material scripts

scancodes-fix
Armin Burgmeier 2013-03-31 16:59:17 +02:00
parent 1d68f736a5
commit 90fbabd20f
3 changed files with 14 additions and 6 deletions

View File

@ -459,6 +459,9 @@ namespace
{
const StdMeshMaterialPass& pass = technique.Passes[i];
if(!pass.DepthCheck)
glDisable(GL_DEPTH_TEST);
glDepthMask(pass.DepthWrite ? GL_TRUE : GL_FALSE);
if(pass.AlphaToCoverage)
@ -630,6 +633,7 @@ namespace
if(shader.Mod2Location != -1) glUniform1iARB(shader.Mod2Location, fMod2);
glDrawElements(GL_TRIANGLES, instance.GetNumFaces()*3, GL_UNSIGNED_INT, instance.GetFaces());
// Clean-up, re-set default state
for (unsigned int j = 0; j < textures.size(); ++j)
{
glActiveTexture(GL_TEXTURE0+textures[j]);
@ -637,6 +641,9 @@ namespace
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisable(GL_TEXTURE_2D);
}
if(!pass.DepthCheck)
glEnable(GL_DEPTH_TEST);
}
}

View File

@ -831,7 +831,7 @@ void StdMeshMaterialTextureUnit::Load(StdMeshMaterialParserCtx& ctx)
}
StdMeshMaterialPass::StdMeshMaterialPass():
DepthWrite(true), CullHardware(CH_Clockwise)
DepthCheck(true), DepthWrite(true), CullHardware(CH_Clockwise)
{
Ambient[0] = Ambient[1] = Ambient[2] = 1.0f; Ambient[3] = 1.0f;
Diffuse[0] = Diffuse[1] = Diffuse[2] = 1.0f; Diffuse[3] = 1.0f;
@ -885,6 +885,10 @@ void StdMeshMaterialPass::Load(StdMeshMaterialParserCtx& ctx)
{
ctx.AdvanceColor(true, Emissive);
}
else if (token_name == "depth_check")
{
DepthCheck = ctx.AdvanceBoolean();
}
else if (token_name == "depth_write")
{
DepthWrite = ctx.AdvanceBoolean();
@ -912,11 +916,6 @@ void StdMeshMaterialPass::Load(StdMeshMaterialParserCtx& ctx)
ctx.AdvanceBoolean();
ctx.WarningNotSupported("colour_write");
}
else if (token_name == "depth_check")
{
ctx.AdvanceBoolean();
ctx.WarningNotSupported(token_name.getData());
}
else if (token_name == "depth_func")
{
StdStrBuf func;

View File

@ -269,7 +269,9 @@ public:
float Emissive[4];
float Shininess;
bool DepthCheck;
bool DepthWrite;
CullHardwareType CullHardware;
SceneBlendType SceneBlendFactors[2];
bool AlphaToCoverage;