• Advertisement

Archived

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

Picking & gluLookAt()

This topic is 5101 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 have used "Picking"... it'' nice and easy...Do u remember? - glSelectBuffer(BUFSIZE, buff); hits = glRenederMode(GL_SELECT); glInitNames(); .... bla bla ... gluPickMatrix((GLdouble) point.x,(GLdouble)viewport[3] - point.y,5.0,5.0, viewport); ... hits = glRenderMode(GL_RENDER): But what happen when I used gluLookAt(...) before I draw my object - nothing good Evrything is going wrong and I don''t understand what to do - Picking doesn''t work! Does somebody have solution?

Share this post


Link to post
Share on other sites
Advertisement
Are you getting a blank screen? You have to multiply your pick matrix by your projection matrix like so, otherwise you just zoom into that 5 x 5 pick matrix your defining:

glPushMatrix();
glLoadIdentity();
gluPickMatrix((GLdouble) mx, (GLdouble) (viewport[3] - my - 28), 5.0, 5.0, viewport);
gluPerspective(40.0f, (GLfloat)800/600, 0.001f, 1000.0f);
glMatrixMode(GL_MODELVIEW);
DrawGLScene();
glMatrixMode(GL_PROJECTION);
glPopMatrix();

glMatrixMode(GL_MODELVIEW);
hits = glRenderMode(GL_RENDER);

If your running under windowed mode, you may find you need to offset your pick by the menu, hence the -28. Oterwise don''t use the -28.

Share this post


Link to post
Share on other sites
Thanks, I did it.. but my screen is black again
What I do?!
I used my selection(picking) function , to draw with it.When I comment (1) and (2) it works!....
But only without (1) and (2)



GLuint buffer[512];
GLint viewport[4];
GLint hits;

glGetIntegerv(GL_VIEWPORT, viewport);

glSelectBuffer(512, buffer);

// hits = glRenderMode(GL_SELECT);

glInitNames();
glPushName(-1);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
// glLoadIdentity();
//(1) gluPickMatrix((GLdouble) point.x,(GLdouble)viewport[3] - point.y, 5.0, 5.0, viewport);
//(2) gluPerspective(40.0, m_gldAspect, 4, 4000.0);


//Draw House here
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
m_cCamera.Look(); //here is a gluLookAt(...)

pHouse->Draw();

glPopMatrix();
glFlush();

Share this post


Link to post
Share on other sites

  • Advertisement