PDA

View Full Version : selection



schailan
06-12-2002, 12:35 AM
hi,

if i create an object as follow:

glNewList(300, GL_COMPILE);
glBegin(GL_QUADS);
glVertex3d(0.0, 0.0, 0.0);
glVertex3d(50.0, 0.0, 0.0);
glVertex3d(50.0, 0.0,50.0);
glVertex3d(0.0, 0.0,50.0);
glEnd();
glEndList();

in order to pick it by mouse, is the following code right:;

glLoadName(0)
glCallList(300);


my pb is that the hit returned is 0, when i invoke glRenderMode(GL_RENDER)

but if i replace my object by glutSolidCube(50), now it works !!!!!

WHY?

another question:

is the selection depending on the texture mapped to the object?
is the selection depending to the location of the camera with gluLookAt, by using the projection transform?

thx!

billy
06-12-2002, 01:00 AM
If you call glLoadName 0 and it returns 0, then I think it is running ok.

schailan
06-12-2002, 02:31 AM
no it's wrong because if it returns , that means no object has been selected!!

albanc
06-13-2002, 07:22 AM
>my pb is that the hit returned is 0, when i invoke glRenderMode(GL_RENDER)
> but if i replace my object by glutSolidCube(50), now it works !!!!!

My guess is that your object isnít effectively drawn under the mouse in selection mode, but your cube, with luck, gets under it.
2 possibilities :
either you havenít rewriten the exact camera code (gluperspective etc..) as when rendering and your object isnít at the same place (object is drawn shifted in selection mode)
or you are not giving the good mouse coordinates (for some obscure reason), and the gluPickMatrix() function doesnít pick at the place you expect it to pick.
I personally met both of these problems !!
A good way to find this out is to control the mouse x and y values, and to draw the selection as a render (commenting //glRenderMode(GL_RENDER) and //gluPickMatrix() ) so you can view exactly how your selection is drawn.
Hope this will help !
Alban