I''m trying to easily use OpenGL selection buffer to pick out points on a map. I''m not sure how easy this is as I''ve never made selection to work but basically I found a little page that said what I was doing should work, here''s the code:
glSelectBuffer(128, buffer); /* initialize */
glRenderMode(GL_SELECT);
glInitNames();
glPushName(-1);
glGetIntegerv(GL_VIEWPORT,viewport); /* set up pick view */
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluPickMatrix(Ms[X_],viewport[3] - Ms[Y_], 2, 2,viewport);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRotatef(rt[Y_], 0.0f, 1.0f, 0.0f);
GlRotatef(rt[X_], 1.0f, 0.0f, 0.0f);
glRotatef(rt[Z_], 0.0f, 0.0f, 1.0f);
glTranslatef(-loc[X_], -loc[Y_] - 2.0f, -loc[Z_]);
glBegin(GL_POINTS);
for (int y = 0; y < MAXMAPSIZE - 1; y++)
{
glPushName(y + 1);
for (int x = 0; x < MAXMAPSIZE - 1; x++)
{
glPushName(x + 1);
glLoadName(1); // not 100% sure about this one
glVertex3fv(Points[x][y]);
glPopName();
}
glPopName();
}
glEnd();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
hits = glRenderMode(GL_RENDER);
Hits is always 0. If anyone, can help me, is there some huge important step that I''m missing and no one ever explains or something.
Map coord selection in 3d
Started by Kudaba, Jun 19 2001 06:30 AM
No replies to this topic






