PDA

View Full Version : draw while resizing window



zeraiam
02-14-2002, 10:29 AM
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.

zeraiam
02-14-2002, 12:24 PM
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.

zeraiam
02-15-2002, 09:58 AM
well, it seems that it's not possible with double-buffering...
true?

tcobbs
02-15-2002, 08:50 PM
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

zeraiam
02-16-2002, 03:06 AM
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 http://www.opengl.org/discussion_boards/ubb/frown.gif). 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).]

elimin8tor
02-16-2002, 03:28 AM
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!!!)

zeraiam
02-16-2002, 04:49 AM
well I tried that but it didn't work. http://www.opengl.org/discussion_boards/ubb/frown.gif

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).

jmathies
02-16-2002, 11:58 AM
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);

zeraiam
02-17-2002, 10:24 AM
http://www.opengl.org/discussion_boards/ubb/confused.gif http://www.opengl.org/discussion_boards/ubb/confused.gif http://www.opengl.org/discussion_boards/ubb/confused.gif
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 ?