Original Post
So, I have the code (which I sort of combined from different websites since none of their code actually worked >.<):
glInitNames(); // Initializes The Name Stack
glPushName(1); // Push 0 (At Least One Entry) Onto The Stack
mainMenu->draw(); // Render The Targets To The Selection Buffer
glPopName();
GLint viewport[4];
GLuint buffer[512];
glSelectBuffer(512,buffer);
glRenderMode(GL_SELECT);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glGetIntegerv(GL_VIEWPORT,viewport);
gluPickMatrix(mouseX,viewport[3]-mouseY,
5,5,viewport);
gluPerspective(45.0f, (GLfloat) (viewport[2]-viewport[0])/(GLfloat) (viewport[3]-viewport[1]), 0.1f, 100.0f);
glMatrixMode(GL_MODELVIEW);
glInitNames();
// restoring the original projection matrix
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glFlush();
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
int hits=glRenderMode(GL_RENDER); // Switch To Render Mode, Find Out How Many
if (hits != 0) // If There Were More Than 0 Hits
{
int choose = buffer[3]; // Make Our Selection The First Object
int depth = buffer[1]; // Store How Far Away It Is
for (int loop = 1; loop < hits; loop++) // Loop Through All The Detected Hits
{
// If This Object Is Closer To Us Than The One We Have Selected
if (buffer[loop*4+1] < GLuint(depth))
{
choose = buffer[loop*4+3]; // Select The Closer Object
depth = buffer[loop*4+1]; // Store How Far Away It Is
}
}
mainMenu->moveY(0.5);
}
The problem is that the 'hits' variable is always 0, apparently, because my mainMenu object is never moved at all :Here is the mainMenu->draw function:
for(int i=0;i<=numberOfObjects;i++)
{
objects.draw();
}
and the object 'objects' drawing function:
glBindTexture(GL_TEXTURE_2D, theTexture.GetID());
for(int i=0;i<=((((numberOfVertices+1)/3)/(numberOfVerticesInAShape+1))-1);i++)
{
shapes.draw();
}
and the object 'shapes' drawing function:
for(int i=0; i<=numberOfVerticesInTheShape; i++)
{
vertices.setZ(vertices.getZ() + addZ);
}
I know that the drawing functions are working fine because when I draw them to the screen, it displays the objects that it is supposed to. Hmmm...I don't know how useful the drawing functions were, but....*shrugs* Any help is appreciated :) -wyrmmage