MCPcopy Create free account
hub / github.com/SFML/SFML / setDevicePixelFormat

Method setDevicePixelFormat

src/SFML/Window/Win32/WglContext.cpp:460–484  ·  view source on GitHub ↗

///////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

458
459////////////////////////////////////////////////////////////
460void WglContext::setDevicePixelFormat(unsigned int bitsPerPixel)
461{
462 const int bestFormat = selectBestPixelFormat(m_deviceContext, bitsPerPixel, m_settings);
463
464 if (bestFormat == 0)
465 {
466 err() << "Failed to find a suitable pixel format for device context: " << getErrorString(GetLastError()) << '\n'
467 << "Cannot create OpenGL context" << std::endl;
468 return;
469 }
470
471 // Extract the depth and stencil bits from the chosen format
472 PIXELFORMATDESCRIPTOR actualFormat;
473 actualFormat.nSize = sizeof(actualFormat);
474 actualFormat.nVersion = 1;
475 DescribePixelFormat(m_deviceContext, bestFormat, sizeof(actualFormat), &actualFormat);
476
477 // Set the chosen pixel format
478 if (SetPixelFormat(m_deviceContext, bestFormat, &actualFormat) == FALSE)
479 {
480 err() << "Failed to set pixel format for device context: " << getErrorString(GetLastError()) << '\n'
481 << "Cannot create OpenGL context" << std::endl;
482 return;
483 }
484}
485
486
487////////////////////////////////////////////////////////////

Callers

nothing calls this directly

Calls 1

getErrorStringFunction · 0.85

Tested by

no test coverage detected