help!!

Hi
I’ve implemented double buffering i’ve got
ONCREATE()
glDrawBuffer(GL_BACK); in oncreate() and

SwapBuffers(dc.m_ps.hdc); in OnPaint() but I still get flickering any ideas
DepthBit is set to 32

Thanks

Try to call glFinish() before the SwapBuffers…

It tells OpenGL to finish all pending drawing operations… It returns only when these operations are done… Then it is time to swap !

Eric

I tried that but still no luck

Implement an empty OnEraseBkgnd() event handler to keep GDI from clearing the client area.

I’ve done that but still no change

Post some code or better, e-mail me your code… I’ll try to locate the fault…

Regards

Eric

P.S. : my e-mail is available by clicking the question mark above this message.

wow, what a nice thing to do, eric!

I do it quite often coz’ I have problems trying to locate a fault by reading in the forum… Most of the time, I just compile the app here and debug… I add some of my macros to the project, just to check that the OGL state is correct:

#ifdef _DEBUG
#define ASSERT_GL_ERROR(ProcName) TestGLError(ProcName)
#else
#define ASSERT_GL_ERROR(ProcName)
#endif
void TestGLError(CString ProcName);

////
//* Procedure Name : TestGLError //
//
Parameters … : CString ProcName //
//
Value … : none //
//
Role … : *//
//
//

void TestGLError(CString ProcName)
{

if (wglGetCurrentContext()==NULL)
return;
int iModelviewStackDepth,iMaxModelviewStackDepth;
int iProjectionStackDepth,iMaxProjectionStackDepth;
int iTextureStackDepth,iMaxTextureStackDepth;
int iNameStackDepth,iMaxNameStackDepth;
CString AllErrors="",strError;
GLenum GL_Error;
do
{
GL_Error=glGetError();
switch (GL_Error)
{
case GL_NO_ERROR:
break;
case GL_INVALID_ENUM:
AllErrors+="GL_INVALID_ENUM
";
break;
case GL_INVALID_VALUE:
AllErrors+="GL_INVALID_VALUE
";
break;
case GL_INVALID_OPERATION:
AllErrors+="GL_INVALID_OPERATION
";
break;
case GL_STACK_OVERFLOW:
AllErrors+="GL_STACK_OVERFLOW
“;
glGetIntegerv(GL_MODELVIEW_STACK_DEPTH,&iModelviewStackDepth);
glGetIntegerv(GL_MAX_MODELVIEW_STACK_DEPTH,&iMaxModelviewStackDepth);
glGetIntegerv(GL_PROJECTION_STACK_DEPTH,&iProjectionStackDepth);
glGetIntegerv(GL_MAX_PROJECTION_STACK_DEPTH,&iMaxProjectionStackDepth);
glGetIntegerv(GL_TEXTURE_STACK_DEPTH,&iTextureStackDepth);
glGetIntegerv(GL_MAX_TEXTURE_STACK_DEPTH,&iMaxTextureStackDepth);
glGetIntegerv(GL_NAME_STACK_DEPTH,&iNameStackDepth);
glGetIntegerv(GL_MAX_NAME_STACK_DEPTH,&iMaxNameStackDepth);
strError.Format(“Modelview Stack Depth : %i / %i”,iModelviewStackDepth,iMaxModelviewStackDepth);
AllErrors+=strError+”
“;
strError.Format(“Projection Stack Depth : %i / %i”,iProjectionStackDepth,iMaxProjectionStackDepth);
AllErrors+=strError+”
“;
strError.Format(“Texture Stack Depth : %i / %i”,iTextureStackDepth,iMaxTextureStackDepth);
AllErrors+=strError+”
“;
strError.Format(“Name Stack Depth : %i / %i”,iNameStackDepth,iMaxNameStackDepth);
AllErrors+=strError+”
";
break;
case GL_STACK_UNDERFLOW:
AllErrors+="GL_STACK_UNDERFLOW
“;
glGetIntegerv(GL_MODELVIEW_STACK_DEPTH,&iModelviewStackDepth);
glGetIntegerv(GL_MAX_MODELVIEW_STACK_DEPTH,&iMaxModelviewStackDepth);
glGetIntegerv(GL_PROJECTION_STACK_DEPTH,&iProjectionStackDepth);
glGetIntegerv(GL_MAX_PROJECTION_STACK_DEPTH,&iMaxProjectionStackDepth);
glGetIntegerv(GL_TEXTURE_STACK_DEPTH,&iTextureStackDepth);
glGetIntegerv(GL_MAX_TEXTURE_STACK_DEPTH,&iMaxTextureStackDepth);
glGetIntegerv(GL_NAME_STACK_DEPTH,&iNameStackDepth);
glGetIntegerv(GL_MAX_NAME_STACK_DEPTH,&iMaxNameStackDepth);
strError.Format(“Modelview Stack Depth : %i / %i”,iModelviewStackDepth,iMaxModelviewStackDepth);
AllErrors+=strError+”
“;
strError.Format(“Projection Stack Depth : %i / %i”,iProjectionStackDepth,iMaxProjectionStackDepth);
AllErrors+=strError+”
“;
strError.Format(“Texture Stack Depth : %i / %i”,iTextureStackDepth,iMaxTextureStackDepth);
AllErrors+=strError+”
“;
strError.Format(“Name Stack Depth : %i / %i”,iNameStackDepth,iMaxNameStackDepth);
AllErrors+=strError+”
";
break;
case GL_OUT_OF_MEMORY:
AllErrors+="GL_OUT_OF_MEMORY
";
break;
default:
AllErrors+=“Unknown GL_ERROR
“;
break;
}
}
while (GL_Error!=GL_NO_ERROR);
if (AllErrors!=””)
AfxMessageBox("Procedure : “+ProcName+”
"+AllErrors);

}

By the way, fox, I received your e-mail and I will try to debug it asap (I need to build some kind of app that will use your CView class !)

Regards.

Eric

I’ve sent you a project - see what you make of it

Eric

Can you explain the code above?
How could I use (for error checking?)

Thanx

Originally posted by fox:
[b]I tried that but still no luck

[/b]

Instead of just doing an empty OnEraseBkgnd, have it return TRUE. The default implementation will erase the background using the default brush. If you return TRUE, it tells the framework that you handled the OnEraseBkgnd yourself and it should do no further erasing.