Eliminación de un contexto de representación
En el ejemplo de código siguiente se muestra cómo eliminar un contexto de representación de OpenGL cuando se cierra una ventana de OpenGL. Es una continuación del escenario que se usa en Crear un contexto de representación y convertirlo en actual.
// a window is about to be destroyed
case WM_DESTROY:
{
// local variables
HGLRC hglrc;
HDC hdc ;
// if the thread has a current rendering context ...
if(hglrc = wglGetCurrentContext()) {
// obtain its associated device context
hdc = wglGetCurrentDC() ;
// make the rendering context not current
wglMakeCurrent(NULL, NULL) ;
// release the device context
ReleaseDC (hwnd, hdc) ;
// delete the rendering context
wglDeleteContext(hglrc);
}