| 64 | }; |
| 65 | |
| 66 | static HGLRC createContext(HDC _hdc, const Resolution& _resolution) |
| 67 | { |
| 68 | const bimg::ImageBlockInfo& colorBlockInfo = bimg::getBlockInfo(bimg::TextureFormat::Enum(_resolution.formatColor) ); |
| 69 | const bimg::ImageBlockInfo& depthStecilBlockInfo = bimg::getBlockInfo(bimg::TextureFormat::Enum(_resolution.formatDepthStencil) ); |
| 70 | |
| 71 | PIXELFORMATDESCRIPTOR pfd; |
| 72 | bx::memSet(&pfd, 0, sizeof(pfd) ); |
| 73 | pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); |
| 74 | pfd.nVersion = 1; |
| 75 | pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; |
| 76 | pfd.iPixelType = PFD_TYPE_RGBA; |
| 77 | pfd.cColorBits = colorBlockInfo.bitsPerPixel; |
| 78 | pfd.cAlphaBits = colorBlockInfo.aBits; |
| 79 | pfd.cDepthBits = depthStecilBlockInfo.depthBits; |
| 80 | pfd.cStencilBits = depthStecilBlockInfo.stencilBits; |
| 81 | pfd.iLayerType = PFD_MAIN_PLANE; |
| 82 | |
| 83 | int pixelFormat = ChoosePixelFormat(_hdc, &pfd); |
| 84 | BGFX_FATAL(0 != pixelFormat, Fatal::UnableToInitialize, "ChoosePixelFormat failed!"); |
| 85 | |
| 86 | DescribePixelFormat(_hdc, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd); |
| 87 | |
| 88 | BX_TRACE("Pixel format:\n" |
| 89 | "\tiPixelType %d\n" |
| 90 | "\tcColorBits %d\n" |
| 91 | "\tcAlphaBits %d\n" |
| 92 | "\tcDepthBits %d\n" |
| 93 | "\tcStencilBits %d\n" |
| 94 | , pfd.iPixelType |
| 95 | , pfd.cColorBits |
| 96 | , pfd.cAlphaBits |
| 97 | , pfd.cDepthBits |
| 98 | , pfd.cStencilBits |
| 99 | ); |
| 100 | |
| 101 | int result; |
| 102 | result = SetPixelFormat(_hdc, pixelFormat, &pfd); |
| 103 | BGFX_FATAL(0 != result, Fatal::UnableToInitialize, "SetPixelFormat failed!"); |
| 104 | |
| 105 | HGLRC context = wglCreateContext(_hdc); |
| 106 | BGFX_FATAL(NULL != context, Fatal::UnableToInitialize, "wglCreateContext failed!"); |
| 107 | |
| 108 | result = wglMakeCurrent(_hdc, context); |
| 109 | BGFX_FATAL(0 != result, Fatal::UnableToInitialize, "wglMakeCurrent failed!"); |
| 110 | |
| 111 | return context; |
| 112 | } |
| 113 | |
| 114 | void GlContext::create(const Resolution& _resolution) |
| 115 | { |