PDA

View Full Version : glLoadName() - Help



BGwra
09-16-2010, 06:34 PM
Hi,
I am making a game where I create objects pressing a button. And each object is pickable. But my problem is when I pick a single object, all other objects get selected. I just want to select one object at a time.
Here is the code:
// draw an object
for(GLint i=0; i < CubeMesh; i++){
for(GLint j=0; j < CubeName; j++){
glPushMatrix();
glTranslatef(0,0,0);
glLoadName(j);
Cube[i].Draw();
glPopMatrix();
}
}

And the selection is:
for(GLint i=0; i < CubeMesh; i++) {
if(hits) {
int n=0;double minz=buff[1];
for(int j=1;j<hits;j++) {
{
if (buff[1+j*4]<minz) {n=i;minz=buff[1+j*4];}
}
}
Cube[i].selected = true;
}else{
Cube[i].selected = false;
}
}

Thanks in advance.

BGwra
09-17-2010, 05:23 AM
Never mind. got it :-)