I've seen Text element doesn't work correctly:
Print some text in black color on white background will hide the text with defaut created text object :|.
After search, it's because the blend function isn't appropriate: Currently they add the text color to destination pixel. All text on white background doesn't display anything…
Here the problem:
//in Text.java
/*
* @return an alpha states for allowing 'black' to be transparent
*/
private static AlphaState getFontAlpha() {
AlphaState as1 = DisplaySystem.getDisplaySystem().getRenderer().createAlphaState();
as1.setBlendEnabled( true );
as1.setSrcFunction( AlphaState.SB_SRC_ALPHA );
as1.setDstFunction( AlphaState.DB_ONE );
return as1;
}
I've modified the code like this:
/*
* @return an alpha states for allowing 'black' to be transparent
*/
private static AlphaState getFontAlpha() {
AlphaState as1 = DisplaySystem.getDisplaySystem().getRenderer().createAlphaState();
as1.setBlendEnabled( true );
as1.setSrcFunction( AlphaState.SB_SRC_ALPHA );
as1.setDstFunction( AlphaState.DB_ONE_MINUS_SRC_ALPHA );
return as1;
}
and created a new fontboard in 32bits RGBA PNG, the same older but with transparency channel (I can send this if someone want...).
public static final String DEFAULT_FONT = "com/jme/app/defaultfont.png";
So now, all it's ok.
In search I think have find a forget here (AlphaState.java):
public void setSrcFunction(int srcFunction) {
if(srcFunction < 0 || srcFunction > 6) {
srcFunction = SB_SRC_ALPHA;
}
srcBlend = srcFunction;
setNeedsRefresh(true);
}
Don't they must write:
public void setSrcFunction(int srcFunction) {
if(srcFunction < 0 || srcFunction > 8) {
srcFunction = SB_SRC_ALPHA;
}
srcBlend = srcFunction;
setNeedsRefresh(true);
}
??? Because on before we have:
public final static int SB_ZERO = 0;
...
public final static int SB_ONE_MINUS_DST_ALPHA = 7;
public final static int SB_SRC_ALPHA_SATURATE = 8;