I have picking set up, using the tutorial on gametutorials.com. I render a simple set of quads, and assign one id to all of them (for ease). This is how I do it.
glInitNames();
glPushName(0);
glLoadName(100);
Then, I draw the vertices to assign them to that ID.
for(int y=0; y<MAP_SIZEY; y=y+2)
{
for(int x=0; x<MAP_SIZEX; x=x+4)
{
this->TileTexID = this->Map[x>>4][y>>2];
glBindTexture(GL_TEXTURE_2D, MapTexture.g_Texture[this->TileTexID]);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 1.0f); glVertex3f(float(x), float(y - 1), 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(float(x + 2), float(y), 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(float(x + 4), float(y - 1), 0.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(float(x + 2), float(y - 2), 0.0f);
glEnd();
}
}
Then...
glEnd(); // I call this again, to stop all drawing to the ID.
glPopName();
In my mouse function, I use the exact same function used in gametutorials, to return the id of the object that was clicked. I call it when the mouse button is pressed.
What happens is, the function always returns zero, instead of the id I want. I am thinking it may have something to do with either the way I am drawing the tiles, or my camera function. Every frame, my camera calls gluLookat. I then change the variables of the position, when the user presses an arrow in a certain direction.
Any help is greatly appreciated.
Thanks