Refresh problems under Win32

Hopefully a very simple problem I’m having. I almost copied verbatim the COpenGLView class in the Win32 documentation and have a subclass of that, which I am using in my program.

The problem is that the screen isn’t always refreshing. When it occurs is completely random and (here at work) it doesn’t happen on every machine. My OnDraw() function in COpenGLView looks like this:

if (MakeCurrent())
{
if (buffering) glDrawBuffer(GL_BACK);
else glDrawBuffer(GL_FRONT);

glClearColor(1.0,1.0,1.0,1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

OnRender(pDC);

glFlush();
glFinish();

// Swap buffers if double buffering
if (buffering)
{
wglSwapLayerBuffers(m_pDC->GetSafeHdc(),WGL_SWAP_MAIN_PLANE);
}
}

The if (buffering) is there, because the only fix to the problem seems to be just rendering straight to the front buffer (ick).

If anyone else has had this problem, or can see what the error of my ways is, please pass it along

Thanks in advance, Jeff!

“Do, or do not; there is no try” - Master Yoda