diff --git a/jme3-core/src/main/java/com/jme3/material/RenderState.java b/jme3-core/src/main/java/com/jme3/material/RenderState.java index 107b9fe40..56b608e33 100644 --- a/jme3-core/src/main/java/com/jme3/material/RenderState.java +++ b/jme3-core/src/main/java/com/jme3/material/RenderState.java @@ -216,63 +216,64 @@ public class RenderState implements Cloneable, Savable { /** * RGB Factor (0, 0, 0), Alpha Factor (0) */ - Zero, + Zero(0), /** * RGB Factor (1, 1, 1), Alpha Factor (1) */ - One, + One(1), /** * RGB Factor (R_s0, G_s0, B_s0), Alpha Factor (A_s0) */ - Src_Color, + Src_Color(2), /** * RGB Factor (1-R_s0, 1-G_s0, 1-B_s0), Alpha Factor (1-A_s0) */ - One_Minus_Src_Color, + One_Minus_Src_Color(3), /** * RGB Factor (R_d, G_d, B_d), Alpha Factor (A_d) */ - Dst_Color, + Dst_Color(4), /** * RGB Factor (1-R_d, 1-G_d, 1-B_d), Alpha Factor (1-A_d) */ - One_Minus_Dst_Color, + One_Minus_Dst_Color(5), /** * RGB Factor (A_s0, A_s0, A_s0), Alpha Factor (A_s0) */ - Src_Alpha, + Src_Alpha(6), /** * RGB Factor (1-A_s0, 1-A_s0, 1-A_s0), Alpha Factor (1-A_s0) */ - One_Minus_Src_Alpha, + One_Minus_Src_Alpha(7), /** * RGB Factor (A_d, A_d, A_d), Alpha Factor (A_d) */ - Dst_Alpha, + Dst_Alpha(8), /** * RGB Factor (1-A_d, 1-A_d, 1-A_d), Alpha Factor (1-A_d) */ - One_Minus_Dst_Alpha, - /** - * RGB Factor (R_c, G_c, B_c), Alpha Factor (A_c) - */ - //Constant_Color, - /** - * RGB Factor (1-R_c, 1-G_c, 1-B_c), Alpha Factor (1-A_c) - */ - //One_Minus_Constant_Color, - /** - * RGB Factor (A_c, A_c, A_c), Alpha Factor (A_c) - */ - //Constant_Alpha, + One_Minus_Dst_Alpha(9), /** - * RGB Factor (1-A_c, 1-A_c, 1-A_c), Alpha Factor (A_c) + * RGB Factor (i, i, i), Alpha Factor (1) */ - //One_Minus_Constant_Alpha, + Src_Alpha_Saturate(10); + + // Convenience value for easy use by the renderer. + private final int value; + + // Convenience constructor. + private BlendFunc(int value) { + this.value=value; + } + /** - * RGB Factor (i, i, i), Alpha Factor (1) + * Provides a predefined integer value for easy use by the renderer. + * + * @return The predefined integer value. */ - Src_Alpha_Saturate + public int getIntValue() { + return value; + } } diff --git a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java index 8d38c5ad7..72bff6586 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java +++ b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java @@ -751,10 +751,10 @@ public final class GLRenderer implements Renderer { break; case Custom: gl.glBlendFuncSeparate( - convertBlendFunc(state.getCustomSfactorRGB()), - convertBlendFunc(state.getCustomDfactorRGB()), - convertBlendFunc(state.getCustomSfactorAlpha()), - convertBlendFunc(state.getCustomDfactorAlpha())); + state.getCustomSfactorRGB().getIntValue(), + state.getCustomDfactorRGB().getIntValue(), + state.getCustomSfactorAlpha().getIntValue(), + state.getCustomDfactorAlpha().getIntValue()); break; default: throw new UnsupportedOperationException("Unrecognized blend mode: " @@ -858,35 +858,6 @@ public final class GLRenderer implements Renderer { } } - private int convertBlendFunc(BlendFunc blendFunc) { - switch (blendFunc) { - case Zero: - return GL.GL_ZERO; - case One: - return GL.GL_ONE; - case Src_Color: - return GL.GL_SRC_COLOR; - case One_Minus_Src_Color: - return GL.GL_ONE_MINUS_SRC_COLOR; - case Dst_Color: - return GL.GL_DST_COLOR; - case One_Minus_Dst_Color: - return GL.GL_ONE_MINUS_DST_COLOR; - case Src_Alpha: - return GL.GL_SRC_ALPHA; - case One_Minus_Src_Alpha: - return GL.GL_ONE_MINUS_SRC_ALPHA; - case Dst_Alpha: - return GL3.GL_DST_ALPHA; - case One_Minus_Dst_Alpha: - return GL3.GL_ONE_MINUS_DST_ALPHA; - case Src_Alpha_Saturate: - return GL.GL_SRC_ALPHA_SATURATE; - default: - throw new UnsupportedOperationException("Unrecognized blend function: " + blendFunc); - } - } - private int convertStencilOperation(StencilOperation stencilOp) { switch (stencilOp) { case Keep: