Bug 1272

Summary: Two-pass TextRenderer color changing during runtime doesn't work if glyph caching is enabled
Product: [JogAmp] Jogl Reporter: Alan Sambol <alan.zgb>
Component: graphAssignee: Sven Gothel <sgothel>
Status: RESOLVED FIXED    
Severity: normal CC: alan.zgb, rami.santina, sgothel
Priority: P4    
Version: tbd   
Hardware: All   
OS: all   
Type: DEFECT SCM Refs:
Workaround: ---
Bug Depends on:    
Bug Blocks: 1064    

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