Removed the switch/case statements in convertBlendFunc() by extending
the BlendFunc enumeration with a convenience integer value.
This commit is contained in:
parent
187e9944fd
commit
ca17bd592a
@ -216,63 +216,64 @@ public class RenderState implements Cloneable, Savable {
|
|||||||
/**
|
/**
|
||||||
* RGB Factor (0, 0, 0), Alpha Factor (0)
|
* RGB Factor (0, 0, 0), Alpha Factor (0)
|
||||||
*/
|
*/
|
||||||
Zero,
|
Zero(0),
|
||||||
/**
|
/**
|
||||||
* RGB Factor (1, 1, 1), Alpha Factor (1)
|
* RGB Factor (1, 1, 1), Alpha Factor (1)
|
||||||
*/
|
*/
|
||||||
One,
|
One(1),
|
||||||
/**
|
/**
|
||||||
* RGB Factor (R_s0, G_s0, B_s0), Alpha Factor (A_s0)
|
* 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)
|
* 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)
|
* 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)
|
* 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)
|
* 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)
|
* 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)
|
* 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)
|
* RGB Factor (1-A_d, 1-A_d, 1-A_d), Alpha Factor (1-A_d)
|
||||||
*/
|
*/
|
||||||
One_Minus_Dst_Alpha,
|
One_Minus_Dst_Alpha(9),
|
||||||
/**
|
|
||||||
* 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,
|
|
||||||
/**
|
|
||||||
* RGB Factor (1-A_c, 1-A_c, 1-A_c), Alpha Factor (A_c)
|
|
||||||
*/
|
|
||||||
//One_Minus_Constant_Alpha,
|
|
||||||
/**
|
/**
|
||||||
* RGB Factor (i, i, i), Alpha Factor (1)
|
* RGB Factor (i, i, i), Alpha Factor (1)
|
||||||
*/
|
*/
|
||||||
Src_Alpha_Saturate
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a predefined integer value for easy use by the renderer.
|
||||||
|
*
|
||||||
|
* @return The predefined integer value.
|
||||||
|
*/
|
||||||
|
public int getIntValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -751,10 +751,10 @@ public final class GLRenderer implements Renderer {
|
|||||||
break;
|
break;
|
||||||
case Custom:
|
case Custom:
|
||||||
gl.glBlendFuncSeparate(
|
gl.glBlendFuncSeparate(
|
||||||
convertBlendFunc(state.getCustomSfactorRGB()),
|
state.getCustomSfactorRGB().getIntValue(),
|
||||||
convertBlendFunc(state.getCustomDfactorRGB()),
|
state.getCustomDfactorRGB().getIntValue(),
|
||||||
convertBlendFunc(state.getCustomSfactorAlpha()),
|
state.getCustomSfactorAlpha().getIntValue(),
|
||||||
convertBlendFunc(state.getCustomDfactorAlpha()));
|
state.getCustomDfactorAlpha().getIntValue());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new UnsupportedOperationException("Unrecognized blend mode: "
|
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) {
|
private int convertStencilOperation(StencilOperation stencilOp) {
|
||||||
switch (stencilOp) {
|
switch (stencilOp) {
|
||||||
case Keep:
|
case Keep:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user