Flickering

Ok people before I go any further I am going to tell you about my hardware… I have a (Try not to gasp too hard on this one) 133mhz P with MMX stuff. Now on to my problem. What happens is, every time I draw a scene with animation, my objects flicker, even simple objects. However an OpenGL example that had Textured(!!!) blocks did not flicker at all and took 2 seconds to load. The way I do it, it takes a lot of time to just create a plane. Any suggestions?

the following assumes you are using a windows api:

depending on what your code is built on (eg. win32 or mfc), it could be that you didn’t tell windows not to erase the background, instead of letting opengl take care of itself.

for example: (using win32)
when you register the window class, you set the background brush to NULL and let glClearColor set it to black (or whatever color is your background)

or: (using mfc)
in the view class, an additional class function is needed:

BOOL COGLView::OnEraseBkgnd(CDC* pDC)
{
return TRUE; // opengl will erase the background, not windows
}
along, of course with the required WM_ message stuff.

Hmf, when you chose the PixelFormat to use for you GL window, did you set the PDF_DOUBLEBUFFER flag ?

It not, you should add this flag to your PIXELFORMATDESCRIPTOR structure, and call SwapBuffers on the appropriate hDC when every call to GL primitive is finished.

That should fix the stuff up.

Ok, I found all this stuff to be windows oriented. I want to do this for windows but (yah I know it’s only for educational purposes) is there a way to do this with glut? Personally I’d rather create a window with about 3 lines of code .

cwhite40

I’m not sure what you’re asking but could it be the case that you want to set double buffering using GLUT?

if thats the case then just call

glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);

these are probably the most used constants. they provide animantion, true color + alpha channel, and depth buffer.

If you need more info check out my GLUT tutorial at
www.fatech.com/tech/opengl/glut

Antonio

I’ll try that but to be more specific for any other answers, my problem is that the scene redraws everything, polygon by polygon, which is for some reason slow even for a small quad that is 10X10 no texturing.

cwhite40

Try sticking

glFlush();

just before you swap the buffers.

Done that already.