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

Libtcod does not listen to system DPI settings, very tiny on hidpi screens #95

Open
hazeled opened this issue Jul 22, 2021 · 9 comments
Labels

Comments

@hazeled
Copy link
Contributor

hazeled commented Jul 22, 2021

For example, on i3:
image

Libtcod is drawing normal resolution without scaling to the dpi of the screen. An easy solution to this would be to read xserver's Xft.dpi, which is how most servers do it on x-based systems

@HexDecimal HexDecimal self-assigned this Jul 22, 2021
@HexDecimal
Copy link
Collaborator

What platform is i3?

This kind of thing is difficult to work with. I need to know how to correctly do this in SDL2 and I never had a platform to test HighDPI on.

Can you add tcod.context.SDL_WINDOW_ALLOW_HIGHDPI to tcod.context.new's sdl_window_flags parameter to see if that affects the issue?

@HexDecimal
Copy link
Collaborator

Sorry, I didn't notice that this wasn't about python-tcod. SDL_WINDOW_ALLOW_HIGHDPI would go into TCOD_ContextParams instead.

How are you currently initializing the window?

@HexDecimal HexDecimal added the bug label Jul 22, 2021
@hazeled
Copy link
Contributor Author

hazeled commented Jul 24, 2021

I'm just using the simple example:

#include "libtcod.hpp"
int main() {
   TCODConsole::initRoot(80,50,"libtcod",false);
   while ( !TCODConsole::isWindowClosed() ) {
       TCOD_key_t key;
       TCODSystem::checkForEvent(TCOD_EVENT_KEY_PRESS,&key,NULL);
       TCODConsole::root->clear();
       TCODConsole::root->putChar(40,25,'@');
       TCODConsole::flush();
   }
   return 0;
}

@HexDecimal
Copy link
Collaborator

Issue #90 might have some useful information. It at least contains what little I know about HighDPI.

Is there a cross-platform way to use Xft.dpi? How is it normally used? Why didn't your window manager resize the window in your example screenshot?

@hazeled
Copy link
Contributor Author

hazeled commented Jul 27, 2021

Normally, xserver apps will use Xft.dpi to measure the DPI of the screen. I'm fairly certain most libraries (Like GTK) do this automatically. However, Xft.dpi is not cross-platform (For things like wayland or other operating systems). My window manager (i3) does correctly send the window size, but the window size is small on my screen because of the HiDPI

@HexDecimal
Copy link
Collaborator

Does the environment variable SDL_VIDEO_HIGHDPI_DISABLED=1 affect the screen size if set before running the program?

I've been unable to find an example of implementing Xft.dpi in SDL2. Normally the ability to resize the window gets around the window being too small on most platforms. I'm not completely sure that an automatic solution can be put into libtcod itself since the DPI would be used to make decisions that'd have to be made outside of libtcod.

@hazeled
Copy link
Contributor Author

hazeled commented Jul 27, 2021

Setting SDL_VIDEO_HIGHDPI_DISABLED=1 or SDL_VIDEO_HIGHDPI_DISABLED=0 has no effect

@hazeled
Copy link
Contributor Author

hazeled commented Jan 11, 2022

Any update on this? I love libtcod but it makes it unusable on my machine

@HexDecimal
Copy link
Collaborator

I guess I need more feedback on this. The SDL docs aren't clear on how you're normally supposed to handle it.

If you're initializing libtcod the modern way then you can manually choose to pass or ignore SDL's SDL_WINDOW_ALLOW_HIGHDPI flag as well as set the window size manually if needed.

@HexDecimal HexDecimal removed their assignment Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants