Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to upscale game by nearest neighbour #7629

Open
JoeCreates opened this issue Jun 27, 2019 · 8 comments
Open

Option to upscale game by nearest neighbour #7629

JoeCreates opened this issue Jun 27, 2019 · 8 comments

Comments

@JoeCreates
Copy link

@JoeCreates JoeCreates commented Jun 27, 2019

Presently if you set the game resolution to half the screen resolution, for example, the upscaling is very blurry when it doesn't need to be.

I'm not a fan of the increased UI size and wish to play on a 1440p monitor, so I would rather set the game size to half and just upscale everything. A nearest neighbour scaling method would be far preferable and prevent the blur that currently occurs.

@nielsmh

This comment has been minimized.

Copy link
Contributor

@nielsmh nielsmh commented Jun 27, 2019

Technically speaking, I think this could be "annoying" to do, and would probably have to be implemented in the video driver rather than anywhere else. In other words, it would be a per-platform feature not necessarily available or working the exact same way on Windows, Mac, Linux.

There could also be some technical challenges with getting the mouse to behave right. (What should the mouse cursor size even be, scaled along or unscaled? Should it be able to move and be positioned at "half pixels"?)

@JoeCreates

This comment has been minimized.

Copy link
Author

@JoeCreates JoeCreates commented Jun 27, 2019

@PeterN

This comment has been minimized.

Copy link
Member

@PeterN PeterN commented Jun 27, 2019

Sure, but we don't use OpenGL, nor DirectX :-)

@nielsmh

This comment has been minimized.

Copy link
Contributor

@nielsmh nielsmh commented Jun 27, 2019

Now you're suggesting ripping out and replacing the entire display pipeline in the game ;)

There is no OpenGL in OpenTTD, nor is there any Direct3D or Metal or any other GPU API you can think of. The rendering happens internally in a software blitter which produces a 2D surface, which is then displayed via a platform-specific video output module, called "video driver" internally. The video driver handles most of the platform-specific things including all mouse and keyboard input and interfacing with the platform windowing system. The most common video drivers in OpenTTD are the Win32 driver for Windows, the SDL driver for Linux, and the Cocoa driver for Mac.

The most efficient way to implement a full game 2x scaling would be at the video driver level, since every platform offers a way to copy a surface to screen scaled in some way. It doesn't need to use any explicit GPU API for that, but it does need to be implemented separately in each, so there can naturally be discrepancies in how they behave.

As for mouse, my question was which of these three scenarios I made a mockup of:
image

@PeterN

This comment has been minimized.

Copy link
Member

@PeterN PeterN commented Jun 27, 2019

Of course, we should replace the multiple drivers with a single cross-platform accelerated driver... but nobody's done that yet.

@nielsmh

This comment has been minimized.

Copy link
Contributor

@nielsmh nielsmh commented Jun 27, 2019

I did a proof of concept on the Win32 driver, it's certainly possible.
image
The game thinks it's running 800x600, but the actual displayed window is 3x scaled to 2400x1800.

nielsmh added a commit to nielsmh/OpenTTD that referenced this issue Jun 27, 2019
@michicc

This comment has been minimized.

Copy link
Member

@michicc michicc commented Jun 27, 2019

There's https://github.com/michicc/OpenTTD/tree/opengl, but it's Windows only for now.

@fsimonis

This comment has been minimized.

Copy link

@fsimonis fsimonis commented Aug 11, 2019

@PeterN Doesn't SDL already fit that description? It is cross-platform and allows you to create contexts for OpenGL, Vulkan, etc.

@michicc It seems like the windows specific part is the initialisation.
You could use the SDL driver to load the OpenGL library and create an OpenGL context for you. This context can then be used in your OpenGL back-end.

nielsmh added a commit to nielsmh/OpenTTD that referenced this issue Dec 25, 2019
nielsmh added a commit to nielsmh/OpenTTD that referenced this issue Dec 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.