PDA

View Full Version : help!!



fox
10-22-2000, 11:54 PM
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

Eric
10-23-2000, 12:47 AM
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

fox
10-23-2000, 05:52 AM
I tried that but still no luck

Relic
10-23-2000, 06:42 AM
Implement an empty OnEraseBkgnd() event handler to keep GDI from clearing the client area.

fox
10-24-2000, 11:24 PM
I've done that but still no change

Eric
10-25-2000, 12:45 AM
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.

Succinct
10-26-2000, 09:17 AM
wow, what a nice thing to do, eric!

Eric
10-26-2000, 10:15 PM
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\n";
break;
case GL_INVALID_VALUE:
AllErrors+="GL_INVALID_VALUE\n";
break;
case GL_INVALID_OPERATION:
AllErrors+="GL_INVALID_OPERATION\n";
break;
case GL_STACK_OVERFLOW:
AllErrors+="GL_STACK_OVERFLOW\n";
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+"\n";
strError.Format("Projection Stack Depth : %i / %i",iProjectionStackDepth,iMaxProjectionStackDepth);
AllErrors+=strError+"\n";
strError.Format("Texture Stack Depth : %i / %i",iTextureStackDepth,iMaxTextureStackDepth);
AllErrors+=strError+"\n";
strError.Format("Name Stack Depth : %i / %i",iNameStackDepth,iMaxNameStackDepth);
AllErrors+=strError+"\n";
break;
case GL_STACK_UNDERFLOW:
AllErrors+="GL_STACK_UNDERFLOW\n";
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+"\n";
strError.Format("Projection Stack Depth : %i / %i",iProjectionStackDepth,iMaxProjectionStackDepth);
AllErrors+=strError+"\n";
strError.Format("Texture Stack Depth : %i / %i",iTextureStackDepth,iMaxTextureStackDepth);
AllErrors+=strError+"\n";
strError.Format("Name Stack Depth : %i / %i",iNameStackDepth,iMaxNameStackDepth);
AllErrors+=strError+"\n";
break;
case GL_OUT_OF_MEMORY:
AllErrors+="GL_OUT_OF_MEMORY\n";
break;
default:
AllErrors+="Unknown GL_ERROR\n";
break;
}
}
while (GL_Error!=GL_NO_ERROR);
if (AllErrors!="")
AfxMessageBox("Procedure : "+ProcName+"\n"+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

fox
10-27-2000, 05:30 AM
I've sent you a project - see what you make of it

fox
10-27-2000, 05:32 AM
Eric

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

Thanx

Deiussum
10-27-2000, 05:35 AM
Originally posted by fox:
I tried that but still no luck



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.