Commit 3847eca0 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Use wglSetPixelFormatWINE() in wined3d_context_gl_set_pixel_format() if we can.

Based on a patch by Connor McAdams. Signed-off-by: 's avatarHenri Verbeet <hverbeet@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent d71358f5
...@@ -1186,6 +1186,7 @@ static BOOL wined3d_context_gl_set_pixel_format(struct wined3d_context_gl *conte ...@@ -1186,6 +1186,7 @@ static BOOL wined3d_context_gl_set_pixel_format(struct wined3d_context_gl *conte
int format = context_gl->pixel_format; int format = context_gl->pixel_format;
HDC dc = context_gl->dc; HDC dc = context_gl->dc;
int current; int current;
HWND win;
if (private && context_gl->dc_has_format) if (private && context_gl->dc_has_format)
return TRUE; return TRUE;
...@@ -1196,55 +1197,43 @@ static BOOL wined3d_context_gl_set_pixel_format(struct wined3d_context_gl *conte ...@@ -1196,55 +1197,43 @@ static BOOL wined3d_context_gl_set_pixel_format(struct wined3d_context_gl *conte
current = gl_info->gl_ops.wgl.p_wglGetPixelFormat(dc); current = gl_info->gl_ops.wgl.p_wglGetPixelFormat(dc);
if (current == format) goto success; if (current == format) goto success;
if (!current)
{
if (!SetPixelFormat(dc, format, NULL))
{
/* This may also happen if the dc belongs to a destroyed window. */
WARN("Failed to set pixel format %d on device context %p, last error %#x.\n",
format, dc, GetLastError());
return FALSE;
}
context_gl->restore_pf = 0;
context_gl->restore_pf_win = private ? NULL : WindowFromDC(dc);
goto success;
}
/* By default WGL doesn't allow pixel format adjustments but we need it /* By default WGL doesn't allow pixel format adjustments but we need it
* here. For this reason there's a Wine specific wglSetPixelFormat() * here. For this reason there's a Wine specific wglSetPixelFormat()
* which allows us to set the pixel format multiple times. Only use it * which allows us to set the pixel format multiple times. Use it when we
* when really needed. */ * can, because even though no pixel format may currently be set, the
* application may try to set one later. */
if (gl_info->supported[WGL_WINE_PIXEL_FORMAT_PASSTHROUGH]) if (gl_info->supported[WGL_WINE_PIXEL_FORMAT_PASSTHROUGH])
{ {
HWND win;
if (!GL_EXTCALL(wglSetPixelFormatWINE(dc, format))) if (!GL_EXTCALL(wglSetPixelFormatWINE(dc, format)))
{ {
ERR("wglSetPixelFormatWINE failed to set pixel format %d on device context %p.\n", ERR("wglSetPixelFormatWINE failed to set pixel format %d on device context %p.\n",
format, dc); format, dc);
return FALSE; return FALSE;
} }
}
win = private ? NULL : WindowFromDC(dc); else if (current)
if (win != context_gl->restore_pf_win) {
{ /* OpenGL doesn't allow pixel format adjustments. Print an error and
wined3d_context_gl_restore_pixel_format(context_gl); * continue using the old format. There's a big chance that the old
* format works although with a performance hit and perhaps rendering
context_gl->restore_pf = private ? 0 : current; * errors. */
context_gl->restore_pf_win = win; ERR("Unable to set pixel format %d on device context %p. Already using format %d.\n",
} format, dc, current);
return TRUE;
goto success; }
else if (!SetPixelFormat(dc, format, NULL))
{
/* This may also happen if the dc belongs to a destroyed window. */
WARN("Failed to set pixel format %d on device context %p, last error %#x.\n",
format, dc, GetLastError());
return FALSE;
} }
/* OpenGL doesn't allow pixel format adjustments. Print an error and win = private ? NULL : WindowFromDC(dc);
* continue using the old format. There's a big chance that the old if (win != context_gl->restore_pf_win)
* format works although with a performance hit and perhaps rendering wined3d_context_gl_restore_pixel_format(context_gl);
* errors. */ context_gl->restore_pf = private ? 0 : current;
ERR("Unable to set pixel format %d on device context %p. Already using format %d.\n", context_gl->restore_pf_win = win;
format, dc, current);
return TRUE;
success: success:
if (private) if (private)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment