SFML community forums
Help => Window => Topic started by: natinusala on April 17, 2015, 11:23:15 pm
-
Hello,
I'm using VideoMode::getFullscreenModes() to get the best fullscreen videomode for my game, but I don't really know what is the proper way to draw my things, knowing the window size.
Let's take an example : I want to draw a bar at the top of the screen, with some text at its left, middle and right. It takes the whole screen width. On my screen, I decided that a 30px height and 16px font was fine, buuuut... on some screens, it may be too large and on some screens it may be too small (the goal is to target a TV, so obviously 30px is ridiculous).
So my question is : what is the proper way to adapt this ? Should I pick a standard resolution and scale to it, and adding black bars ? Or scaling each UI component ? But how ?
Thanks ^^
-
It's all up to you. ;)
If your game is made for a specific resolution then you might want to scale.
If your game can show more content if more pixels are available then don't scale but serve more content.
If your game should run on a TV then you'll have to take into account that the viewers will most likely sit further away and thus the bars etc. can't be too small.
Thing about what you actually want/need and if you still don't know which way to go, come back with a clearer concept. ;)
-
I'm actually making a console-like GUI for a Raspberry Pi (only the GUI). It includes a profile system, a game library, etc.
So I think that the best solution is to adapt every single component to the actual screen, like saying that the top bar is 1/14 of the screen, the font size is the top bar height minus some pixels for the padding etc...
But I honestly think that there is a better solution, it would be quite a pain to create everything like this.
-
It's only a pain if you don't design a proper UI system that can handle most of the stuff automatically. ;)
-
Like creating a components system with some layouts (like Swing) and stuff ? I was planning to make some components but creating a layout system is quite heavy, isn't it ?
-
It can be made very complex, but for a limited use case it shouldn't be extremely difficult.
-
I talked with a friend (who is a Minecraft modder) and he told me that Minecraft uses a technique to scale to every resolution ; it creates a new ortho which units is either wider or smaller than an actual pixel (depending on the resolution), and then scales everything according to it (by tweaking glOrtho). That means that you now have to draw your stuff using a specific unit, and it works quite well.
Would that be possible to do using SFML ?
-
Sure. As we already mentioned you can just scale things. ;)
-
Would there be a way to automatize the scaling for every component drawn, or do I need to scale each one "by hand" ?
-
Use a view. It'll scale for you.