Nota
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare ad accedere o modificare le directory.
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare a modificare le directory.
L'esempio di codice seguente illustra l'aspetto del codice di contesto di rendering GLX nella sezione precedente quando è stato convertito in Windows.The following code shows how the GLX rendering context code in the previous section look when it has been ported to Windows.
HGLRC hRC; // rendering context variable
/* Create and initialize a window */
/* Window message switch in a window procedure */
case WM_CREATE: // Message when window is created
{
HDC hDC, hDCTemp; // device context handles
/* Get the handle of the windows device context. */
hDC = GetDC(hWnd);
/* Create a rendering context and make it the current context */
hRC = wglCreateContext(hDC);
if (!hRC)
{
MessageBox(NULL, "Cannot create context.", "Error", MB_OK);
return FALSE;
}
wglMakeCurrent(hDC, hRC);
}
break;
.
case WM_DESTROYED: // Message when window is destroyed
{
HGLRC hRC // rendering context handle
HDC hDC; // device context handle
/* Release and free the device context and rendering context. */
hDC = wglGetCurrentDC;
hRC = wglGetCurrentContext;
wglMakeCurrent(NULL, NULL);
if (hRC)
wglDeleteContext(hRC);
if (hDC)
ReleaseDC(hWnd, hDC);
PostQuitMessage (0);
}
break;