wglDeleteContext, wglMakeCurrent and resources
Hi!
My question is similar to:
http://www.gamedev.net/community/forums/topic.asp?topic_id=307699
but that is unanswered and even I wasn't able to post a reply (which was going to be further questions anyways).
So: is there a way to free context-associated resources when a HDC is not available for the appropriate RC?
I mean there would be a drawing function which gets a HDC in parameter, sets wglMakeCurrent (hDC, hRC), performs some drawing, then releases the DC with wglMakeCurrent (NULL, NULL). I certainly won't want to delete all the display lists at this point, otherwise I would have to recompile them the next update time. (I have to release the DC in order to draw on it using GDI later). This repeats several times then I want to clean up things.
Do I have to present a valid HDC to the clean up code (in order to be able wglMakeCurrent the RC) or does wglDeleteContext automatically free up all the display lists (and other resources) bound to it?
I tried wglMakeCurrent (NULL, hRC) and then glDeleteLists but that doesn't seem to work.
Thx in advance!
I believe the answer to the question in the linked thread is yes. All resources associated with a context are freed when it destroyed unless they are shared with another context. In that case they are freed when the last shared context is deleted.
In answer to your question, you do not need the dc in order to destroy the opengl context. Just make sure the context is not bound to another thread and call wglDeleteContext(yourContext). The context you are deleting does not need to be bound to the current thread in order to delete the context, though to use it for rendering or to delete specific resources individually it does need to be bound.
In answer to your question, you do not need the dc in order to destroy the opengl context. Just make sure the context is not bound to another thread and call wglDeleteContext(yourContext). The context you are deleting does not need to be bound to the current thread in order to delete the context, though to use it for rendering or to delete specific resources individually it does need to be bound.
I tried wglMakeCurrent (NULL, hRC) and then glDeleteLists but that doesn't seem to work.
In order to bind the context to the thread with wglMakeCurrent, you need to provide a DC. This does not need to be the same DC you created the rendering context with, but it does need to be on the same device. One option is to use GetDC(myWindow) to get a hdc for the window you are rendering to. You should not need to delete the lists manually however if you are destroying the context.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement