Compare 3 modes of SDL_HINT_RENDER_SCALE_QUALITY


Using SDL library to render a picture to renderer (monitor ), it sometime become blur when we need to compress/rescale the size of picture.

SDL_HINT_RENDER_SCALE_QUALITY , is a hint that specifies scaling quality when rendering (copy picture/texture and paste to monitor through graphic card )

This hint have 3 option : nearest (default ) , linear (supported by OpenGL and Direct3D) , best (supported by Direct3D).

In following pictures, the archer (green one with the cross bow ) have originally 128*128 pixels , all other objects have originally 32*32 pixels and render destinate size is 32*32 with all object . This mean the archer will be compressed and lost information .


[Nearest] , mean that when rescale picture bigger than original one, nearest pixel color is chose to filling missing pixel . In this mode, the 32*32 pixel objects have surprising best quality in all modes and compressed one (the archer) have worst quality.

rc = SDL_Set_Hint(SDL_HINT_RENDER_SCALE_QUALITY, “nearest”)

[Nearest] Case (Default)

[Linear] , the average color will be calculated by surround pixel . In this mode, all 32*32 pixels objects will have blur pixels around it because background color is too light this time. Hope it become better in some other cases. A good news is , archer become less blocking this time because the loss compressed pixels got recalculated by linear algorithm.

rc = SDL_Set_Hint(SDL_HINT_RENDER_SCALE_QUALITY, “linear”)

[Linear] Case Using OpenGL or Direct3D

In [best] mode , nothing changed much compare with [linear] case , but we can see archer detailly this time .

rc = SDL_Set_Hint(SDL_HINT_RENDER_SCALE_QUALITY, “best”)

[Best ] Case Using Direct3D

Leave a Reply

Your email address will not be published. Required fields are marked *