glEnable(GL_CULL_FACE) + OpenGL's selection buffer problem

Started by
3 comments, last by BytePtr 12 years, 7 months ago
Hi.

Im using OpenGL picking with selection buffer.
Selection Buffer
It seems to work fine until i enable face culling with: glEnable(GL_CULL_FACE);

If it's enabled then it messes up the picking completely. I mean, it returns almost random names.

Im using it to figure out on which side user clicked on simple cube.
Face culling is a MUST HAVE in my project.


So is there some magic OpenGL command that resolves this problem?

EDIT: OK i can review my vertex order when drawing cube to actually make the culling by hand and disable opengl face culling completely when drawing the box but anyway...

Is there a better way?

TIA.
Advertisement

Hi.

Im using OpenGL picking with selection buffer.
Selection Buffer
It seems to work fine until i enable face culling with: glEnable(GL_CULL_FACE);

If it's enabled then it messes up the picking completely. I mean, it returns almost random names.

Im using it to figure out on which side user clicked on simple cube.
Face culling is a MUST HAVE in my project.


So is there some magic OpenGL command that resolves this problem?

EDIT: OK i can review my vertex order when drawing cube to actually make the culling by hand and disable opengl face culling completely when drawing the box but anyway...

Is there a better way?

TIA.


You should not enable face culling which I think is not supported with OpenGL selection buffer - but instead go through result and pick the face (point) with lowest depth associated - this is information the selection buffer is returning.
Ok, i think you're right. + rep.

I once again just to be sure enabled GL_CULL_FACE and it messed up picking.
Then i disabled it and picking works again pretty well.

So im gonna review my vertex "coords" and their order. I had to do this anyway for optimizing the rendering of them so this is the right time to do the both things.
Never knew GL supported the "selection buffer".

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

Ok, i have another question, don't want to create new topic.

The picking works, i can easily detect on which side user clicked. The boxes user clicks are so called "selection boxes". User can "paint" the selection boxes how he wants and edit data in whole that selection.
Selection boxes are textured (basically just green borders with transparency in the middle, so all boxes can be seen through). All boxes have transparency with glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.5);


This causes a problem. Im picking coordinates with gluUnproject which also works fine but it always goes through the transparent selector and picks up coordinate at the "lowest level the user clicked". If i disable transparency, it picks up the first "textured" item.

I mean, let's say texture is transparent except few parts, gluUnproject detects that transparency, it then goes through that transparent "hole" and stops only if it doesn't find any transparency in his way or until it hits the color of background of the scene (glClearColor).

For selection buffer i can tell exactly, to return only the FIRST item clicked. It doesn't go through transparency, but immediately returns the first face user clicked and ignores everything what's behind the other transparent boxes.


How to tell gluUnproject to do the same?
Should i enable/disable something for a moment when picking with gluUnproject?


As far as i have tested gluUnproject picks up only if user clicked on textured or filled quad.
Is there any command that is responsible about changing this behaviour?

This topic is closed to new replies.

Advertisement