PDA

View Full Version : strange selection



Loursi
07-18-2001, 09:38 PM
I am writting a program where user can conduct 3-d sylinder selection, the problem is that to select the cylinder, the mouse

should be pointed higher rather than the screen image, the code is as following, pls help to figure out what's going wrong?
///////////////////////////////////////
void CHoleLogView::ProcessSelect(CPoint point)
{

GLuint selectBuf[BUFSIZE];
GLint hits;
GLint viewport[4];
int xPos=point.x;
int yPos=point.y;
CClientDC pDC(this);
wglMakeCurrent(pDC.m_hDC, m_hRC);
glGetIntegerv(GL_VIEWPORT, viewport);
glSelectBuffer(BUFSIZE, selectBuf);
glRenderMode(GL_SELECT);


glInitNames();
glPushName(0);


///////////////////////////////////////

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluPickMatrix(xPos, (viewport[3]-yPos),5.0,5.0,viewport);
glOrtho(m_minXScope*2.5,m_maxXScope*2.5,m_minZScop e*1.2,15.0,2.0,5.0*m_distance);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(m_xEye, m_yEye, m_zEye,m_xAt,m_yAt,m_zAt,0.0,0.0,1.0);

DrawSegments(GL_SELECT);



hits=glRenderMode(GL_RENDER);

Proces****s(hits, selectBuf);


glPopMatrix();

wglMakeCurrent(NULL, NULL);
Invalidate();
}

Pat
07-19-2001, 08:55 AM
Do your parameters in the glOrtho function match exactly what you had setup for the projection matrix before you entered this function?

Maybe the projection matricies are slightly different when you are picking which would cause the hits to occur slightly offset from where you expect...