Re: TextRenderer and VAOs

Posted by JanBenes on
URL: https://forum.jogamp.org/TextRenderer-and-VAOs-tp4029530p4029539.html

Hi Rami,

thanks for looking into this. Unfortunately, it didn't help (see my modified source TestTextRendering_v2.java). This is my modified display method

public void display(GLAutoDrawable drawable) {
	System.out.println("display");
		
	GL3 gl = new DebugGL3(drawable.getGL().getGL3());
	drawable.setGL(gl);
		
	gl.glClear(GL3.GL_COLOR_BUFFER_BIT | GL3.GL_DEPTH_BUFFER_BIT);		
	<nabble_a href="TestTextRendering_v2.java">TestTextRendering_v2.java</nabble_a>
	int width = drawable.getWidth();
	int height = drawable.getHeight();
		
	if(!textRenderer.isInitialized()) {
		textRenderer.init(gl);
		textRenderer.setAlpha(gl, 1.0f);
		textRenderer.setColorStatic(gl, 1, 0, 0);
	}
		
	textRenderer.getShaderState().useProgram(gl, true);
		
	textRenderer.reshapePerspective(null, 45.0f, width, height, 0.1f, 7000.0f);  // has probably no effect
	textRenderer.reshapeOrtho(null, width, height, 0.1f, 7000.0f);

        final float[] textPosition = new float[] {0, 0, 0};
        final int[] texSize = new int[] { 400 }; 
        final int fontSize = 50;
        
        textRenderer.resetModelview(null);
        textRenderer.translate(gl, 250, 250, -6000);
        textRenderer.updateMatrix(gl);
        textRenderer.drawString3D(gl, font, "Hi", textPosition, fontSize, texSize);
        
        textRenderer.getShaderState().useProgram(gl, false);
        
        // UNCOMMENT BELOW TO MAKE APPLICATION THROW AN EXCEPTION IN THE NEXT CALL TO DISPLAY
        // gl.glBindVertexArray(0); 
}

To me, it seems as if the text renderer wasn't able to handle the unbinding of (its) vertex array. I don't think it is illegal to call glBindVertexArray(0). Maybe a different call is needed to re-bind the text renderer's buffer? Also, Rami, could you please show me how the Region variable is created? I can't try to just copy-paste and run your code without it. Thanks!

I have tried (don't know why I haven't tried that before) using a DebugGL3 context and am now getting the following output by calling drawString3D after calling glBindVertexArray(0); here, "init" and "display" are just debugging print-outs. I get:

init
display
display
Exception in thread "AWT-EventQueue-0" javax.media.opengl.GLException: Thread[AWT-EventQueue-0,6,main] glGetError() returned the following error codes after a call to glGetVertexAttribiv(<int> 0x0, <int> 0x889F, <[I>, <int> 0x0): GL_INVALID_OPERATION ( 1282 0x502), 
	at javax.media.opengl.DebugGL3.checkGLGetError(DebugGL3.java:9753)
	at javax.media.opengl.DebugGL3.glGetVertexAttribiv(DebugGL3.java:8150)
	at javax.media.opengl.DebugGL3.glGetVertexAttribiv(DebugGL3.java:8144)
	at javax.media.opengl.DebugGL3.glGetVertexAttribiv(DebugGL3.java:8144)
	at jogamp.opengl.util.glsl.GLSLArrayHandler.enableShaderState(GLSLArrayHandler.java:101)
	at jogamp.opengl.util.glsl.GLSLArrayHandler.enableState(GLSLArrayHandler.java:64)
	at com.jogamp.opengl.util.GLArrayDataClient.enableBuffer(GLArrayDataClient.java:207)
	at jogamp.graph.curve.opengl.VBORegionSPES2.drawImpl(VBORegionSPES2.java:129)
	at com.jogamp.graph.curve.opengl.GLRegion.draw(GLRegion.java:125)
	at jogamp.graph.curve.text.GlyphString.renderString3D(GlyphString.java:187)
	at jogamp.graph.curve.opengl.TextRendererImpl01.drawString3D(TextRendererImpl01.java:105)
	at simplebrowser.prototype.TestTextRendering.display(TestTextRendering.java:101)
	at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:583)
	at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:567)
	at javax.media.opengl.awt.GLCanvas$7.run(GLCanvas.java:1054)
	at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1029)
	at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:904)
	at javax.media.opengl.awt.GLCanvas$8.run(GLCanvas.java:1065)
	at javax.media.opengl.Threading.invoke(Threading.java:193)
	at javax.media.opengl.awt.GLCanvas.display(GLCanvas.java:483)
	at javax.media.opengl.awt.GLCanvas.paint(GLCanvas.java:537)
	at javax.media.opengl.awt.GLCanvas.update(GLCanvas.java:719)
	at sun.awt.RepaintArea.updateComponent(RepaintArea.java:255)
	at sun.lwawt.LWRepaintArea.updateComponent(LWRepaintArea.java:42)
	at sun.awt.RepaintArea.paint(RepaintArea.java:232)
	at sun.lwawt.LWComponentPeer.handleJavaPaintEvent(LWComponentPeer.java:1277)
	at sun.lwawt.LWComponentPeer.handleEvent(LWComponentPeer.java:1165)
	at java.awt.Component.dispatchEventImpl(Component.java:4937)
	at java.awt.Component.dispatchEvent(Component.java:4687)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:729)
	at java.awt.EventQueue.access$200(EventQueue.java:103)
	at java.awt.EventQueue$3.run(EventQueue.java:688)
	at java.awt.EventQueue$3.run(EventQueue.java:686)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
	at java.awt.EventQueue$4.run(EventQueue.java:702)
	at java.awt.EventQueue$4.run(EventQueue.java:700)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:699)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

edit: remove extra source code link