I am at the end of my rope with doing selection under gl. Right now I am using
the basic gl seleciton technique as follows:
glGetIntegerv(GL_VIEWPORT, viewport);
glSelectBuffer(BUFFER_LENGTH, selectBuff);
glRenderMode(GL_SELECT);
// set up the name stack
glInitNames();
glPushName(0);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluPickMatrix((GLdouble)xPos1, (GLdouble)viewport[3] - yPos1, (GLdouble) 2, (GLdouble) 2, viewport);
// set either orthographic or perspective
// projection
m_activeCamera->setProjection( );
// translate to camera’s position in scene
m_activeCamera->apply( );
// Draw the scene - calling glLoadName before each object drawn.
m_scene->draw( GL_SELECT );
glFlush ( );
// Collect the hits
hits = glRenderMode(GL_RENDER);
… process hits …
The problem is that I am getting inconsistant
results. Sometimes I’ll select nothing and
get all but one of my objects back as hits.
One specific case which is mind boggiling is
where I only have 2 quads in a scene. I click
the bottom one and it returns the correct
GLuint as the picked name in the selection
buffer. I select the top one and i get a
return of 1 hit with no name:
hits = 1;
selectBuff 0x0012f854
[0] 0 - number of names - wtf?
[1] 0 - min z
[2] 0 - max z
[3] 3435973836
I have seen the same results on a G400 and
a geForce 256 under win2k.
Any Ideas? Anyone?
Thanks,
Harley