• Advertisement


This topic is now archived and is closed to further replies.

Map coord selection in 3d

This topic is 6060 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post

Link to post
Share on other sites

  • Advertisement