TextRenderer - my text won't show

classic Classic list List threaded Threaded
63 messages Options
1234
Reply | Threaded
Open this post in threaded view
|

Re: TextRenderer - my text won't show

chakie
Thanks. Seems to simply be a misnamed uniform.

Anyway, I can't seem to get a GL3bc profile on OSX. When I try

        GLProfile glprofile = GLProfile.get( GLProfile.GL3 );

I get:

Exception in thread "main" javax.media.opengl.GLException: Profile GL3bc is not available on null, but: [GLProfile[GL2ES2/GL2.hw], GLProfile[GL2ES1/GL2.hw], GLProfile[GL2/GL2.hw], GLProfile[GL3/GL3.hw], GLProfile[GL2/GL2.hw], GLProfile[GL2GL3/GL2.hw]]
Reply | Threaded
Open this post in threaded view
|

Re: TextRenderer - my text won't show

gouessej
Administrator
Just call GLProfile.getMaxFixedFunc() or GLProfile.getDefault().
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: TextRenderer - my text won't show

chakie
Those two give me a GL2 profile which is not what I want.

Reply | Threaded
Open this post in threaded view
|

Re: TextRenderer - my text won't show

gouessej
Administrator
There is no backward compatible profile available for your hardware. Therefore, you cannot benefit of OpenGL 3 and use GL2 at the same time :s Use the new shader based text renderer, wait for the fix of the bug 810 affecting the legacy renderer or use GL2.

You can use a 3D engine providing its own text rendering but a few supports forward compatible profiles. Even JMonkeyEngine 3 still uses a very few features of the fixed pipeline.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: TextRenderer - my text won't show

chakie
Yeah, the old renderer is out. OSX's OpenGL drivers aren't exactly the best I've seen, but at least we've got OpenGL3 nowadays.

The new shader based renderer looks to be very good, but it has some issues too. This is what I get:

Exception in thread "main-FPSAWTAnimator-Timer0" java.lang.RuntimeException: javax.media.opengl.GLException: Thread[AWT-EventQueue-0,6,main] glGetError() returned the following error codes after a call to glUniform(<javax.media.opengl.GLUniformData> GLUniformData[name gcu_ColorStatic, location 1, size 1x3, count 1, data HeapFloatBuffer[pos 0, lim 3, cap 3, remaining 3; array true, direct false, r/w true: 1.0, 1.0, 1.0]]): GL_INVALID_OPERATION ( 1282 0x502),
        at com.jogamp.common.util.awt.AWTEDTExecutor.invoke(AWTEDTExecutor.java:58)
        at jogamp.opengl.awt.AWTThreadingPlugin.invokeOnOpenGLThread(AWTThreadingPlugin.java:100)
        at jogamp.opengl.ThreadingImpl.invokeOnOpenGLThread(ThreadingImpl.java:205)
        at javax.media.opengl.Threading.invokeOnOpenGLThread(Threading.java:172)
        at javax.media.opengl.Threading.invoke(Threading.java:191)
        at javax.media.opengl.awt.GLCanvas.display(GLCanvas.java:483)
        at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:74)
        at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:440)
        at com.jogamp.opengl.util.FPSAnimator$MainTask.run(FPSAnimator.java:167)
        at java.util.TimerThread.mainLoop(Timer.java:555)
        at java.util.TimerThread.run(Timer.java:505)
Caused by: javax.media.opengl.GLException: Thread[AWT-EventQueue-0,6,main] glGetError() returned the following error codes after a call to glUniform(<javax.media.opengl.GLUniformData> GLUniformData[name gcu_ColorStatic, location 1, size 1x3, count 1, data HeapFloatBuffer[pos 0, lim 3, cap 3, remaining 3; array true, direct false, r/w true: 1.0, 1.0, 1.0]]): GL_INVALID_OPERATION ( 1282 0x502),
        at javax.media.opengl.DebugGL3.checkGLGetError(DebugGL3.java:9753)
        at javax.media.opengl.DebugGL3.glUniform(DebugGL3.java:5174)
        at com.jogamp.opengl.util.glsl.ShaderState.uniform(ShaderState.java:952)
        at com.jogamp.graph.curve.opengl.Renderer.setColorStatic(Renderer.java:213)

Seems like there's some issue with the gcu_ColorStatic uniform.
Reply | Threaded
Open this post in threaded view
|

Re: TextRenderer - my text won't show

gouessej
Administrator
If I were you, I would try to run an example (in jogl-demos) using the new text renderer. If it works, then compare this example with your source code, otherwise report a bug against JOGL.

Which example do you use?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: TextRenderer - my text won't show

chakie
I took some code from this:

http://forum.jogamp.org/file/n4029530/TestTextRendering.java

Note that the exception comes due to DebugGL being used. I assume that a normal test would would not notice it unless the text color is changed. I'm still learning so I always use DebugGL.

I'll see if I can get one of the demos working.
Reply | Threaded
Open this post in threaded view
|

Re: TextRenderer - my text won't show

chakie
Hm, the demos are definitely not easy to get running. I'll see if it can be done.
Reply | Threaded
Open this post in threaded view
|

Re: TextRenderer - my text won't show

chakie
The jogl-demos package is broken at least:

com.sun.deploy.net.FailedDownloadException: Unable to load resource: file:/Users/chakie/Downloads/jogl-demos/jnlp-files/DEMO_CODEBASE_TAG/TestTextRenderer.jnlp
        at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
        at com.sun.deploy.net.DownloadEngine.downloadResource(Unknown Source)
        at com.sun.deploy.cache.ResourceProviderImpl.getResource(Unknown Source)
        at com.sun.deploy.cache.ResourceProviderImpl.getResource(Unknown Source)
        at com.sun.javaws.Launcher.updateFinalLaunchDesc(Unknown Source)
        at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
        at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
        at com.sun.javaws.Launcher.launch(Unknown Source)
        at com.sun.javaws.Main.launchApp(Unknown Source)
        at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
        at com.sun.javaws.Main.access$000(Unknown Source)
        at com.sun.javaws.Main$1.run(Unknown Source)
        at java.lang.Thread.run(Thread.java:724)

I'll see if there's a repository with the source, but that means getting it manually compiled on the command line. Not sure what testing the example would actually give, as the error I see is with the shader code or uniform passing that TextRenderer uses.
Reply | Threaded
Open this post in threaded view
|

Re: TextRenderer - my text won't show

gouessej
Administrator
You can use GIT to get the demos from Github. You can easily compile all projects with Ant in command line.

Edit.: Don't run the demos by using the JNLP locally if you don't have the proper references, rather recompile everything or use the online demos.

Edit.2: Have you tried the demo in the top right corner?
http://jogamp.org/deployment/jogamp-current/jogl-test-applets.html
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: TextRenderer - my text won't show

chakie
Seems I'm too dumb for this. I cloned https://github.com/sgothel/jogl-demos but said repository only seems to contain:

jogl-demos/src/demos/j2d/TestTextRenderer.java

which is using the old version. No sample uses com.jogamp.graph.curve.opengl.TextRenderer. I assume there's some other repository somewhere with newer stuff or a branch I don't know about.

Compiling the demos is also not documented anywhere. :)

% cd make
% ant
Buildfile: /Users/chakie/Downloads/jogl-demos/make/build.xml

BUILD FAILED
/Users/chakie/Downloads/jogl-demos/make/build.xml:29: Cannot find /Users/chakie/Downloads/gluegen/make/gluegen-cpptasks.xml imported from /Users/chakie/Downloads/jogl-demos/make/build.xml

Total time: 0 seconds

I'm sorry for wasting your time with this. I'll wait for a later version of JOGL and see if it gets fixed then.
Reply | Threaded
Open this post in threaded view
|

Re: TextRenderer - my text won't show

gouessej
Administrator
You need to get the other dependencies from Github to make it work, i.e at least GlueGen and JOGL.

There are demos using the new renderer here:
https://github.com/sgothel/jogl/tree/master/src/test/com/jogamp/opengl/test/junit/graph/demos

My bug report concerns the legacy renderer. If you find a bug in the new renderer, it won't get fixed if we don't know what is wrong and how to reproduce it.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: TextRenderer - my text won't show

chakie
In reply to this post by gouessej
Aha, the online demos work with Safari, not with Chrome. Yes, I can see that demo just fine and it seems to look exactly like in the screenshot.

If I don't use DebugGL3 to check for errors I don't get the same exception, but I also don't see any text either. Nor anything of my other rendering. The state is somehow broken, but I'll see what I can do.

I would prefer to be able to use DebugGL3 to catch my own errors though.
Reply | Threaded
Open this post in threaded view
|

Re: TextRenderer - my text won't show

gouessej
Administrator
Therefore, there is something wrong in your code, isn't it? I admit that maybe there is something wrong in JOGL when using DebugGL3. Why not talking to Sven and Rami about that on IRC? They implemented this new renderer whereas I only fixed one bug in the legacy renderer.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: TextRenderer - my text won't show

chakie
Oh, there is definitely something wrong in my code that causes all rendering to disappear. I guess that the TextRenderer changes the projection matrix and I simply have to force my camera to reset it afterwards. Now I only do it when the camera actually changes.

The exception however does not come from my code. I could make a bug report about it if I dig a bit deeper into the code.

Reply | Threaded
Open this post in threaded view
|

Re: TextRenderer - my text won't show

chakie
Ok, the reason my own rendering fails to show up was a gl.glEnable(GL_BLEND) in:

https://github.com/sgothel/jogl/blob/master/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java

It's never disabled. I don't know enough OpenGL to grok why that messes up my own very simple rendering, but that was the reason. Still no text on the screen though and I can't find the sources for those new TextRenderer demos. I just don't understand what the parameters are and in what coordinate space they are used.
Reply | Threaded
Open this post in threaded view
|

Re: TextRenderer - my text won't show

gouessej
Administrator
I see what you mean, it should be enabled only when necessary, not always :s Feel free to fill a bug report for the other remaining trouble with DebugGL3. Thank you for your investigations.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: TextRenderer - my text won't show

chakie
I have yet to see any rendered text though. Trying to reverse engineer what the code actually does based on:

https://github.com/sgothel/jogl/blob/master/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java

What I do is basically:

        // get a font
        font = FontFactory.get( FontFactory.JAVA ).getDefault();

        // set up a renderer
        RenderState renderState = RenderState.createRenderState( new ShaderState(), SVertex.factory() );
        renderer = TextRenderer.create( renderState, 0 );

        renderer.init( gl );
       
        renderer.setAlpha( gl, color.alpha );
        renderer.setColorStatic( gl, color.red, color.green, color.blue );

        // disable blending for now, enable when actually rendering text
        gl.glDisable(GL3.GL_BLEND);

And when rendering:

        // re-enable blending
        gl.glEnable( GL3.GL_BLEND );

        // set up any transformation
        renderer.reshapeOrtho( gl, width, height, 1, 10 );
        renderer.resetModelview( gl );

        // TODO: why is this needed, the position is set below
        renderer.translate( gl, 0, 0, 2 );

        // position of the rendered text
        final float[] textPosition = new float[]{ 100, 100, 5 };

        // size of the created texture map. TODO: is this sane?
        final int[] textureSize = new int[]{ 400 };

        // set color
        renderer.setColorStatic( gl, color.red, color.green, color.blue );
        renderer.setAlpha( gl, color.alpha );

        // draw the text
        renderer.drawString3D( gl, font, "Hello world", textPosition, fontSize, textureSize );

        gl.glDisable(GL3.GL_BLEND);

To me it seems like that ought to render my string as for a HUD. The font is valid, the font size too, the color is white with no alpha. Everything seems sane. I also see no warnings or errors in the console. Will dig more.


Reply | Threaded
Open this post in threaded view
|

Re: TextRenderer - my text won't show

chakie
Did a final small test and added a verbose flag to the ShaderState instance that is used:

        RenderState renderState = RenderState.createRenderState( new ShaderState(), SVertex.factory() );

        // more verbosity
        renderState.getShaderState().setVerbose( true );

        renderer = TextRenderer.create( renderState, 0 );
        renderer.init( gl );
        renderer.setAlpha( gl, color.alpha );
        renderer.setColorStatic( gl, color.red, color.green, color.blue );

This causes:

ShaderState: attachShaderProgram: -1 -> 2 (enable: false)
        null
        ShaderProgram[id=2, linked=false, inUse=false, program: 22,
   ShaderCode[id=3, type=VERTEX_SHADER, valid=false, shader:  0, source]
   ShaderCode[id=4, type=FRAGMENT_SHADER, valid=false, shader:  0, source]]

But the output comes only once even if I try to render the same text many times. Something is not right somewhere.

Ok, *now* I'll leave this class in peace to mature a bit. I must get on with other tasks.

Reply | Threaded
Open this post in threaded view
|

Re: TextRenderer - my text won't show

chakie
I noticed that 2.0.2 had been released, I had been using 2.0.2.rc12 from the Maven repos. Doesn't seem to be any difference, still no visible text and no different errors apart from this old one:

ShaderState: attachShaderProgram: -1 -> 2 (enable: false)
        null
        ShaderProgram[id=2, linked=false, inUse=false, program: 25,
   ShaderCode[id=3, type=VERTEX_SHADER, valid=false, shader:  0, source]
   ShaderCode[id=4, type=FRAGMENT_SHADER, valid=false, shader:  0, source]]

But as renderer.getShaderState().linked() returns true when rendering I assume that the shader has been loaded and linked after that error. My current guess is that there's something wrong with the initialization:

        RenderState renderState = RenderState.createRenderState( new ShaderState(), SVertex.factory() );
        renderState.getShaderState().setVerbose( true );
        renderer = TextRenderer.create( renderState, 0 );
        renderer.init( gl );
        renderer.setAlpha( gl, color.alpha );
        renderer.setColorStatic( gl, color.red, color.green, color.blue );

I have no idea what a SVertex does and can't find it in the API docs at http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/ which has me believe those docs aren't up to date right now.

Yup, back to lurk mode for this topic, this was just a quick test with the newest version.
1234