Text Rendering to JOGL2

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

Text Rendering to JOGL2

tami
I am desperate here.  I am a casual JAVA/JOGL programmer, since my main programming responsibilities are in other languages.  However, I have developed a java/jogl application that will be useful to my clients in a relatively small amount of time.  

Recently, I realized I must port it to JOGL2 and I did that pretty easily, got the javaws working and all was well except for text rendering.  

I have now spent a ridiculous amount of time trying to figure out how to render a word to an opengl frame.  It seems like you need a shader, a shader program, a render state, etc., etc.  What used to take 5 lines of code now seems like it will take I don't know how many lines!!  Please help.
Reply | Threaded
Open this post in threaded view
|

Re: Text Rendering to JOGL2

Sven Gothel
Administrator
On Wednesday, December 28, 2011 09:34:44 PM tami [via jogamp] wrote:

>
> I am desperate here.  I am a casual JAVA/JOGL programmer, since my main
> programming responsibilities are in other languages.  However, I have
> developed a java/jogl application that will be useful to my clients in a
> relatively small amount of time.  
>
> Recently, I realized I must port it to JOGL2 and I did that pretty easily,
> got the javaws working and all was well except for text rendering.  
>
> I have now spent a ridiculous amount of time trying to figure out how to
> render a word to an opengl frame.  It seems like you need a shader, a shader
> program, a render state, etc., etc.  What used to take 5 lines of code now
> seems like it will take I don't know how many lines!!  Please help.

Maybe you like to use the 'old' text renderer until
we have reviewed and enhance the API for the new one
and since it seems to be too complicated for your case.

Nevertheless, setting up the RenderState etc is a simple
'few line' experience if nothing else but rendering text is desired.
See the UIShape impl. etc.

We hope that an upcoming review can simplify and clarify those steps
and to find the balance between flexible/generic and simple.

~Sven
Reply | Threaded
Open this post in threaded view
|

Re: Text Rendering to JOGL2

tami
Hi Sven,

By UiShape impl, do you mean this guy?  

     http://jausoft.com/git/?p=jogl.git;a=blob;f=src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIShape.java;h=7e3d267750031b9d20e8bee0000ff5f2a87bfd52;hb=4ccf5ed0cc14743a3a97d7b0dcc61e839d263a1a

I'd really like to stick with JOGL2.  Is there some simple example out there that has a GL2 canvas and then renders something to it in 3d?

Thanks for your reply,
Tami
Reply | Threaded
Open this post in threaded view
|

Re: Text Rendering to JOGL2

tami
Oops ... renders not just "something," but some text!  Sorry!
Reply | Threaded
Open this post in threaded view
|

Re: Text Rendering to JOGL2

Sven Gothel
Administrator
In reply to this post by tami
On Wednesday, December 28, 2011 10:38:46 PM tami [via jogamp] wrote:
>
> Hi Sven,
>
> By UiShape impl, do you mean this guy?  
>
>    
> http://jausoft.com/git/?p=jogl.git;a=blob;f=src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIShape.java;h=7e3d267750031b9d20e8bee0000ff5f2a87bfd52;hb=4ccf5ed0cc14743a3a97d7b0dcc61e839d263a1a

Well, this one is the base class for our experimental UI stuff .. yes.

http://jausoft.com/git/?p=jogl.git;a=blob;f=src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java;hb=HEAD#l151

Shows how you can 'simply' render the FPS to the screen.

Since these 'graph' demos are complicated, ie. use a lot of OO stuff
and since many people requested a more simple demo,
I will write smaller ones - probably when starting the review of our API.
I can't tell when I can do it, but probably before mid January,
depends on other work items.

>
> I'd really like to stick with JOGL2.  Is there some simple example out there
> that has a GL2 canvas and then renders something to it in 3d?
>

This test is using the old AWT and 'bitmapped' based text renderer:
  http://jausoft.com/git/?p=jogl.git;a=blob;f=src/test/com/jogamp/opengl/test/junit/jogl/awt/text/TestAWTTextRendererUseVertexArrayBug464.java;hb=HEAD

~Sven
Reply | Threaded
Open this post in threaded view
|

Re: Text Rendering to JOGL2

tami
> Since these 'graph' demos are complicated, ie. use a lot of OO stuff
and since many people requested a more simple demo,
I will write smaller ones - probably when starting the review of our API.
I can't tell when I can do it, but probably before mid January,
depends on other work items.

Yay!  That would be great!!  How will we know when it's ready and where to find it?  Thanks so much!
Reply | Threaded
Open this post in threaded view
|

Re: Text Rendering to JOGL2

tami
Sven,

I decided I just couldn't wait on this, so I am really trying to figure out these demos - all so I can just render text!!

Anyway, no matter which way I turn, I keep running into the same runtime NPE whenever I need to use gl as far as textrenderer is concerned:

....
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*** 2.1 (compatibility profile, any, new) - 2.1 APPLE-1.6.36
*** GLDebugMessage false
Matrix: -10.0/10.0 x-70.0 @0.0
Reshape: null
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.jogamp.graph.curve.opengl.Renderer.setColorStatic(Renderer.java:205)
at org.yourorghere.GPUTextRendererListenerBase01.display(GPUTextRendererListenerBase01.java:153)
at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:174)
at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:162)
....

This is the section of code and it's failing on the setColorStatic:

    public void display(GLAutoDrawable drawable) {
        final int width = drawable.getWidth();
        final int height = drawable.getHeight();
        GL2ES2 gl = drawable.getGL().getGL2ES2();
        
        gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); // Demo02 needs to have this set here as well .. hmm ?
        gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

        final TextRenderer textRenderer = (TextRenderer) getRenderer();
        //textRenderer.reshapeOrtho(null, width, height, 0.1f, 7000.0f);
        textRenderer.setColorStatic(gl, 0.0f, 0.0f, 0.0f);
        final GLAnimatorControl animator = drawable.getAnimator();
        final boolean _drawFPS = drawFPS && null != animator && animator.getTotalFPSFrames()>10;
        
Could the libraries I'm using be wrong or something?

Ugh!  :-(




On Wed, Dec 28, 2011 at 5:23 PM, tami [via jogamp] <[hidden email]> wrote:
> Since these 'graph' demos are complicated, ie. use a lot of OO stuff
and since many people requested a more simple demo,
I will write smaller ones - probably when starting the review of our API.
I can't tell when I can do it, but probably before mid January,
depends on other work items.

Yay!  That would be great!!  How will we know when it's ready and where to find it?  Thanks so much!


If you reply to this email, your message will be added to the discussion below:
http://forum.jogamp.org/Text-Rendering-to-JOGL2-tp3617263p3617464.html
To unsubscribe from Text Rendering to JOGL2, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Text Rendering to JOGL2

Wade Walker
Administrator
Hi Tami,

I just verified on my system (Win 7 64-bit) that the TestAWTTextRendererUseVertexArrayBug464.java example listed by Sven above seems to work fine for me (I just pasted the code verbatim into a file, fixed an import, and ran it). Are you running the above example, or something else of your own devising? Also, it might help if you listed your platform and graphics card.
Reply | Threaded
Open this post in threaded view
|

Re: Text Rendering to JOGL2

tami
Hi Wade,

Initially, before porting to JOGL2, I happily used this sort of thing to render text:

    public void initTextRenderer() {
        Font font = new Font("SansSerif", Font.BOLD, 14);
        textRenderer = new TextRenderer(font, true, false) {};
    }
...
                        textRenderer.begin3DRendering();
                        textRenderer.draw3D(pps, 0, 0, 0, 0.007f);
                        textRenderer.drawString3D(gl, null, pps, xrot, VW, VW);
                        textRenderer.end3DRendering();
                        
It was great.  Now, it looks like that doesn't work anymore.  So, I've been trying to figure out what will work.

> TestAWTTextRendererUseVertexArrayBug464.java example listed by Sven above seems to work fine for me (I just pasted the code verbatim into a file, fixed an import, and ran it).  Are you running the above example, or something else of your own devising? 


I know I'm a little clueless here, so I do apologize for needing help.  My idea was that if I added your classes (GPURendererListenerBase01, GPUTextGLListener0A, and GPUTextRendererListenerBase01) to my project, that I should be able to somehow call/use GPUTextRendererListenerBase01 to render to a canvas.  I can get everything to compile, but I really don't know how to implement that GPUTextRendererListenerBase01 class.  I tried this sort of thing:

canvas6.addGLEventListener(new GPUTextRendererListenerBase01(null,1,false,false) {});

... but that's what's giving me the NPE.

I'm just having a really hard time believing it is this hard to just put text at a point in 3d space on a glcanvas.

Am I going in the totally wrong direction?  I must be!!

>Also, it might help if you listed your platform and graphics card. 
Mac OS X 10.6.8
Intel HD Graphics 3000
Java SE 6 1.6.0_29-b11-402
And I got the libraries I'm using from:  http://jogamp.org/deployment/jogamp-current/archive/

I truly appreciate any help at all.  This stuff has gotten very complex!

Thanks,
Tami


On Fri, Dec 30, 2011 at 6:21 PM, Wade Walker [via jogamp] <[hidden email]> wrote:
Hi Tami,

I just verified on my system (Win 7 64-bit) that the TestAWTTextRendererUseVertexArrayBug464.java example listed by Sven above seems to work fine for me (I just pasted the code verbatim into a file, fixed an import, and ran it). Are you running the above example, or something else of your own devising? Also, it might help if you listed your platform and graphics card.



If you reply to this email, your message will be added to the discussion below:
http://forum.jogamp.org/Text-Rendering-to-JOGL2-tp3617263p3622097.html
To unsubscribe from Text Rendering to JOGL2, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Text Rendering to JOGL2

Wade Walker
Administrator
I just verified that this works on OS X 1.7.1 too, just to be sure. All you have to do is take the text from this page:

http://jausoft.com/git/?p=jogl.git;a=blob_plain;f=src/test/com/jogamp/opengl/test/junit/jogl/awt/text/TestAWTTextRendererUseVertexArrayBug464.java;hb=HEAD

Just cut and paste it into a new file (changing the package to fit your workspace), and add

import com.jogamp.opengl.test.junit.jogl.awt.text.TextRendererGLEventListener01;

since it's not in the test package anymore.

If this runs on your system, then you can gradually morph it (in a working state) until it does what you want