Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
This commit is contained in:
parent
fbc49beee3
commit
a19e258730
5 changed files with 79 additions and 9 deletions
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
|
||||
#include "SDL_hints.h"
|
||||
#include "SDL_loadso.h"
|
||||
#include "SDL_syswm.h"
|
||||
#include "../SDL_sysrender.h"
|
||||
|
@ -137,11 +138,13 @@ typedef struct
|
|||
D3DPRESENT_PARAMETERS pparams;
|
||||
SDL_bool updateSize;
|
||||
SDL_bool beginScene;
|
||||
D3DTEXTUREFILTERTYPE scaleMode;
|
||||
} D3D_RenderData;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
IDirect3DTexture9 *texture;
|
||||
D3DTEXTUREFILTERTYPE scaleMode;
|
||||
} D3D_TextureData;
|
||||
|
||||
typedef struct
|
||||
|
@ -451,6 +454,7 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
|
|||
return NULL;
|
||||
}
|
||||
data->beginScene = SDL_TRUE;
|
||||
data->scaleMode = D3DTEXF_FORCE_DWORD;
|
||||
|
||||
/* Get presentation parameters to fill info */
|
||||
result = IDirect3DDevice9_GetSwapChain(data->device, 0, &chain);
|
||||
|
@ -537,6 +541,20 @@ D3D_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
|
|||
}
|
||||
}
|
||||
|
||||
static D3DTEXTUREFILTERTYPE
|
||||
GetScaleQuality(void)
|
||||
{
|
||||
const char *hint = SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY);
|
||||
|
||||
if (!hint || *hint == '0' || SDL_strcasecmp(hint, "nearest") == 0) {
|
||||
return D3DTEXF_POINT;
|
||||
} else if (*hint == '1' || SDL_strcasecmp(hint, "linear") == 0) {
|
||||
return D3DTEXF_LINEAR;
|
||||
} else {
|
||||
return D3DTEXF_ANISOTROPIC;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
|
@ -553,6 +571,7 @@ D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
}
|
||||
data->scaleMode = GetScaleQuality();
|
||||
|
||||
texture->driverdata = data;
|
||||
|
||||
|
@ -1018,10 +1037,13 @@ D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
|
||||
D3D_SetBlendMode(data, texture->blendMode);
|
||||
|
||||
IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER,
|
||||
D3DTEXF_LINEAR);
|
||||
IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER,
|
||||
D3DTEXF_LINEAR);
|
||||
if (texturedata->scaleMode != data->scaleMode) {
|
||||
IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER,
|
||||
texturedata->scaleMode);
|
||||
IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER,
|
||||
texturedata->scaleMode);
|
||||
data->scaleMode = texturedata->scaleMode;
|
||||
}
|
||||
|
||||
result =
|
||||
IDirect3DDevice9_SetTexture(data->device, 0, (IDirect3DBaseTexture9 *)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue