newasun
05-24-2005, 02:16 AM
I have drawn two objects in opengl. I want to select the object by which I can zoom and move each object individually. Following is my code I couldnt get feedback from pick. Is it the right way to do it.
void CViewerView::display()
{
glInitNames();
glPushName(0);
glPushMatrix();
glLoadName(1);
draw_line();
glLoadName(2);
drawTri();
glPopMatrix();
glPopName();
}
void CViewerView::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_RightButtonDown = TRUE;
m_RightDownPos= point;
glGetIntegerv(GL_VIEWPORT,viewport);
glSelectBuffer(BUFSIZE,selectBuf);
glRenderMode(GL_SELECT);
glMatrixMode (GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluPickMatrix ((GLdouble) point.x/100, (GLdouble) point.y/100,1.0, 1.0, viewport);
gluPerspective(30.0, (GLfloat) 10/ (GLfloat) 10, 1.0, 10.0);
glMatrixMode(GL_MODELVIEW);
draw_line();
drawTri();
glPopMatrix ();
glFlush ();
//hits = glRenderMode (GL_RENDER);
//processHits (hits, selectBuf);
//glutPostRedisplay();
CView::OnRButtonDown(nFlags, point);
TRACE2("MOUSE DOWN! x=%d, y=%d\n",hits, point.y);
}
void CViewerView::display()
{
glInitNames();
glPushName(0);
glPushMatrix();
glLoadName(1);
draw_line();
glLoadName(2);
drawTri();
glPopMatrix();
glPopName();
}
void CViewerView::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_RightButtonDown = TRUE;
m_RightDownPos= point;
glGetIntegerv(GL_VIEWPORT,viewport);
glSelectBuffer(BUFSIZE,selectBuf);
glRenderMode(GL_SELECT);
glMatrixMode (GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluPickMatrix ((GLdouble) point.x/100, (GLdouble) point.y/100,1.0, 1.0, viewport);
gluPerspective(30.0, (GLfloat) 10/ (GLfloat) 10, 1.0, 10.0);
glMatrixMode(GL_MODELVIEW);
draw_line();
drawTri();
glPopMatrix ();
glFlush ();
//hits = glRenderMode (GL_RENDER);
//processHits (hits, selectBuf);
//glutPostRedisplay();
CView::OnRButtonDown(nFlags, point);
TRACE2("MOUSE DOWN! x=%d, y=%d\n",hits, point.y);
}