Win 2k Minimize Crash

Here is a problem that has perplexed me. In my OpenGL applications I have a resize member function that calls glViewport. The resize is called when the window is first created without any problem. However, when I minimize the window, the application crashes at the glViewport. This only happens when I minimize before I do any other type of resize. If I resize the window first, minimize works fine. Also, the application does not crash while I’m debuging in Visual C. Anyone have any suggestions?

Sounds like you do not initialize some of your variables properly.

Hi !

Is it crashing in the glViewport() function ?

Are you using MFC ?, sometimes you get crashes if you don’t check for zero values in cx,cy.

Is it possible that this might be the problem ?

I always add code in the resize handler like:

if( cx > 0 && cy > 0)
{
bla bla bla
}

Mikael

I’m not using MFC. Minimizing the window does pass zeros to my Resize function, but they are handled. I also check for null pointers but that doesn’t seem to be the problem either. The minimize works if I resize the window first. The program does not crash the first time Resize is called at creation. If the second call is for a minimize then it crashes. If the second call is not a minimize then the program run perfectly after that including minimize.

I can’t replicate the error in the debugger (which is a mystery in itself), but when I comment out the glViewport line the program works so I believe that is where the crash occurs.

I get the feeling that this is something very obscure. Someone could probably convince me that gamma rays are the problem if they made a good argument.

Why would you call a glViewport when the window minimizes? Usually minimized applications suspend rendering to the minimized window altogether until the window is restored.
YMMV of course.

HTH

Jean-Marc

My main message loop catches all WM_SIZE messages, which includes minimize.

I’ve just changes my case statement to check what type of resize it is and to only use my Resize function if it is a manual resize. This stops the program from crashing when minimizing after initialization.

That’s solves my problem, but doesn’t satisfy my curiosity. If anyone knows why minimize causes problems before a manual resize of the window but not after; or why the problem doesn’t occur in debug, I’d love to know.

Thanks for your help.

but can’t you specifically catch a minimize message? in your message handler, when the msg is WM_SIZE, check wParam for SIZE_MINIMIZED and do your handling there.

[EDIT]nevermind…you already fixed it

[This message has been edited by coredump (edited 05-01-2002).]

What about showing us some code ?