PDA

View Full Version : strange grey when you resize...



JHChong
06-18-2003, 11:13 AM
I was wondering if anybody have this problem and how it can be solved:

Environment:
When in a SDI window with OpenGL running in a child thread. A model of hug polygon count (about 1000000 tri-polygons) with < 100% opacity is loaded in the view window.

Problem:
When one resizes the window, a strange grey color was drawn into the view before it is displayed completely. In some cases, parts of the model showed up in the grey area. glFinish before SwapBuffers does not rectify the problem.

Suspicion:
I suspect I have hit a performance bottleneck in the OGL pipeline. If so, what is the likely workaround?

I would appreciate any input.

Thank you,
Chong

Csiki
06-18-2003, 12:30 PM
Originally posted by JHChong:
I was wondering if anybody have this problem and how it can be solved:

Environment:
When in a SDI window with OpenGL running in a child thread. A model of hug polygon count (about 1000000 tri-polygons) with < 100% opacity is loaded in the view window.

Problem:
When one resizes the window, a strange grey color was drawn into the view before it is displayed completely. In some cases, parts of the model showed up in the grey area. glFinish before SwapBuffers does not rectify the problem.

Suspicion:
I suspect I have hit a performance bottleneck in the OGL pipeline. If so, what is the likely workaround?

I would appreciate any input.

Thank you,
Chong

I have the same effect, but I think that's normal.
When you resize the window, the size of the buffer is also changing (I am talking about backbuffer also!!!).
What sould the driver do? Scale the old image? No, it simply clears the buffer with gray color (and clear the Z-buffer, etc.), and continue the rendering.
So what do you see after buffer changing? A picture with gray background and the second half of your rendering commands...
Of course it's a workaround that you see before the bufferswap whether the window size is changed while you rendered the image.
If yes then you shouldn't swap the buffer, just start the rendering again.

Csiki

Madoc
06-19-2003, 12:45 AM
Sounds to me like it could be Windows erasing the background. Make sure the hbrBackground member of your window class is null or intercept the WM_ERASEBACKGROUND message and simply return null.

Csiki
06-19-2003, 05:44 AM
Originally posted by Madoc:
Sounds to me like it could be Windows erasing the background. Make sure the hbrBackground member of your window class is null or intercept the WM_ERASEBACKGROUND message and simply return null.

Doesn't help. I have seen some demos and all do this deffect.

M/\dm/\n
06-19-2003, 05:59 AM
It will be there until you'll draw your frame, & in your case I guess FPS are verry low.

Csiki
06-19-2003, 11:15 AM
Originally posted by M/\dm/\n:
It will be there until you'll draw your frame, & in your case I guess FPS are verry low.

No. I render in a different thread with 130fps, but when I resize the window quite slowly (hold button, slow mouse moving), I get a nice gray window...
All program I know (DirectX: same with white color) do this.

Korval
06-19-2003, 11:29 AM
I render in a different thread with 130fps

And therein lies the problem. You're doing your rendering in a different thread from the actual window.

When the window is resized, it received a WM_PAINT message. This is Win32 telling the window to redraw itself. Unfortunately, you don't do any rendering in WM_PAINT. Since the buffers have been destroyed and re-created, precisely what lives in that memory is fully driver/API dependent.

Also, it is entirely possible that, in the middle of rendering, the user could be resizing the view. Had you been rendering in the WM_PAINT handler, there wouldn't be a problem (because the window itself doesn't get resized until it receives various sizing messages). This, of course, means that the graphics API will interrupt your rendering with a buffer-resize operation. This will, likely, clear the buffer, thus destroying what was there.

The best you can hope to get is to just clear your buffers before you render your scene.