1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
BOOL COGLContext::InitContext(HDC a_hDC)
{
PIXELFORMATDESCRIPTOR pfd;
int nFormat;
unsignedint nCount;
BOOL bOk = FALSE;
// Clear memory
ZeroMemory( &pfd, sizeof( pfd ) );
// set the pixel format for the DC
pfd.nSize = sizeof( pfd );
pfd.nVersion = 1;
m_hDC = a_hDC;
int nAttr[] =
{
WGL_DRAW_TO_WINDOW_ARB, TRUE,
WGL_SUPPORT_OPENGL_ARB, TRUE,
WGL_SAMPLE_BUFFERS_ARB, (m_nMSAA>1)?TRUE:FALSE,
WGL_SAMPLES_ARB, (m_nMSAA>1)?m_nMSAA:0,
WGL_RED_BITS_ARB, 8,
WGL_GREEN_BITS_ARB, 8,
WGL_BLUE_BITS_ARB, 8,
WGL_ALPHA_BITS_ARB, 8,
WGL_DEPTH_BITS_ARB, 24,
WGL_DOUBLE_BUFFER_ARB, TRUE,
0
};
// choose a pixel format that meets our minimum requirements
wglChoosePixelFormatARB(m_hDC,(constint*)nAttr,NULL,1,&nFormat,&nCount);
// Set this pixelformat
bOk = SetPixelFormat( m_hDC, nFormat, &pfd );
// Create and enable the render context (RC)
m_hRenderDC = wglCreateContext( m_hDC );
bOk = wglMakeCurrent( m_hDC, m_hRenderDC );
// Get All The pixel format extension here
return TRUE;
}
|
Partager