ssebi / jmonkeyengine

Automatically exported from code.google.com/p/jmonkeyengine
0 stars 0 forks source link

Nifty font color tags are no longer supported. #496

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Since the latest stable update nifty html <font color=""> tags no longer set 
the color for the relevant text. This is most likely due to the new set of 
Nifty materials loaded by RenderDeviceJme.java.

Suggested fix:

Instead of using NiftyTex for both images and fonts add a seperate Material for 
font rendering (NiftyFont.etc). This structure works:

NiftyFont.vert:
uniform mat4 g_WorldViewProjectionMatrix;

attribute vec4 inPosition;
attribute vec2 inTexCoord;
attribute vec4 inColor;

varying vec2 texCoord;
varying vec4 color;

void main() {
    vec2 pos = (g_WorldViewProjectionMatrix * inPosition).xy;
    gl_Position = vec4(pos, 0.0, 1.0);

    texCoord = inTexCoord;   
    color = inColor;
}

NiftyFont.frag:
uniform sampler2D m_Texture;
uniform vec4 m_Color; 

varying vec2 texCoord;
varying vec4 color;

void main() {
    vec4 texVal = texture2D(m_Texture, texCoord);

    gl_FragColor = texVal *  m_Color * color;
}

The J3MD is evident, I think.

Original issue reported on code.google.com by j.warmer...@gmail.com on 22 May 2012 at 2:00

GoogleCodeExporter commented 9 years ago

Original comment by ShadowIs...@gmail.com on 1 Jun 2012 at 3:44

GoogleCodeExporter commented 9 years ago
I can't reproduce this issue.
What is the <font> tag it does not seem to exist in Nifty.
Also i tried with a text tag <text color="..."/> and a <style><attribute 
font=".." color=".."/></style> and both are working properly.

Could you provide a xml document that fail, please?

Original comment by remy.bou...@gmail.com on 1 Jun 2012 at 7:21

GoogleCodeExporter commented 9 years ago

Original comment by ShadowIs...@gmail.com on 1 Jun 2012 at 10:38

GoogleCodeExporter commented 9 years ago
Jens developed an extension library that adds html support to nifty. For the 
<font> tag it converts the following String: "<font color="#ff0000ff">Monkeys 
eat bananas</font>" into "\#ff0000ff#Monkeys eat bananas". 

This is then broken into segments by BitMapText and the quad's (I think) color 
is set. The issue lies in the fact that the new Materials for Nifty don't take 
the base color into account.

I can't send you the failing xml, as it's too dependent on a large set of 
assets.

Original comment by j.warmer...@gmail.com on 2 Jun 2012 at 9:16

GoogleCodeExporter commented 9 years ago

Original comment by e.so...@gmail.com on 19 Sep 2012 at 4:43