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;
}