Multi-threaded app (problem with redraw on WM_MOV)

I’m hoping to get some help with a problem I’m having with the graphics framework I’m working on. Everything is working fine with one exception. When I move the window it doesn’t appear to update correctly, (resize works fine). What happens is this, I move the window say to the right on the desktop 20 pixels. The application will continue to draw but the left portion of the window will not be redrawn. The portion that isn’t redrawn is the same size as the distance moved (20 pixels). The GL rendering part appears to be working fine, redraws happen etc., but it is almost as if the buffer is being clipped, like maybe windows is confused on where the window is.

More specifics on my app. I’m using the basic WinMain, WndProc type loop. I’ve tried ignoring the WM_SIZE message or handling it. I’ve tried invalidating the window on a move event, all to no avail.

Resize works fine and will correct the problem (syncs up the window). Also clicking on the title bar or moving the mouse across the window buttons on the upper right corner will also fix the problem.

One other thing, I’m trying to create a multithreaded application, so I’m doing all the GL setup/rendering on one thread, UI on another.

I can include snippets of source code if that would help.

Any ideas?

Thanks

elroy

Well, there’s something in the set-up which is wrong
when the window is moved, but which gets corrected when
you click the title bar or resize the window. Look through
your code path to see what you do in the resize case, and
compare to what you’re doing in the move case.

Just as a guess, perhaps you’re accidentally moving the
GL rectangle INSIDE the window by as much as you’re moving
the window, when you should actually keep it constant
because the rectangle doesn’t move, counted in window
co-ordinates?

Thanks for the reply.

I’m including a snippet of code from the message passing thread.

I have tried ignoring the WM_SIZE event, handling it like it is shown and a couple of other methods. The more I investigate the more I don’t think it is a GL issue. When moving the whole window, GL really doesn’t need to do anything (other than keep rendering). I’m wondering if I set something up incorrectly, or if it is the fact that I have a rendering thread (creates the GL rendering context) and the main thread which created the window. It is really starting to bug me… Sure I could have the WM_SIZE handler post a resize message but that seems to be a hack. I would prefer to figure out what isn’t quite right. I have also found that when I move the window to the top left corner it will draw outside of the window a bit, (onto the desktop). Very confusing and not what I wanted to be spending my time on.

Here is the code. As I said I have tried not handling the WM_MOVE message or handling it differently than shown.

	case WM_MOVE:
	case WM_SIZE:
	     EnterCriticalSection(&csThreadSafe);
		rsRenderData.bResize = TRUE;
		rsRenderData.bModifyFlag = TRUE;
		LeaveCriticalSection(&csThreadSafe);

Well, After more investigation it appears it is driver related. I tried one of the example programs from the OpenGL Super Bible 2nd book that made use of threads and it suffered from the same problem. (the other examples didn’t). I then tried the app on a different computer and the problem did not show itself. I work at home on a GForce (this showed the problem) at work I have a G400, the only other difference could be Win98 vs 2000 (where 2000 works). I’m going to change my program to toggle between multi-threaded and single threaded and see if the problem persists in the single threaded case.

Has anyone seen this type of behavior before?

elroy

Well, I figured out what was going on, and on the off chance that someone else is reading this thread, will divulge what I found.

As I mentioned earlier I found a multithreaded example program that didnt’ work on my home computer, but did at work. I thought it might be driver related butwhen I was home last night I realized that there was more going on than the move problem. Nothing was displayed in the window when I moved it. One of the benifits of a rendering thread is that you still update the window when you move. It was then I realized that for some reason my computer at home at the show window contents when moving/sizing turned off!. When I enabled this everything worked correctly. Well there’s 6 hrs of my life I’ll never get back

HEHE that was a happy ending, except of the fact that u used 6 hours, but i guess u’ll live =)