From 13132e10cc618134df58660368f9cc2569750535 Mon Sep 17 00:00:00 2001 From: "Sha..om" Date: Mon, 17 Sep 2012 16:41:28 +0000 Subject: [PATCH] * Remy: please rename context.alphaTestEnabled to alphaTestFallOff and make it a float. Also, add FixedFuncBinding.AlphaTestFallOff and make J3MLoader parse it git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9746 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../jme3/renderer/lwjgl/LwjglGL1Renderer.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/engine/src/lwjgl/com/jme3/renderer/lwjgl/LwjglGL1Renderer.java b/engine/src/lwjgl/com/jme3/renderer/lwjgl/LwjglGL1Renderer.java index cd1ac611d..4e12694a1 100644 --- a/engine/src/lwjgl/com/jme3/renderer/lwjgl/LwjglGL1Renderer.java +++ b/engine/src/lwjgl/com/jme3/renderer/lwjgl/LwjglGL1Renderer.java @@ -204,12 +204,19 @@ public class LwjglGL1Renderer implements GL1Renderer { glColor4f(1, 1, 1, 1); } } + if (context.alphaTestFallOff > 0f) { + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_GREATER, context.alphaTestFallOff); + } else { + glDisable(GL_ALPHA_TEST); + } } /** * Reset fixed function bindings to default values. */ private void resetFixedFuncBindings(){ + context.alphaTestFallOff = 0f; // zero means disable alpha test! context.color = null; context.ambient = null; context.diffuse = null; @@ -219,6 +226,7 @@ public class LwjglGL1Renderer implements GL1Renderer { } public void setFixedFuncBinding(FixedFuncBinding ffBinding, Object val) { + float falloff; switch (ffBinding) { case Color: context.color = (ColorRGBA) val; @@ -238,6 +246,9 @@ public class LwjglGL1Renderer implements GL1Renderer { case UseVertexColor: context.useVertexColor = (Boolean) val; break; + case AlphaTestFallOff: + context.alphaTestFallOff = (Float) val; + break; } } @@ -259,15 +270,12 @@ public class LwjglGL1Renderer implements GL1Renderer { context.depthTestEnabled = false; } - if (state.isAlphaTest() && !context.alphaTestEnabled) { - glEnable(GL_ALPHA_TEST); - glAlphaFunc(GL_GREATER, state.getAlphaFallOff()); - context.alphaTestEnabled = true; - } else if (!state.isAlphaTest() && context.alphaTestEnabled) { - glDisable(GL_ALPHA_TEST); - context.alphaTestEnabled = false; + if (state.isAlphaTest()) { + setFixedFuncBinding(FixedFuncBinding.AlphaTestFallOff, state.getAlphaFallOff()); + } else { + setFixedFuncBinding(FixedFuncBinding.AlphaTestFallOff, 0f); // disable it } - + if (state.isDepthWrite() && !context.depthWriteEnabled) { glDepthMask(true); context.depthWriteEnabled = true;