How does SDL2.0 scale/resample textures behind the scenes?

In GL, you can set filter parameters like “GL_NEAREST” and “GL_LINEAR” to control the way that textures are resized when they are stretched or shrunk. For example, if you have a game that uses pixel art and you want to scale it correctly, you set “GL_NEAREST” because you want Nearest Neighbor, rather than Bilinear filtering, to prevent blurring.

How does SDL2.0’s hardware rendering system handle this, and is there a way to change it?

My own experiments have shown that it might default to Nearest Neighbor, as I was able to scale up a 16x16 sprite to 32x32 without any blurring.

I hope my question was clear. If not I’ll be glad to explain further. :slight_smile:

You can use:

Code:
SDL_SetHint (SDL_HINT_RENDER_SCALE_QUALITY, Value);

Where ‘Value’ can be: nearest, linear or best.

See:
SDL_SetHint Function (http://wiki.libsdl.org/SDL_SetHint?highlight=(\bCategoryHints\b)|(CategoryEnum)|(CategoryStruct)|(CategoryDefine)|(SGFunctions)) and SDL_HINT_RENDER_SCALE_QUALITY (http://wiki.libsdl.org/SDL_HINT_RENDER_SCALE_QUALITY?highlight=(\bCategoryDefine\b)|(CategoryHints))

Hope that helps. :slight_smile:

Perfect, thanks. Not sure how I missed the Configuration part of the wiki.