///////////////////////////////////////////////////////
| 486 | |
| 487 | //////////////////////////////////////////////////////////// |
| 488 | void WglContext::updateSettingsFromPixelFormat() |
| 489 | { |
| 490 | const int format = GetPixelFormat(m_deviceContext); |
| 491 | |
| 492 | if (format == 0) |
| 493 | { |
| 494 | err() << "Failed to get selected pixel format: " << getErrorString(GetLastError()) << std::endl; |
| 495 | return; |
| 496 | } |
| 497 | |
| 498 | PIXELFORMATDESCRIPTOR actualFormat; |
| 499 | actualFormat.nSize = sizeof(actualFormat); |
| 500 | actualFormat.nVersion = 1; |
| 501 | |
| 502 | if (DescribePixelFormat(m_deviceContext, format, sizeof(actualFormat), &actualFormat) == 0) |
| 503 | { |
| 504 | err() << "Failed to retrieve pixel format information: " << getErrorString(GetLastError()) << std::endl; |
| 505 | return; |
| 506 | } |
| 507 | |
| 508 | // Detect if we are running using the generic GDI implementation and warn |
| 509 | if (actualFormat.dwFlags & PFD_GENERIC_FORMAT) |
| 510 | { |
| 511 | m_isGeneric = true; |
| 512 | |
| 513 | [[maybe_unused]] static const bool hasWarnedAboutGeneric = [actualFormat]() -> bool |
| 514 | { |
| 515 | err() << "Warning: Detected \"Microsoft Corporation GDI Generic\" OpenGL implementation" << std::endl; |
| 516 | |
| 517 | // Detect if the generic GDI implementation is not accelerated |
| 518 | if (!(actualFormat.dwFlags & PFD_GENERIC_ACCELERATED)) |
| 519 | err() << "Warning: The \"Microsoft Corporation GDI Generic\" OpenGL implementation is not " |
| 520 | "hardware-accelerated" |
| 521 | << std::endl; |
| 522 | return true; |
| 523 | }(); |
| 524 | } |
| 525 | |
| 526 | if (SF_GLAD_WGL_ARB_pixel_format) |
| 527 | { |
| 528 | static constexpr std::array attributes = {WGL_DEPTH_BITS_ARB, WGL_STENCIL_BITS_ARB}; |
| 529 | std::array<int, 2> values{}; |
| 530 | |
| 531 | if (wglGetPixelFormatAttribivARB(m_deviceContext, |
| 532 | format, |
| 533 | PFD_MAIN_PLANE, |
| 534 | static_cast<UINT>(attributes.size()), |
| 535 | attributes.data(), |
| 536 | values.data()) == TRUE) |
| 537 | { |
| 538 | m_settings.depthBits = static_cast<unsigned int>(values[0]); |
| 539 | m_settings.stencilBits = static_cast<unsigned int>(values[1]); |
| 540 | } |
| 541 | else |
| 542 | { |
| 543 | err() << "Failed to retrieve pixel format information: " << getErrorString(GetLastError()) << std::endl; |
| 544 | m_settings.depthBits = actualFormat.cDepthBits; |
| 545 | m_settings.stencilBits = actualFormat.cStencilBits; |
nothing calls this directly
no test coverage detected