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 › Problem with hint(DISABLE_DEPTH_TEST)
Page Index Toggle Pages: 1
Problem with hint(DISABLE_DEPTH_TEST) (Read 712 times)
Problem with hint(DISABLE_DEPTH_TEST)
Jun 13th, 2008, 5:24pm
 
Hello,

I'm trying to to use hint(DISABLE_DEPTH_TEST) to draw directly to the screen, however it's not having any effect unless I call camera() before it, which messes up how my sketch looks. The text I'm trying to draw on the screen appears in the model.

A few details:
I'm using OPENGL, and the Obsessive Camera Direction library with Processing 133. I'm on a Mac G5 with a discrete graphics card. My code looks like this:

MyPApplet.hint(PApplet.DISABLE_DEPTH_TEST);
MyPApplet.fill(255);
MyPApplet.textSize(15f);
MyPApplet.text(mousepos, 10, 10);

MyPApplet.unhint(PApplet.DISABLE_DEPTH_TEST);

(Note that I'm calling this in the draw function of a class: MyPApplet refers to my processing applet.)

Could this be a problem with using the OCD library? Any ideas? Thanks.


Re: Problem with hint(DISABLE_DEPTH_TEST)
Reply #1 - Jun 19th, 2008, 11:04am
 
If I remember correctly you need to reset the camera for the things to stick to your screen and not be placed "in the world" so to speak.

What I did for my simple 3dengine was this, just before writing the gui elements.

   ((PGraphicsOpenGL)g).gl.glClear(GL.GL_DEPTH_BUFFER_BIT);
   camera();

How are you using OCD in your program?
Re: Problem with hint(DISABLE_DEPTH_TEST)
Reply #2 - Jun 19th, 2008, 9:20pm
 
Well, with a bit of toying around, I got this working. It seems like a bit of a hack, but it works smoothly enough in my initial tests:

// Store your OCD camera's position and target in variables. I'm not showing it here, but I have them as Vec3D objects (Toxi's Library).

// Reset the camera
camera();
// Disable Depth Test
hint(DISABLE_DEPTH_TEST);
// Do your thing
fill(255);
rect(width/2, height/2, 30,30);
// Enable Depth Test
unhint(DISABLE_DEPTH_TEST);
// Set the camera to where you had it.
camera(position.x, position.y, position.z,  target.x, target.y, target.z, 0, 1, 0);

This works even if you change the OCD camera's FOV, which I can't explain. If someone has a better way to do this, please post.
Re: Problem with hint(DISABLE_DEPTH_TEST)
Reply #3 - Jun 23rd, 2008, 7:08pm
 
Well, I didn't test this well enough. It's drawing my rect where it should be on the screen, but behind everything else. Anyone have any ideas?
Page Index Toggle Pages: 1