diff --git a/include/SDL_render.h b/include/SDL_render.h index 6e3daf522..60c87b66a 100644 --- a/include/SDL_render.h +++ b/include/SDL_render.h @@ -682,7 +682,8 @@ extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer, /** * \brief Clear the current rendering target with the drawing color * - * This function clears the entire rendering target, ignoring the viewport. + * This function clears the entire rendering target, ignoring the viewport and + * the clip rectangle. * * \return 0 on success, or -1 on error */ diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index da8c1af07..c54897fe7 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -1311,6 +1311,10 @@ D3D_RenderClear(SDL_Renderer * renderer) BackBufferHeight = data->pparams.BackBufferHeight; } + if (renderer->clipping_enabled) { + IDirect3DDevice9_SetRenderState(data->device, D3DRS_SCISSORTESTENABLE, FALSE); + } + /* Don't reset the viewport if we don't have to! */ if (!renderer->viewport.x && !renderer->viewport.y && renderer->viewport.w == BackBufferWidth && @@ -1340,6 +1344,10 @@ D3D_RenderClear(SDL_Renderer * renderer) IDirect3DDevice9_SetViewport(data->device, &viewport); } + if (renderer->clipping_enabled) { + IDirect3DDevice9_SetRenderState(data->device, D3DRS_SCISSORTESTENABLE, TRUE); + } + if (FAILED(result)) { return D3D_SetError("Clear()", result); } diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index 7c6f80d44..0276f28da 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -1146,8 +1146,16 @@ GL_RenderClear(SDL_Renderer * renderer) (GLfloat) renderer->b * inv255f, (GLfloat) renderer->a * inv255f); + if (renderer->clipping_enabled) { + data->glDisable(GL_SCISSOR_TEST); + } + data->glClear(GL_COLOR_BUFFER_BIT); + if (renderer->clipping_enabled) { + data->glEnable(GL_SCISSOR_TEST); + } + return 0; } diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c index b8b8c1d49..56cbad680 100644 --- a/src/render/opengles/SDL_render_gles.c +++ b/src/render/opengles/SDL_render_gles.c @@ -815,9 +815,17 @@ GLES_RenderClear(SDL_Renderer * renderer) (GLfloat) renderer->g * inv255f, (GLfloat) renderer->b * inv255f, (GLfloat) renderer->a * inv255f); + + if (renderer->clipping_enabled) { + data->glDisable(GL_SCISSOR_TEST); + } data->glClear(GL_COLOR_BUFFER_BIT); + if (renderer->clipping_enabled) { + data->glEnable(GL_SCISSOR_TEST); + } + return 0; } diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index edefa6415..30d761ad7 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -1327,8 +1327,16 @@ GLES2_RenderClear(SDL_Renderer * renderer) data->clear_a = renderer->a; } + if (renderer->clipping_enabled) { + data->glDisable(GL_SCISSOR_TEST); + } + data->glClear(GL_COLOR_BUFFER_BIT); + if (renderer->clipping_enabled) { + data->glEnable(GL_SCISSOR_TEST); + } + return 0; }