Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


glEnable(GL_CULL_FACE) + OpenGL's selection buffer problem


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 BytePtr   Members   -  Reputation: 106

Like
0Likes
Like

Posted 06 September 2011 - 06:43 PM

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.

Sponsor:

#2 Filousov   Members   -  Reputation: 130

Like
1Likes
Like

Posted 07 September 2011 - 02:09 AM

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.

#3 BytePtr   Members   -  Reputation: 106

Like
0Likes
Like

Posted 07 September 2011 - 03:02 PM

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.

#4 dpadam450   Members   -  Reputation: 933

Like
0Likes
Like

Posted 08 September 2011 - 03:53 PM

Never knew GL supported the "selection buffer".

#5 BytePtr   Members   -  Reputation: 106

Like
0Likes
Like

Posted 09 September 2011 - 03:28 AM

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?




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS