PDA

View Full Version : wglDeleteContext acting weird



dawn
10-23-2002, 02:18 AM
I've searched the forums on strange behaviour of the DeleteContext, but i couldn't find a good answer or idea on it. So, in the finishing part of the app, when window is destroyed, i call the usual functions to deinit gl (makecurrent(null, null) and wgldeletecontext(hrc) and the others). The strange part is that this method works very well on most of the cases, but in some of them (usually huge maps with many textures) deletecontext simply crush - i test if the makecurrent succeed or hrc is valid, i also call glfinish. Another thing is that everything is ok if i use a console app that creates the gl window, but the crushes appear in a mfc app that cand preview some scenes.

Sorry if this seems stupid, but i haven't got a clue.

knackered
10-23-2002, 03:07 AM
In which overridden method of CWnd are you calling wglDeleteContext?

dawn
10-23-2002, 03:14 AM
The closing method is called when a "stop" flag is set. This is modified when WM_DESTROY, WM_QUIT are received or ESC is pressed.

Asgard
10-23-2002, 04:11 AM
Try not to set a stop flag when your app receives a WM_DESTROY, but to immediately destroy the context there. Your window, and therefore also the associated device context, is probably already destroyed when you call wglDeleteContext and that probably causes the crash. Hard to tell really without being able to debug your code though.

dawn
10-23-2002, 04:20 AM
I take care of WM_DESTROY. It's not from there.

ToolChest
10-23-2002, 04:40 AM
You said it happens on big maps with lots of textures? Do you delete all of the textures before deleting the context? I'm not sure that it matters, but I would try it just to be safe...

dawn
10-24-2002, 01:23 AM
In fact was from the texturing: i was deleting the textures, but some of them were "corrupted" - with more tests i solved it. Anyway, thanks for your answers.