PDA

View Full Version : strange problem in drawing my models right



Swe
03-12-2003, 04:11 PM
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);
}

shinpaughp
03-12-2003, 05:32 PM
I didn't see anything that looked like it was swapping the buffers twice or would cause that effect, but then could be elsewhere in your code. You may want to use find/search to see if there is another occurance of SwapBuffers within your code even other files. Maybe you accidentally embedded it into your keyboard code or update function.

Could just be your monitor. Is it a CRT or an LCD? My monitor is pretty cheap and the phosphors don't have a quick reset time so to speak. Not sure about the terminology of this. I had worse effects if I remember correctly on my laptop LCD.

If you can, post a link to your executable or show more code if you still can't find the problem.

Those are my thoughts at least.

Good luck. Hope you find the problem.