in uw applicatie code
4 Initialiseer een OpenGL behulp van een apparaat context ( DC ) : HDC HDC = GetDC ( hWnd ) ; Zet de pixel formaat voor de DC via de volgende code :
PIXELFORMATDESCRIPTOR pfd ;
ZeroMemory
( & pfd , sizeof ( pfd ) ) ;
pfd.nSize
= sizeof ( pfd ) ;
pfd . nVersie = 1 ;
pfd.dwFlags
= PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL |
PFD_DOUBLEBUFFER
;
pfd.iPixelType = PFD_TYPE_RGBA ;
pfd.cColorBits
= 24 ;
pfd.cDepthBits = 16
;
pfd.iLayerType = PFD_MAIN_PLANE
;
int iFormat
= ChoosePixelFormat ( hDC , & pfd ) ;
SetPixelFormat
( hDC , iFormat , & pfd ) ;
Deze code zal dubbele buffering , z - buffer , kleur formaat en alpha -buffer opgeven . " ChoosePixelFormat " kiest gewoon de beste match voor de toepassing . SetPixelFormat zal de keuze van toepassing
5
Maak een OpenGL context behulp wglCreateContext : . . HRC = wglCreateContext ( hDC ) ; wglMakeCurrent ( * hDC , * HRC ) , je kunt nu eindelijk programmeren met OpenGL