mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-28 22:18:28 +00:00
Added SDL_SCALEMODE_PIXELART
This is based on the algorithm presented by t3ssel8r: https://www.youtube.com/watch?v=d6tp43wZqps
This commit is contained in:
@@ -74,9 +74,10 @@ static const float TONEMAP_CHROME = 2;
|
||||
|
||||
//static const float TEXTURETYPE_NONE = 0;
|
||||
static const float TEXTURETYPE_RGB = 1;
|
||||
static const float TEXTURETYPE_NV12 = 2;
|
||||
static const float TEXTURETYPE_NV21 = 3;
|
||||
static const float TEXTURETYPE_YUV = 4;
|
||||
static const float TEXTURETYPE_RGB_PIXELART = 2;
|
||||
static const float TEXTURETYPE_NV12 = 3;
|
||||
static const float TEXTURETYPE_NV21 = 4;
|
||||
static const float TEXTURETYPE_YUV = 5;
|
||||
|
||||
static const float INPUTTYPE_UNSPECIFIED = 0;
|
||||
static const float INPUTTYPE_SRGB = 1;
|
||||
@@ -90,6 +91,11 @@ typedef struct
|
||||
float input_type;
|
||||
float color_scale;
|
||||
|
||||
float texel_width;
|
||||
float texel_height;
|
||||
float texture_width;
|
||||
float texture_height;
|
||||
|
||||
float tonemap_method;
|
||||
float tonemap_factor1;
|
||||
float tonemap_factor2;
|
||||
@@ -2106,7 +2112,15 @@ static void D3D11_SetupShaderConstants(SDL_Renderer *renderer, const SDL_RenderC
|
||||
constants->input_type = INPUTTYPE_HDR10;
|
||||
break;
|
||||
default:
|
||||
constants->texture_type = TEXTURETYPE_RGB;
|
||||
if (cmd->data.draw.texture_scale_mode == SDL_SCALEMODE_PIXELART) {
|
||||
constants->texture_type = TEXTURETYPE_RGB_PIXELART;
|
||||
constants->texture_width = texture->w;
|
||||
constants->texture_height = texture->h;
|
||||
constants->texel_width = 1.0f / constants->texture_width;
|
||||
constants->texel_height = 1.0f / constants->texture_height;
|
||||
} else {
|
||||
constants->texture_type = TEXTURETYPE_RGB;
|
||||
}
|
||||
if (texture->colorspace == SDL_COLORSPACE_SRGB_LINEAR) {
|
||||
constants->input_type = INPUTTYPE_SCRGB;
|
||||
} else if (texture->colorspace == SDL_COLORSPACE_HDR10) {
|
||||
@@ -2318,6 +2332,7 @@ static bool D3D11_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *
|
||||
return SDL_SetError("Unknown texture address mode: %d", cmd->data.draw.texture_address_mode);
|
||||
}
|
||||
break;
|
||||
case SDL_SCALEMODE_PIXELART: // Uses linear sampling
|
||||
case SDL_SCALEMODE_LINEAR:
|
||||
switch (cmd->data.draw.texture_address_mode) {
|
||||
case SDL_TEXTURE_ADDRESS_CLAMP:
|
||||
|
Reference in New Issue
Block a user