Fix For Virtual Jaguar HiDPI Scaling Issue
I have ran into this problem a few times running VJ in Linux, specifically Kubuntu 18.04 and later over the last few years, where the image of the game being played doesn’t fill the window size or fullscreen properly. When running a 4K monitor this isn’t an uncommon problem to have high dpi scaling issues with applications that haven’t been updated in a while.
I have found a rough workaround by modifying the source for VJ. I also wanted to make this post with the solution I have been using in case anyone else out there might be running into the same problem, and there isn’t a better way to do this currently. Below is an image of what I am experiencing when opening VJ, and it holds true when playing a game windowed or in full screen. I am using version 2.1.3(final) source from the git repository.
Here is a solution I am currently using to fix this. Before building Virtual Jaguar perform the following modifications to the source code.
First we need to determine what our scaling value is. This is fairly simple to do just by checking our global scaling value in our operating system. This is usually represented by a percentage of the native scaling. For example, in Kubuntu Display Configuration menu, there is a slider to adjust the global scale. Currently my desktop is set to 175%. We convert this to a decimal value of 1.75, we can use this in code to multiply certain values to match our current global scale.
/src/gui/mainwin.cpp – Add the following line in the function MainWin::SetFullScreen, below the line where int newWidth is initialized. The line looks like this “int newWidth = (int)(aspectRatio * (double)r.height());”.
newWidth *= 1.75;
Then alter the line just below, that looks like this “videoWidget->offset = (r.width() – newWidth) / 2;”, multiplying r.width() by 2.2. It should now look like the line below.
videoWidget->offset = ((r.width() * 1.75) - newWidth) / 2;
/src/gui/glwidget.cpp – Now we need to multiply width() and hieght() function calls by 2.2, do this by altering the following lines.
outputWidth = width(); changes to:
outputWidth = width() * 1.75;
unsigned outputHeight = height(); changes to:
unsigned outputHeight = height() * 1.75;
This isn’t a perfect solution and is a bit of a pain if you adjust your global scale, but, as far as I know, this is currently the only way to get Virtual Jaguar to properly scale in KDE and possibly other QT based applications. The program could be edited with updated QT functions to handle scaling. There is a bit of a discussion of this on the AtariAge forums here.