mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-21 19:30:38 +01:00
gallium/wgl: fix default pixel format issue
When creating a context without SetPixelFormat() don't blindly take the
pixel format reported by GDI. Instead, look for our own closest pixel
format.
Minor clean-ups added by Brian Paul.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103412
Reviewed-by: Brian Paul <brianp@vmware.com>
Tested-by: Brian Paul <brianp@vmware.com>
(cherry picked from commit bf41b2b262)
This commit is contained in:
parent
56993f4b8a
commit
c846d72523
1 changed files with 21 additions and 2 deletions
|
|
@ -132,6 +132,25 @@ DrvCreateLayerContext(HDC hdc, INT iLayerPlane)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the stw pixel format that most closely matches the pixel format
|
||||
* on HDC.
|
||||
* Used to get a pixel format when SetPixelFormat() hasn't been called before.
|
||||
*/
|
||||
static int
|
||||
get_matching_pixel_format(HDC hdc)
|
||||
{
|
||||
int iPixelFormat = GetPixelFormat(hdc);
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
|
||||
if (!iPixelFormat)
|
||||
return 0;
|
||||
if (!DescribePixelFormat(hdc, iPixelFormat, sizeof(pfd), &pfd))
|
||||
return 0;
|
||||
return stw_pixelformat_choose(hdc, &pfd);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called via DrvCreateContext(), DrvCreateLayerContext() and
|
||||
* wglCreateContextAttribsARB() to actually create a rendering context.
|
||||
|
|
@ -174,7 +193,7 @@ stw_create_context_attribs(HDC hdc, INT iLayerPlane, DHGLRC hShareContext,
|
|||
* but not all do, and the opengl32 runtime seems to use a default
|
||||
* pixel format in some cases, so use that.
|
||||
*/
|
||||
iPixelFormat = GetPixelFormat(hdc);
|
||||
iPixelFormat = get_matching_pixel_format(hdc);
|
||||
if (!iPixelFormat)
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -458,7 +477,7 @@ stw_make_current(HDC hDrawDC, HDC hReadDC, DHGLRC dhglrc)
|
|||
* pixel format in some cases, so we must create a framebuffer for
|
||||
* those here.
|
||||
*/
|
||||
int iPixelFormat = GetPixelFormat(hDrawDC);
|
||||
int iPixelFormat = get_matching_pixel_format(hDrawDC);
|
||||
if (iPixelFormat)
|
||||
fb = stw_framebuffer_create( hDrawDC, iPixelFormat );
|
||||
if (!fb)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue