Textures & surfacesSDL 3.2

SDL_SetTextureScaleMode

Chooses how a texture is filtered when drawn bigger or smaller: smooth (linear) or sharp pixels (nearest).

Signature

bool SDL_SetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode scaleMode);

How it works

The default is SDL_SCALEMODE_LINEAR, which blends neighbouring pixels: good for photos and smooth art, but it blurs pixel art the moment it is drawn at a size other than 1:1. SDL_SCALEMODE_NEAREST picks the closest pixel, so a 16×16 sprite drawn at 64×64 becomes crisp 4×4 blocks.

Parameters

textureSDL_Texture *

The texture.

scaleModeSDL_ScaleMode

The filter.

Common values

SDL_SCALEMODE_NEAREST
Sharp, blocky. For pixel art.
SDL_SCALEMODE_LINEAR
Smooth, blurry when enlarged. Default.

Return value

true on success, false on failure.

Example

example.cpp
1SDL_Texture* tiles = SDL_CreateTextureFromSurface(renderer, surface);
2SDL_SetTextureScaleMode(tiles, SDL_SCALEMODE_NEAREST);
Official SDL wiki