int InitGL(HWND hwnd) {
static PIXELFORMATDESCRIPTOR pfd=
{
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER, // Must Support Double Buffering
PFD_TYPE_RGBA, // Request An RGBA Format
24, // Select Our Color Depth
0, 0, 0, 0, 0, 0, // Color Bits Ignored
0, // No Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
16, // 16Bit Z-Buffer (Depth Buffer)
0, // No Stencil Buffer
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};
hdc=GetDC(hwnd);
if (hdc==NULL) return 1;
iFormat = ChoosePixelFormat(hdc,&pfd);
if (!iFormat || !SetPixelFormat(hdc,iFormat,&pfd)) return 2;
hrc=wglCreateContext(hdc);
if (!hrc || !wglMakeCurrent(hdc, hrc)) return 3;
glShadeModel(GL_SMOOTH);
glClearColor(0.0f,0.0f,0.0f,0.5f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = NULL;
// Адрес функции создания расширенного контекста от драйвера видеокарты
wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC) (wglGetProcAddress("wglCreateContextAttribsARB"));
// временный контекст OpenGL нам больше не нужен, удаляем его
wglMakeCurrent(NULL, NULL);
wglDeleteContext(hrc);
// если драйвер видеокарты не предоставил нам адрес этой функции
if (!wglCreateContextAttribsARB) {
dbg(hwnd);
}
return 0;
}
aW50IEluaXRHTChIV05EIGh3bmQpIHsKCXN0YXRpYyBQSVhFTEZPUk1BVERFU0NSSVBUT1IgcGZkPQkJCQkKCXsKCQlzaXplb2YoUElYRUxGT1JNQVRERVNDUklQVE9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