TextRenderer is hiding somewhere

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

TextRenderer is hiding somewhere

Aksenov239
Hello. This time I've tried to use the simplest example possible even using TextRenderer. Somehow when I translate it doesn't show anything. Here is the code.

    TextRenderer renderer;
    public void init(GLAutoDrawable drawable) {
        GL2 gl = drawable.getGL().getGL2();

        glu = new GLU();
        gl.glClearDepth(1f);
        gl.glEnable(GL.GL_DEPTH_TEST);
        gl.glDepthFunc(GL.GL_LEQUAL);
        gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL2.GL_NICEST);
        gl.glShadeModel(GLLightingFunc.GL_SMOOTH);

        renderer = new TextRenderer(Font.decode("Open Sans 18"));
    }

   public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
        GL2 gl = drawable.getGL().getGL2();
        if (height == 0) height = 1;
        gl.glViewport(0, 0, width, height);

        gl.glMatrixMode(GL2.GL_PROJECTION);
        gl.glLoadIdentity();
        gl.glOrtho(0, width, 0, height, 0, 1);

        gl.glMatrixMode(GL2.GL_MODELVIEW);
        gl.glLoadIdentity();
   }

    public void display(GLAutoDrawable drawable) {
        GL2 gl = drawable.getGL().getGL2();
        gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
        gl.glLoadIdentity();

        gl.glTranslatef(0.1f, 0, 0);
        renderer.begin3DRendering();
        renderer.setColor(1, 1, 1, 1);
        renderer.draw("TestTestTest", 0, 0);
        renderer.endRendering();
   }

If in display I call gl.glTranslatef(0, 0, 0) - I see "TestTestTest" in the bottom of the screen, while using gl.glTranslatef(0.1f, 0, 0) or gl.glTranslatef(1f, 0, 0) there is nothing shown. It seems, there are some problems with projection but I do not know what. Can you help me?

Thanks in advance.
Vitaly Aksenov
Reply | Threaded
Open this post in threaded view
|

Re: TextRenderer is hiding somewhere

gouessej
Administrator
Use begin3DRendering() with end3DRendering() instead of endRendering().
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: TextRenderer is hiding somewhere

Aksenov239
Thank you for pointing out! Now it seems to work as expected.

AV