Login  Register

Re: [TextRenderer] Using depth test in 2D mode

Posted by Djak on Dec 21, 2010; 10:01am
URL: https://forum.jogamp.org/TextRenderer-Using-depth-test-in-2D-mode-tp2084831p2125209.html

After some tests, it seems texts are only drawn if their z is between -1, 1.
And depth test seems to not be made.
Anyone got suggestions for what I'm trying to do ?
Here :

code wrote
        gl.glPushMatrix();
        gl.glTranslatef(0, 0, 10);
        gl.glColor3f(0.5f, 0.5f, 0.5f);
       
        // Rectangle
        gl.glBegin(GL.GL_POLYGON);
        gl.glVertex3f(-0.5f, -0.5f, 0);
        gl.glVertex3f(0.5f, -0.5f, 0);
        gl.glVertex3f(0.5f, 0.5f, 0);
        gl.glVertex3f(-0.5f, 0.5f, 0);
        gl.glEnd();  
        gl.glPopMatrix();
               
        this.textRender.beginRendering(640, 480, false);
        this.textRender.draw3D("text", 50, 50, 0.5f, 1);
        this.textRender.endRendering();
text should be behind the rectangle cause it have a lower z and should'nt be drawn, but it is.
Tnahks in advance:)

The environment initialization is something like that :

code wrote
gl.glEnable(GL.GL_DEPTH_TEST);
gl.glViewport(0, 0, 640, 480);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(45, aspect, 0.1f, 10000.0f);
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
...
this.textRender = new TextRenderer(new Font("Arial", Font.PLAIN, 12), true, true);
this.textRender.setColor(1, 0, 0, 1);