hi~,all:
i’ve got an app with which i could edit a planar graph. After selecting a Node with the mouse, modify the Node’s coordinate values in a modeless dialog.
But after modify several Nodes as expected , the view window and the dialog window become fragmentized
. And the debug output window outputs(debug version, i doesn’t run the app in release version):
Warning: Uncaught exception in WindowProc (returning 0).
First-chance exception in Tool.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
WGL Message:WGL: __wglDDrawSwapBuffersBlit: Blt: DDERROR = DDERR_GENERIC
WGL Message:WGL: __wglDDrawSwapBuffersBlit: Blt: DDERROR = DDERR_GENERIC
WGL Message:WGL: __wglDDrawSwapBuffersBlit: Blt: DDERROR = DDERR_GENERIC
WGL Message:WGL: __wglDDrawSwapBuffersBlit: Blt: DDERROR = DDERR_GENERIC
The below are some code pieces supposed to be involved:
void COpenGLView::OnMouseMove(… CPoint point)
{
GLuint nName = 0;
if (select(point, nName))
{
m_nSelName = nName;
…; // hilight the Node named nName.
}
}
void COpenGLView::OnLButtonDblClk(…)
{
m_pModelessDlg->SetSelName(m_nSelName);/m_pModelessDlg’s parent window is the view window./
…; /* valuate the control with the coordinates of Node m_nSelName, so that i can modify the Node.*/
}
void COpenGLView::select(const CPoint& pt, GLuint& nName)
{
CPoint point = pt;
nName = -1;
GLuint* pSelectBuffer = new GLuint[1024];
ASSERT(pSelectBuffer);
// get current matrix status
GLint aiCurrentViewport[4];
glGetIntegerv(GL_VIEWPORT, &aiCurrentViewport[0]);
point.y = aiCurrentViewport[3] - point.y;
// begin select
CDC* pDC = GetDC();
wglMakeCurrent(pDC->GetSafeHdc(), m_hGLContext);
glSelectBuffer(SELECT_BUF_SIZE, pSelectBuffer);
glRenderMode(GL_SELECT);
glInitNames();
glPushName(0);
// transformation
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluPickMatrix(point.x, point.y , 0.1f , 0.1f , &aiCurrentViewport[0]);
glMultMatrixd( &m_adCurrentProjectMatrix[0][0] );
glMatrixMode( GL_MODELVIEW );
glPushMatrix();
glLoadIdentity();
glLoadMatrixd( &m_adCurrentMoldMatrix[0][0] );
// render for selection
draw4Select();/render all the nodes with gluSphere(m_pQuad, …)/
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode( GL_MODELVIEW );
// decode the selection result
GLint nHits = glRenderMode(GL_RENDER);
GLint nNames;
GLuint* pBuffer = pSelectBuffer;
…;
…;
if (pSelectBuffer) delete []pSelectBuffer;
return (nName!=-1);
}
oh~ , the platform: Window2K, msdev 6.0, nvidia card.
Any idea will be deeply appreciated!!