I am working on a game with SDL2 and having trouble turning off linear filtering when upscaling textures.

My game has a bunch of 32x32 tiles. I used SDL_RenderSetLogicalSize so that there is a one-to-one pixel mapping (i.e. my logical size is n * 32 x m * 32.)

However, when the the whole scene is upscaled to fit the actual screen, it seems to be interpolated (blurry).

I saw these two other posts (1, 2) which recommended using SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0");. I did that, but nothing seems to change at all. It returns true and it is in fact changing the hint, but the rendering just doesn't change at all. I even tried setting it with priority but nothing changes.

Any idea how to fix this? I am on Windows if that's relavent.

  • \$\begingroup\$ Where do you call SDL_SetHint? \$\endgroup\$ – Tyyppi_77 Apr 15 '18 at 9:12
  • \$\begingroup\$ @Tyyppi_77 I tried calling it every frame before drawing anything and also after initialization before starting my loop. It didn't seem to make a difference. Is there a particular place it is supposed to be? \$\endgroup\$ – B1CL0PS Apr 15 '18 at 14:10
  • 1
    \$\begingroup\$ Yes, you need to call it before creating the textures. \$\endgroup\$ – Tyyppi_77 Apr 15 '18 at 14:40
  • \$\begingroup\$ @Tyyppi_77 wow, that fixed it perfectly! I was doing it just after creating textures. Weird that I couldn't find that in the documentation anywhere. Thanks so much! \$\endgroup\$ – B1CL0PS Apr 15 '18 at 14:54

SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0"); needs to happen before texture creation.

This is because interpolation mode is a property of created textures, not the rendering pipeline.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.