HDC hDC = ::GetDC(hWnd);
PIXELFORMATDESCRIPTOR pfd;
::ZeroMemory(&pfd, sizeof(pfd));
pfd.nSize = sizeof(pfd);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL
| PFD_GENERIC_ACCELERATED | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 32;
pfd.cAlphaBits = 8;
pfd.cDepthBits = 24;
pfd.cStencilBits = 8;
int format = ::ChoosePixelFormat(hDC, &pfd);
::SetPixelFormat (hDC, format, &pfd);
HGLRC hTempRC = ::wglCreateContext(hDC);
::wglMakeCurrent(hDC, hTempRC);
wgl_LoadFunctions(hDC);
int attribs[] =
{
WGL_CONTEXT_MAJOR_VERSION_ARB, 4,
WGL_CONTEXT_MINOR_VERSION_ARB, 2,
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
0
};
HGLRC hRC = ::wglCreateContextAttribsARB(hDC, nullptr, attribs);
::wglMakeCurrent(nullptr, nullptr);
wglDeleteContext(hTempRC);
::wglMakeCurrent(hDC, hRC);
ogl_LoadFunctions();