SDL3 High DPI?
Hi, my SDL3 application using Clay (based on SDL3 example in repo) is not able to scale properly. On my high DPI display, it is really tiny. How do I tell Clay/SDL3 to respect DPI?
It could be because of your text scaling. The text in SDL is scaled in pixels, not relative to the window size. To fix this, just multiply your .fontSize with a scale that respects your window size. I have a function for that:
float getFontScale() {
int h = 0;
SDL_GetWindowSize(sdlWindow, NULL, &h);
return h / BASE_WINDOW_HEIGHT;
}
You can use it like this: .fontSize = 30 * getFontScale(). BASE_WINDOW_HEIGHT is the window height in pixels for which your application is made and looks good at. So your application has the right size at 1600x900, BASE_WINDOW_HEIGHT would be 900.
@nobschulth That is a very helpful function, but it would be more clear if h wasn't initialized. Initializing a variable makes it seem you want to use the value you gave it, but if you're just overwriting it in the next line, you can save a write by simply leaving the value blank.
As always, shoutout to using out-params instead of just returning so that one can't use the function as an rvalue.
any way to auto change inside clay?