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!