PDA

View Full Version : wglMakeCurrent failure



V-man
02-18-2005, 01:28 PM
I have noticed that this function fails when I call it when it's time to shutdown ie, when the app receives WM_DESTROY.

When I call wglMakeCurrent(NULL, NULL) it succeeds, but then trying to make it current again with my previous GL context fails.
So I wanted to see what the problem is.
I called GetLastError which gives some number.
Then I used FormatMessage (which usually works), but it doesn't return anything. The lpMsgBuf parameter remains NULL!

This is on ATI. On NV, it's working.

zeckensack
02-18-2005, 01:37 PM
Err ... (http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowmessages/wm_destroy.asp)
The WM_DESTROY message is sent when a window is being destroyed. It is sent to the window procedure of the window being destroyed after the window is removed from the screen.IOW the device context is already gone.

V-man
02-19-2005, 07:06 AM
The message is sent when the window is beeing destroyed, but the handles are still valid. Also, every code I've seen do their cleanup during WM_DESTROY.

Where so you do your cleanup?

plasmonster
02-19-2005, 09:24 AM
While I've never had trouble shutting down the GL in this way on NVIDIA hardware, the wording in the MSDN might give one pause. What exactly is meant by "removed from the sceen?"

As far as I can determine, they simply mean that the window is hidden and deactivated, but a window in every other respect.

You might try the GL shutdown before the window destruction, in the odd chance that it's an ATI bug.

zeckensack
02-20-2005, 05:58 AM
Originally posted by V-man:
The message is sent when the window is beeing destroyed, but the handles are still valid. Also, every code I've seen do their cleanup during WM_DESTROY.Dunno. I never felt the need for trying that out. It sounds pretty dangerous to me.
You could probably as well just exit(0), but that's really not my idea of a clean shutdown.

Where so you do your cleanup?Before calling DestroyWindow.
Or when receiving a WM_CLOSE message, because the default window proc will call DestroyWindow.

V-man
02-20-2005, 09:52 AM
It had occured to me that doing it in WM_CLOSE is possible, but I think WM_DESTROY is fine. I'm trying to clarify MSDN's statement.

Considering the fact that the Red Book, SDK's provided by major vendors, thousands of tutorials and free code do this kind of thing or don't delete GL resources at all, one has to wonder.

I'm trying to find out what is the "right thing to do"TM and what is "the correct behavior"TM

Why should one vendor's driver report a failure when it works on another.

V-man
02-22-2005, 03:55 AM
I'm interested in what other people think.
:)

zed
02-22-2005, 10:58 AM
did u have a look at the source code for sdl/glut?
also perhaps the unreal source.