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:
Sam Lantinga 2025-03-12 08:45:25 -07:00
parent 853375da61
commit 3e9e22f17d
63 changed files with 15968 additions and 13125 deletions

View file

@ -1964,8 +1964,12 @@ bool SDL_SetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode scaleMode)
{
CHECK_TEXTURE_MAGIC(texture, false);
if (scaleMode != SDL_SCALEMODE_NEAREST &&
scaleMode != SDL_SCALEMODE_LINEAR) {
switch (scaleMode) {
case SDL_SCALEMODE_NEAREST:
case SDL_SCALEMODE_LINEAR:
case SDL_SCALEMODE_PIXELART:
break;
default:
return SDL_InvalidParamError("scaleMode");
}
@ -5707,7 +5711,7 @@ static bool CreateDebugTextAtlas(SDL_Renderer *renderer)
// Convert temp surface into texture
SDL_Texture *texture = SDL_CreateTextureFromSurface(renderer, atlas);
if (texture) {
SDL_SetTextureScaleMode(texture, SDL_SCALEMODE_NEAREST);
SDL_SetTextureScaleMode(texture, SDL_SCALEMODE_PIXELART);
renderer->debug_char_texture_atlas = texture;
}
SDL_DestroySurface(atlas);