ikemen-engine / Ikemen-GO

An open-source fighting game engine that supports MUGEN resources.
https://ikemen-engine.github.io
Other
717 stars 125 forks source link

Inexact full-screen scaling #1914

Closed Kasasagi77 closed 2 months ago

Kasasagi77 commented 2 months ago

Describe the bug

In the full-screen mode, there are thin black borders (or borders filled with artifacts /garbage until #1911 is fixed) at the left and right side of the screen, even if the game resolution and the screen resolution are exactly the same. In my configuration (1920x1080, full-screen, described below) these borders are exactly 1px wide on the left and 2px wide on the right.

This is introduced by scaling the screen to window size, commit b3447d8d.

To Reproduce

My config (extract):

  "Fullscreen": true,
  "FullscreenRefreshRate": 60,
  "FullscreenWidth": 1920,
  "FullscreenHeight": 1080,
  "GameWidth": 1920,
  "GameHeight": 1080,

This is run on a screen resolution of 1920x1080.

Screenpack localcord is also 1920, 1080 if it matters by any chance.

My OS/Hardware/Desktop: Linux / AMD GPU / KDE / X11, if it matters.

This issue is not stage-dependent.

This issue is not visible in the screenshots taken internally in Ikemen.

Before #1911 is fixed, the black borders can instead be filled with garbage/artifacts (even in full-screen).

Expected behavior

No black borders on the left/right in full-screen if it exactly matches the game resolution.

Screenshots / Video

Black borders in commit b3447d8d:

1920x1080, fullscreen, 1px-wide border on the left and 2px-wide berder on the right. They are more visible in the floor area in the screenshot below.

black-borders-b3447d8d

No black borders in commit d80ff047:

correct-d80ff047

Engine Version (or source code date)

b3447d8d

Operating system

Linux

Extra context or search terms

I do not know if this is the case in this issue, but I seem to half-remember some problems in some other software with the full-screen window size being reported slightly smaller for some reason? Maybe in the full-screen mode, the configured full screen resolution should be used, if it is not already so?

@SuperFromND - will You take a look?

SuperFromND commented 2 months ago

Can confirm this issue exists, and isn't fixed by my pending PRs. Admittedly I haven't really done a whole lot of testing in fullscreen which is why I didn't catch this.

Seems like the culprit is the new GetScaledViewportSize function returning values that are just ever so slightly different (1918 by 1080), which is probably some floating point shenanagains.

image

A simple check to return the same viewport size if the game's in fullscreen, like this code snippet below, seems to fix the problem:

    if sys.fullscreen {
        return 0, 0, int32(winWidth), int32(winHeight)
    }

image