4
\$\begingroup\$

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.

\$\endgroup\$
4
  • \$\begingroup\$ Where do you call SDL_SetHint? \$\endgroup\$
    – user35344
    Apr 15, 2018 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\$
    – QuinnF
    Apr 15, 2018 at 14:10
  • 1
    \$\begingroup\$ Yes, you need to call it before creating the textures. \$\endgroup\$
    – user35344
    Apr 15, 2018 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\$
    – QuinnF
    Apr 15, 2018 at 14:54

1 Answer 1

6
\$\begingroup\$

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.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .