|
|
@ -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,10 +696,10 @@ 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
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************\ |
|
|
|
/*********************************************************************\ |
|
|
|
|* Camera and World transforms *| |
|
|
|
|* Camera and World transforms *| |
|
|
|
\*********************************************************************/ |
|
|
|
\*********************************************************************/ |
|
|
|