Hi Gurus,
I encounter a problem on drawing my OpenGL models smoothly in VC++ with MFC applications…
I have read alot of references and examples and am pretty sure that my OpenGL settings are all correct. NOTE, the buffers are clear and my models are drawn ONCE per frame… however, there’s a ghost view of the previous frames appear on my current frame… In the other words, what i see is that the models are drawn twice and the geometries of them are slightly apart while i do the navigation… Can anyone help me out…
Thanks a million!!!
The following is the sample codes
CView::KeyDown
{
// one of the case that i update my drawings
if (leftArrowKey)
myposition.x+=1.0
InvalidateRect(NULL);
}
CView::OnPaint()
{
CPaintDC dc(this); // device context for painting
RenderScene()
}
CView::RenderScene()
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f) ;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT|GL_ACCUM_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST );
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-m_ClipSize,m_ClipSize,-m_ClipSize,m_ClipSize,1.0, 5000.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(…);
glDrawBuffer(GL_BACK);
glPushMatrix()
// THis is where i draw my models
glLoadIdentity();
glTranslatef(myposition.x, myposition.y, myposition.z);
DrawModels();
glPopMatrix();
SwapBuffer(hdc);
}