wined3d: Clear GL backbuffer in wined3d_context_gl_init().

Signed-off-by: Paul Gofman <pgofman@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Paul Gofman 2022-02-11 18:42:28 +03:00 committed by Alexandre Julliard
parent fcc0f1fb64
commit b36e4cfe2d
1 changed files with 14 additions and 3 deletions

View File

@ -1897,7 +1897,7 @@ HGLRC context_create_wgl_attribs(const struct wined3d_gl_info *gl_info, HDC hdc,
} }
static BOOL wined3d_context_gl_create_wgl_ctx(struct wined3d_context_gl *context_gl, static BOOL wined3d_context_gl_create_wgl_ctx(struct wined3d_context_gl *context_gl,
struct wined3d_swapchain_gl *swapchain_gl) struct wined3d_swapchain_gl *swapchain_gl, BOOL *new_drawable)
{ {
enum wined3d_swap_effect swap_effect = swapchain_gl->s.state.desc.swap_effect; enum wined3d_swap_effect swap_effect = swapchain_gl->s.state.desc.swap_effect;
const struct wined3d_format *colour_format, *ds_format; const struct wined3d_format *colour_format, *ds_format;
@ -1920,6 +1920,8 @@ static BOOL wined3d_context_gl_create_wgl_ctx(struct wined3d_context_gl *context
swap_effect_copy = swap_effect == WINED3D_SWAP_EFFECT_COPY || swap_effect == WINED3D_SWAP_EFFECT_COPY_VSYNC; swap_effect_copy = swap_effect == WINED3D_SWAP_EFFECT_COPY || swap_effect == WINED3D_SWAP_EFFECT_COPY_VSYNC;
*new_drawable = !GetPixelFormat(context_gl->dc);
if (wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER) if (wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER)
{ {
static const enum wined3d_format_id ds_formats[] = static const enum wined3d_format_id ds_formats[] =
@ -2018,7 +2020,7 @@ static BOOL wined3d_context_gl_create_wgl_ctx(struct wined3d_context_gl *context
} }
context_gl->dc_is_private = TRUE; context_gl->dc_is_private = TRUE;
return wined3d_context_gl_create_wgl_ctx(context_gl, swapchain_gl); return wined3d_context_gl_create_wgl_ctx(context_gl, swapchain_gl, new_drawable);
} }
share_ctx = device->context_count ? wined3d_context_gl(device->contexts[0])->gl_ctx : NULL; share_ctx = device->context_count ? wined3d_context_gl(device->contexts[0])->gl_ctx : NULL;
@ -2064,6 +2066,7 @@ HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl, struct wi
const struct wined3d_d3d_info *d3d_info; const struct wined3d_d3d_info *d3d_info;
const struct wined3d_gl_info *gl_info; const struct wined3d_gl_info *gl_info;
struct wined3d_device *device; struct wined3d_device *device;
BOOL new_drawable;
unsigned int i; unsigned int i;
TRACE("context_gl %p, swapchain %p.\n", context_gl, swapchain_gl); TRACE("context_gl %p, swapchain %p.\n", context_gl, swapchain_gl);
@ -2142,7 +2145,7 @@ HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl, struct wi
sizeof(*context_gl->texture_type)))) sizeof(*context_gl->texture_type))))
goto fail; goto fail;
if (!wined3d_context_gl_create_wgl_ctx(context_gl, swapchain_gl)) if (!wined3d_context_gl_create_wgl_ctx(context_gl, swapchain_gl, &new_drawable))
goto fail; goto fail;
/* Set up the context defaults. */ /* Set up the context defaults. */
@ -2299,6 +2302,14 @@ HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl, struct wi
gl_info->gl_ops.gl.p_glScissor(0, 0, 0, 0); gl_info->gl_ops.gl.p_glScissor(0, 0, 0, 0);
checkGLcall("glScissor"); checkGLcall("glScissor");
if (new_drawable)
{
gl_info->gl_ops.gl.p_glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
gl_info->gl_ops.gl.p_glClearDepth(1.0f);
gl_info->gl_ops.gl.p_glClearStencil(0);
gl_info->gl_ops.gl.p_glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
checkGLcall("glClear");
}
return WINED3D_OK; return WINED3D_OK;
fail: fail: