* Deleted StencilFunction and replaced it with TestFunction (in case it will be used in more than one place)

* RenderContext.reset() now properly resets stencil render state.
 * Added full javadoc to RenderState

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7581 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
sha..rd 14 years ago
parent 87116ba4bc
commit dce2dd2eb1
  1. 761
      engine/src/core/com/jme3/material/RenderState.java
  2. 15
      engine/src/core/com/jme3/renderer/RenderContext.java
  3. 40
      engine/src/lwjgl-ogl/com/jme3/renderer/lwjgl/LwjglRenderer.java

File diff suppressed because it is too large Load Diff

@ -35,7 +35,6 @@ package com.jme3.renderer;
import com.jme3.material.RenderState; import com.jme3.material.RenderState;
import com.jme3.scene.VertexBuffer; import com.jme3.scene.VertexBuffer;
import com.jme3.texture.Image; import com.jme3.texture.Image;
import com.jme3.texture.Texture;
/** /**
* Represents the current state of the graphics library. This class is used * Represents the current state of the graphics library. This class is used
@ -149,8 +148,8 @@ public class RenderContext {
public RenderState.StencilOperation backStencilStencilFailOperation = RenderState.StencilOperation.Keep; public RenderState.StencilOperation backStencilStencilFailOperation = RenderState.StencilOperation.Keep;
public RenderState.StencilOperation backStencilDepthFailOperation = RenderState.StencilOperation.Keep; public RenderState.StencilOperation backStencilDepthFailOperation = RenderState.StencilOperation.Keep;
public RenderState.StencilOperation backStencilDepthPassOperation = RenderState.StencilOperation.Keep; public RenderState.StencilOperation backStencilDepthPassOperation = RenderState.StencilOperation.Keep;
public RenderState.StencilFunction frontStencilFunction = RenderState.StencilFunction.Always; public RenderState.TestFunction frontStencilFunction = RenderState.TestFunction.Always;
public RenderState.StencilFunction backStencilFunction = RenderState.StencilFunction.Always; public RenderState.TestFunction backStencilFunction = RenderState.TestFunction.Always;
/** /**
* Vertex attribs currently bound and enabled. If a slot is null, then * Vertex attribs currently bound and enabled. If a slot is null, then
@ -193,5 +192,15 @@ public class RenderContext {
boundAttribs[i] = null; boundAttribs[i] = null;
attribIndexList.reset(); attribIndexList.reset();
stencilTest = false;
frontStencilStencilFailOperation = RenderState.StencilOperation.Keep;
frontStencilDepthFailOperation = RenderState.StencilOperation.Keep;
frontStencilDepthPassOperation = RenderState.StencilOperation.Keep;
backStencilStencilFailOperation = RenderState.StencilOperation.Keep;
backStencilDepthFailOperation = RenderState.StencilOperation.Keep;
backStencilDepthPassOperation = RenderState.StencilOperation.Keep;
frontStencilFunction = RenderState.TestFunction.Always;
backStencilFunction = RenderState.TestFunction.Always;
} }
} }

@ -33,6 +33,8 @@ package com.jme3.renderer.lwjgl;
import com.jme3.light.LightList; import com.jme3.light.LightList;
import com.jme3.material.RenderState; import com.jme3.material.RenderState;
import com.jme3.material.RenderState.StencilOperation;
import com.jme3.material.RenderState.TestFunction;
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath; import com.jme3.math.FastMath;
import com.jme3.math.Matrix4f; import com.jme3.math.Matrix4f;
@ -67,6 +69,7 @@ import com.jme3.util.BufferUtils;
import com.jme3.util.IntMap; import com.jme3.util.IntMap;
import com.jme3.util.IntMap.Entry; import com.jme3.util.IntMap.Entry;
import com.jme3.util.ListMap; import com.jme3.util.ListMap;
import java.io.File;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.DoubleBuffer; import java.nio.DoubleBuffer;
import java.nio.FloatBuffer; import java.nio.FloatBuffer;
@ -632,28 +635,27 @@ public class LwjglRenderer implements Renderer {
if (state.isStencilTest()) { if (state.isStencilTest()) {
glEnable(GL_STENCIL_TEST); glEnable(GL_STENCIL_TEST);
glStencilOpSeparate(GL_FRONT, glStencilOpSeparate(GL_FRONT,
glStencilOpFromStencilOp(state.getFrontStencilStencilFailOperation()), convertStencilOperation(state.getFrontStencilStencilFailOperation()),
glStencilOpFromStencilOp(state.getFrontStencilDepthFailOperation()), convertStencilOperation(state.getFrontStencilDepthFailOperation()),
glStencilOpFromStencilOp(state.getFrontStencilDepthPassOperation())); convertStencilOperation(state.getFrontStencilDepthPassOperation()));
glStencilOpSeparate(GL_BACK, glStencilOpSeparate(GL_BACK,
glStencilOpFromStencilOp(state.getBackStencilStencilFailOperation()), convertStencilOperation(state.getBackStencilStencilFailOperation()),
glStencilOpFromStencilOp(state.getBackStencilDepthFailOperation()), convertStencilOperation(state.getBackStencilDepthFailOperation()),
glStencilOpFromStencilOp(state.getBackStencilDepthPassOperation())); convertStencilOperation(state.getBackStencilDepthPassOperation()));
glStencilFuncSeparate(GL_FRONT, glStencilFuncSeparate(GL_FRONT,
glStencilFuncFromStencilFunc(state.getFrontStencilFunction()), convertTestFunction(state.getFrontStencilFunction()),
0, Integer.MAX_VALUE); 0, Integer.MAX_VALUE);
glStencilFuncSeparate(GL_BACK, glStencilFuncSeparate(GL_BACK,
glStencilFuncFromStencilFunc(state.getBackStencilFunction()), convertTestFunction(state.getBackStencilFunction()),
0, Integer.MAX_VALUE); 0, Integer.MAX_VALUE);
} else { } else {
glDisable(GL_STENCIL_TEST); glDisable(GL_STENCIL_TEST);
} }
} }
} }
private int glStencilOpFromStencilOp(RenderState.StencilOperation s) { private int convertStencilOperation(StencilOperation stencilOp) {
switch (s) { switch (stencilOp) {
case Keep: case Keep:
return GL_KEEP; return GL_KEEP;
case Zero: case Zero:
@ -671,21 +673,21 @@ public class LwjglRenderer implements Renderer {
case Invert: case Invert:
return GL_INVERT; return GL_INVERT;
default: default:
throw new UnsupportedOperationException("Unrecognized front stencil operation: " + s); throw new UnsupportedOperationException("Unrecognized stencil operation: " + stencilOp);
} //end switch }
} }
private int glStencilFuncFromStencilFunc(RenderState.StencilFunction s) { private int convertTestFunction(TestFunction testFunc) {
switch (s) { switch (testFunc) {
case Never: case Never:
return GL_NEVER; return GL_NEVER;
case Less: case Less:
return GL_LESS; return GL_LESS;
case LessEqual: case LessOrEqual:
return GL_LEQUAL; return GL_LEQUAL;
case Greater: case Greater:
return GL_GREATER; return GL_GREATER;
case GreaterEqual: case GreaterOrEqual:
return GL_GEQUAL; return GL_GEQUAL;
case Equal: case Equal:
return GL_EQUAL; return GL_EQUAL;
@ -694,8 +696,8 @@ public class LwjglRenderer implements Renderer {
case Always: case Always:
return GL_ALWAYS; return GL_ALWAYS;
default: default:
throw new UnsupportedOperationException("Unrecognized front stencil functin: " + s); throw new UnsupportedOperationException("Unrecognized test function: " + testFunc);
} //end switch }
} }
/*********************************************************************\ /*********************************************************************\

Loading…
Cancel
Save