Hi !
I have a problem with selection buffer.
I’m drawing a grid of rectangles but when I click on the grid Opengl sets the number of hits to 1 and the number of the object hit is always 0
Here’s the code:
void Mouse3D(int mouseX,int mouseY,Vector& v1,Vector& v2)
{
GLuint selectBuff[64];
GLint hits, viewport[4];
glSelectBuffer(64, selectBuff);
glGetIntegerv(GL_VIEWPORT, viewport);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glRenderMode(GL_SELECT);
glLoadIdentity();
gluPickMatrix(mouseX, viewport[3]-mouseY, 2, 2, viewport);
gluPerspective(45.0f,(GLfloat)800/(GLfloat)600,1.0f,1000.0f);
glMatrixMode(GL_MODELVIEW);
camera.Set();
bf.DrawCases();
hits = glRenderMode(GL_RENDER);
if(hits > 0)
index = selectBuff[3];
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
}
bf.drawCases draws the grid. Each rectangle has one different color and one name with LoadName(numRect);
Thanks