Posted by
JanBenes on
URL: https://forum.jogamp.org/TextRenderer-and-VAOs-tp4029530p4030081.html
Hi Rami & others
sorry for the very long response time, I was swamped with other, more pressing, tasks. To give you a context refresh - I was hoping to render text and had problems doing so because calling gl.glBindVertexArray after drawing text would always cause a crash.
Following your advice, I tried
1)
Just changing to NewtCanvasAWT. I initialized my window/frame according to this
post. The resulting file is here:
TestTextRendering_v2.java.
I still get exactly the same issues as with GLCanvas. To answer your question. I'm calling gl.glBindVertexArray(0); because it has the same effect as calling gl.glBindVertexArray(anActualIdOfMyOwnVertexArray). I hope that by resolving this issue in the MWE, I will also be able to resolve it in my application.
Exception in thread "main" javax.media.opengl.GLException: Thread[main,5,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_v2.display(TestTextRendering_v2.java:110)
at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:583)
at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:567)
at jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:377)
at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1029)
at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:904)
at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:593)
at jogamp.opengl.GLAutoDrawableBase.defaultWindowResizedOp(GLAutoDrawableBase.java:222)
at com.jogamp.newt.opengl.GLWindow.access$200(GLWindow.java:103)
at com.jogamp.newt.opengl.GLWindow$2.windowResized(GLWindow.java:124)
at jogamp.newt.WindowImpl.consumeWindowEvent(WindowImpl.java:2632)
at jogamp.newt.WindowImpl.sendWindowEvent(WindowImpl.java:2570)
at com.jogamp.newt.opengl.GLWindow.sendWindowEvent(GLWindow.java:674)
at com.jogamp.newt.awt.NewtCanvasAWT.attachNewtChild(NewtCanvasAWT.java:589)
at com.jogamp.newt.awt.NewtCanvasAWT.validateComponent(NewtCanvasAWT.java:501)
at com.jogamp.newt.awt.NewtCanvasAWT.reshape(NewtCanvasAWT.java:439)
at java.awt.Component.setBounds(Component.java:2243)
at java.awt.BorderLayout.layoutContainer(BorderLayout.java:838)
at java.awt.Container.layout(Container.java:1503)
at java.awt.Container.doLayout(Container.java:1492)
at java.awt.Container.validateTree(Container.java:1688)
at java.awt.Container.validateTree(Container.java:1697)
at java.awt.Container.validateTree(Container.java:1697)
at java.awt.Container.validateTree(Container.java:1697)
at java.awt.Container.validate(Container.java:1623)
at java.awt.Container.validateUnconditionally(Container.java:1660)
at java.awt.Window.pack(Window.java:818)
at simplebrowser.prototype.TestTextRendering_v2.init2(TestTextRendering_v2.java:71)
at simplebrowser.prototype.TestTextRendering_v2.main(TestTextRendering_v2.java:78)
2)
Reconstructing a MWE from your snippets. I wonder if I went wrong somewhere (
TestTextRendering_v3.java), but I'm getting the below listed exception (without ever calling the offending glBindVertexArray):
Exception in thread "main" java.lang.RuntimeException: java.lang.NullPointerException
at jogamp.newt.DefaultEDTUtil.invokeImpl(DefaultEDTUtil.java:220)
at jogamp.newt.DefaultEDTUtil.invoke(DefaultEDTUtil.java:135)
at jogamp.newt.DisplayImpl.runOnEDTIfAvail(DisplayImpl.java:221)
at jogamp.newt.WindowImpl.runOnEDTIfAvail(WindowImpl.java:1724)
at jogamp.newt.WindowImpl.setVisible(WindowImpl.java:885)
at jogamp.newt.WindowImpl.setVisible(WindowImpl.java:890)
at com.jogamp.newt.opengl.GLWindow.setVisible(GLWindow.java:417)
at com.jogamp.newt.awt.NewtCanvasAWT.attachNewtChild(NewtCanvasAWT.java:587)
at com.jogamp.newt.awt.NewtCanvasAWT.validateComponent(NewtCanvasAWT.java:501)
at com.jogamp.newt.awt.NewtCanvasAWT.reshape(NewtCanvasAWT.java:439)
at java.awt.Component.setBounds(Component.java:2243)
at java.awt.BorderLayout.layoutContainer(BorderLayout.java:838)
at java.awt.Container.layout(Container.java:1503)
at java.awt.Container.doLayout(Container.java:1492)
at java.awt.Container.validateTree(Container.java:1688)
at java.awt.Container.validateTree(Container.java:1697)
at java.awt.Container.validateTree(Container.java:1697)
at java.awt.Container.validateTree(Container.java:1697)
at java.awt.Container.validate(Container.java:1623)
at java.awt.Container.validateUnconditionally(Container.java:1660)
at java.awt.Window.show(Window.java:1033)
at java.awt.Component.show(Component.java:1651)
at java.awt.Component.setVisible(Component.java:1603)
at java.awt.Window.setVisible(Window.java:1014)
at simplebrowser.prototype.TestTextRendering_v3.init2(TestTextRendering_v3.java:74)
at simplebrowser.prototype.TestTextRendering_v3.main(TestTextRendering_v3.java:80)
Caused by: java.lang.NullPointerException
at simplebrowser.prototype.TestTextRendering_v3.display(TestTextRendering_v3.java:92)
at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:583)
at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:567)
at jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:377)
at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1029)
at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:904)
at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:593)
at jogamp.opengl.GLAutoDrawableBase.defaultWindowResizedOp(GLAutoDrawableBase.java:222)
at com.jogamp.newt.opengl.GLWindow.access$200(GLWindow.java:103)
at com.jogamp.newt.opengl.GLWindow$2.windowResized(GLWindow.java:124)
at jogamp.newt.WindowImpl.consumeWindowEvent(WindowImpl.java:2632)
at jogamp.newt.WindowImpl.sendWindowEvent(WindowImpl.java:2570)
at jogamp.newt.WindowImpl.setVisibleActionImpl(WindowImpl.java:866)
at jogamp.newt.WindowImpl$VisibleAction.run(WindowImpl.java:877)
at com.jogamp.common.util.RunnableTask.run(RunnableTask.java:112)
at jogamp.newt.DefaultEDTUtil$EventDispatchThread.run(DefaultEDTUtil.java:331)
Overall, I have had a really hard time finding out how to create a window that uses NewCanvasAWT (I also couldn't find the text demos in the demos repository) and I did manage to down the JVM several times in the process. I have spent tens of hours now trying to render text in my application (and constructing the MWE/finding out what the issue is) and really hope I can resolve this issue soon.
Could someone go ahead and run the the
TestTextRendering_v2.java source and tell me if it works for them on a different machine? Any suggestions appreciated.
Thanks a lot!
J.