Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to correctly support multiple resolutions with a fullscreen window ?  (Read 4929 times)

0 Members and 3 Guests are viewing this topic.

natinusala

  • Newbie
  • *
  • Posts: 25
    • View Profile
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 ^^

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
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. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

natinusala

  • Newbie
  • *
  • Posts: 25
    • View Profile
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.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
It's only a pain if you don't design a proper UI system that can handle most of the stuff automatically. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

natinusala

  • Newbie
  • *
  • Posts: 25
    • View Profile
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 ?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
It can be made very complex, but for a limited use case it shouldn't be extremely difficult.
« Last Edit: April 20, 2015, 03:56:34 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

natinusala

  • Newbie
  • *
  • Posts: 25
    • View Profile
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 ?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Sure. As we already mentioned you can just scale things. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

natinusala

  • Newbie
  • *
  • Posts: 25
    • View Profile
Would there be a way to automatize the scaling for every component drawn, or do I need to scale each one "by hand" ?

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Use a view. It'll scale for you.

 

anything