Bug 1272 - Two-pass TextRenderer color changing during runtime doesn't work if glyph caching is enabled
Summary: Two-pass TextRenderer color changing during runtime doesn't work if glyph cac...
Status: RESOLVED FIXED
Alias: None
Product: Jogl
Classification: JogAmp
Component: graph (show other bugs)
Version: tbd
Hardware: All all
: P4 normal
Assignee: Sven Gothel
URL:
Depends on:
Blocks: 1064
  Show dependency treegraph
 
Reported: 2015-12-02 17:29 CET by Alan Sambol
Modified: 2024-02-14 00:53 CET (History)
3 users (show)

See Also:
Type: DEFECT
SCM Refs:
Workaround: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Sambol 2015-12-02 17:29:39 CET
I am using the following text rendering setup:

Initialisation:
	public void init(GL2ES2 gl) {		
		renderer = RegionRenderer.create(renderState, null, null);
		if (blending && renderModes > 0) {
renderState.setHintMask(RenderState.BITHINT_BLENDING_ENABLED);
		}
		// uses gl.glBlendFuncSeparate(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA, GL.GL_ONE, GL.GL_ONE_MINUS_SRC_ALPHA)
		textRenderUtil = new TextRegionUtil(renderModes);
		renderer.init(gl, renderModes);
		renderer.enable(gl, false);
		textRenderUtil.setCacheLimit(2048);
	}

Rendering:
	public void renderString(GL2ES2 gl, String text, String font, float pixelSize, float color[], int sampleCount) {
		if (renderModes != 0 && cullFace) {
			gl.glDisable(GL.GL_CULL_FACE);
		}
		this.sampleCount[0] = sampleCount;
		renderer.enable(gl, true);
		// Doesn't work if color changes during runtime with 2-pass rendering (VBAA/MSAA) with glyph caching enabled
		renderState.setColorStatic(color[0], color[1], color[2], color[3]);
		textRenderUtil.drawString3D(gl, renderer, fonts.get(font), pixelSize, text, null, this.sampleCount);
		renderer.enable(gl, false);
		if (renderModes != 0 && cullFace) {
			gl.glEnable(GL.GL_CULL_FACE);
		}
	}

If I use random colorStatic per each frame with renderModes = 0, the color changes as expected with good FPS. If I use renderModes = Region.VBAA_RENDERING_BIT or renderModes = Region.MSAA_RENDERING_BIT the color never changes and always uses the first assigned value.

When textRenderUtil.setCacheLimit(1) is performed the color changes as expected again, but performance is terribly slow (5x less FPS than with cache).

Same happens textRenderUtil.clear() is performed before each render.
Comment 1 Sven Gothel 2024-02-14 00:53:17 CET
Should work now