Clipping not as expected when on Linux fullscreen scaling.

I am using the following image for the main menu items.

menufonts-base

I’m grabbing each piece like this, where the image above is menufonts-base

mainUI.push("start",{0,0,382,44},{29,199,0,0},"menufonts-base","menufonts-white","menufonts-hot");
    mainUI.push("highscore",{0,45,382,58},{29,282,0,0},"menufonts-base","menufonts-white","menufonts-hot");
    mainUI.push("options",{0,104,382,57},{29,365,0,0},"menufonts-base","menufonts-white","menufonts-hot");
    mainUI.push("exit",{0,163,382,46},{29,451,0,0},"menufonts-base","menufonts-white","menufonts-hot");
    mainUI.push("credits",{0,210,382,46},{29,533,0,0},"menufonts-base","menufonts-white","menufonts-hot");
void ley::UIMenu::push(std::string label, const SDL_Rect src, const SDL_Rect dest, const std::string b, const std::string t, const std::string th) {
    //push a UI Element into the UI Menu

    SDL_Texture* base = TextureManager::Instance()->getTexture(b);
    SDL_Texture* tex = TextureManager::Instance()->getTexture(t);
    SDL_Texture* texhot = TextureManager::Instance()->getTexture(th);

    UIElement temp(label, src, {dest.x, dest.y, src.w, src.h}, base, tex, texhot);
    elements.push_back(temp);
}

I would expect that there is no way with the code to have captured the hot pink line. The Start item is from x=0 to x=44 and the pink line starts on x=45. Windowed is 1280 x 720 and the Screen is 1920 x 1080.

When running in windowed mode in Linux, or Fullscreen and windowed in Windows everything works as expected.

When starting as fullscreen and then going to windowed everything works as expected in Linux.

Expected result:

When started as windowed and scaling to fullscreen somehow the pink line is being captured and drawn to the screen. The results are also slightly different depending on SDL_HINT_RENDER_SCALE_QUALITY.

Also see https://discourse.libsdl.org/t/sdl-fullscreen-no-longer-stretching-by-default/49593/7 which has some details about how I am switching to full screen.

SDL_HINT_RENDER_SCALE_QUALITY = 0

SDL_HINT_RENDER_SCALE_QUALITY = 1

SDL_HINT_RENDER_SCALE_QUALITY = 2

How is the pink line being captured?

Thanks,
Electrosys

It’s because of texture filtering. The GPU samples and blends in the surrounding texels.

This is a pretty common issue with sprite sheets aka sprite atlases. The solution is to leave a 1 pixel buffer around the sprites.

edit: as an aside, be aware that using images for text will make it harder to translate your game into other languages.

1 Like

Thanks! Great info. I’m reading up on Texture Filtering to learn more about it.