We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › transparent QUAD texture issue
Page Index Toggle Pages: 1
transparent QUAD texture issue (Read 857 times)
transparent QUAD texture issue
May 15th, 2009, 9:54am
 
I am trying to render a very simple tree by using a tree texture with transparency and rendering it along the x and y axis. But if I render something else behind it after, it doesn't work.

This is because of the way the z-buffer works, and in C++ I could do glDepthMask(GL_FALSE), render the two QUADS, and then call glDepthMask(GL_TRUE).

I tried doing this in Processing like this-
Code:
PGraphicsOpenGL pgl = (PGraphicsOpenGL) g;
   GL gl = pgl.beginGL();
   gl.glDepthMask(false);
   pushMatrix();
   translate( loc.x, loc.y, loc.z );

    beginShape( QUADS );
    texture( tree );
    vertex( 0, -30, 0, 0, 1 );
    vertex( 0, 30, 0, 1, 1 );
    vertex( 0, 30, 60, 1, 0 );
    vertex( 0, -30, 60, 0, 0 );
   
    vertex( -30, 0, 0, 0, 1 );
    vertex( 30, 0, 0, 1, 1 );
    vertex( 30, 0, 60, 1, 0 );
    vertex( -30, 0, 60, 0, 0 );
    endShape();
   
    popMatrix();
    gl.glDepthMask(true);
    pgl.endGL();


But the trees don't appear. If i remove pgl.endGL(), the trees appear fine, but I get a whole slew of other errors.

Am I allowed to call processing GL statements within beginGL(), and if so, why aren't my trees appearing?

Thanks!
Re: transparent QUAD texture issue
Reply #1 - May 15th, 2009, 10:06am
 
Guess I posted too soon. Here is the solution.

Code:
PGraphicsOpenGL pgl = (PGraphicsOpenGL) g; 
GL gl = pgl.beginGL();
gl.glDisable( GL.GL_DEPTH_TEST );
pgl.endGL();
pushMatrix();
translate( loc.x, loc.y, loc.z );

beginShape( QUADS );
texture( tree );
vertex( 0, -30, 0, 0, 1 );
vertex( 0, 30, 0, 1, 1 );
vertex( 0, 30, 60, 1, 0 );
vertex( 0, -30, 60, 0, 0 );

vertex( -30, 0, 0, 0, 1 );
vertex( 30, 0, 0, 1, 1 );
vertex( 30, 0, 60, 1, 0 );
vertex( -30, 0, 60, 0, 0 );
endShape();

popMatrix();
gl = pgl.beginGL();
gl.glEnable( GL.GL_DEPTH_TEST );
pgl.endGL();
Page Index Toggle Pages: 1