From 1a1cd8c1432996e5d0e50dd7ae78394a9f3593c3 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 8 Dec 2017 11:09:05 -0800 Subject: [PATCH] Fixed bug 1878 - Scaled texture draws with filtering produce wrapping artifacts. Yuri K. Schlesner When using texture filtering, there are filtering artifacts visible on the edges of scaled textures, where the texture filtering pulls in texels from the other side of the texture. Using clamping texture modes wouldn't completely fix this since source rectangles don't need to cover the whole texture. (See screenshot attached in next post.) The opengl driver uses clamping on textures and so avoid this at least in the cases where the source rect is the whole texture. The direct3d driver does not and so has problems in every case. I'm not sure if it can actually completely be fixed, but at least enabling clamping for direct3d would be one step in the right direction. --- src/render/direct3d/SDL_render_d3d.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index 04982481e..a6e2aeec1 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -1412,6 +1412,10 @@ D3D_UpdateTextureScaleMode(D3D_RenderData *data, D3D_TextureData *texturedata, u texturedata->scaleMode); IDirect3DDevice9_SetSamplerState(data->device, index, D3DSAMP_MAGFILTER, texturedata->scaleMode); + IDirect3DDevice9_SetSamplerState(data->device, index, D3DSAMP_ADDRESSU, + D3DTADDRESS_CLAMP); + IDirect3DDevice9_SetSamplerState(data->device, index, D3DSAMP_ADDRESSV, + D3DTADDRESS_CLAMP); data->scaleMode[index] = texturedata->scaleMode; } }