draw while resizing window

Hello,
My question is not directly opengl related.
I’m looking for the way to keep drawing (and updating) my gl scene while the user is resizing the window (under win2k).
I’m trying to catch WM_SIZING messages but there must be something I’ve missed.

It works very well with glut if I put a glviewport in my reshape function and then redraw the scene but now I’m trying to do it without glut.

well, it seems that it’s not possible with double-buffering…
true?

It works fine for me. I’m not using glut. During the WM_SIZE event I note the new size, along with the fact that a resize occurred, but nothing else. During the WM_PAINT event I check if a resize occurred, and if so I call glViewport with the new size, and then gluPerspective with the new aspect ratio.

This works for me in Win 98 Second Edition as long as I have the “Show window contents while dragging” checkbox checked in the Effects tab of the Display Properties. If I uncheck that checkbox, it reverts back to outline resize mode, but this is what it should do. If people want outline resize mode, I don’t think it’s my job as a developer to try to fight them on it.

–Travis Cobbs

I used NeHe tutorial on “how to set up openGL under Windows” so I wasn’t drawing the scene during WM_PAINT events but in the main loop (the NeHe tutorial has exactly the same problem as mine ). I tried doing as you said and moved my drawing from the main loop to WM_PAINT handling code but then the scene is never drawn !
Here’s my message proc code :

LONG WINAPI WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static bool resized = true;
static int dx=WIN_DX, dy=WIN_DY;
switch(uMsg)
{
case WM_PAINT:
if(resized)
{
glViewport(0, 0, dx, dy);
gluPerspective( 90,
((float)dx)/dy,
NEAR_CLIPPING,
FAR_CLIPPING);
display();
SwapBuffers((HDC)wParam);
resized = false;
}
break;
case WM_SIZE:
resized = true;
dx = LOWORD(lParam);
dy = HIWORD(lParam);
return 0;
case WM_CLOSE:
PostQuitMessage(0);
return 0;
case WM_KEYDOWN:
keys[wParam] = true;
break;
case WM_KEYUP:
if(wParam == 27)
{
PostQuitMessage(0);
return 0;
}
keys[wParam] = false;
break;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}

and This is my main loop :

while(!quit)
{
if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
if (msg.message==WM_QUIT)
quit=true;
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
else
{
// removed the drawing code from here
}
}

Anything horrible in my code ?

(by the way, I have checked “draw window content while dragging” too)

[This message has been edited by zeraiam (edited 02-16-2002).]

I think, that you have to call your drawing routine directly from WM_SIZE as WM_PAINT is first called when you finished resizing (I think!!!)

well I tried that but it didn’t work.

When I use single buffering it works perfectly but there is something wrong with double-buffering.
I’ve had a look at glut source code but I couldn’t find out the magic part (I might be more confused now in fact).

Put this wm_paint code in the wm_size event as well and it should redraw the scene during a resize.

glViewport(0, 0, dx, dy);
gluPerspective( …
display();
SwapBuffers((HDC)wParam);


It only works when I don’t set the PFD_DOUBLEBUFFER flag in the PIXELFORMATDESCRIPTOR structure.
I’ve read in the helpfile that : “This flag (PFD_DOUBLEBUFFER) and PFD_SUPPORT_GDI are mutually exclusive in the current generic implementation”. Does it have something to do with my problem? If so, how do they cope with it in glut ?