Jump to content

  • Log In with Google      Sign In   
  • Create Account

Gui: in percents or in pixels?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 thecheeselover   Members   -  Reputation: 330

Like
0Likes
Like

Posted 20 February 2012 - 05:18 PM

Hi there,

I was wondering if it was better to set the Gui in function of how many pixels are on the screen (a percentage) or if it was better to set the Gui in function of a fixed resolution. If the resolution of the Gui is fixed, Gui elements won't scale if the actual resolution is different from the fixed one. If Gui elements use a percentage, they will scale depending on the actual resolution. What do you think is better?

Thank you,
Thecheeselover
Hide yo cheese! Hide yo wife!

Sponsor:

#2 Corefanatic   Members   -  Reputation: 129

Like
1Likes
Like

Posted 20 February 2012 - 06:11 PM

Generally, making a UI system pased on percentages or using universal coordinate system (ie. top left corder of any window is (0,0) and bottom right is (1,1)) is better since your UI will scale automatically, but set pixels is faster to implement.

I honestly think that best solution is one that incorporates both, for example if you want a console window in your ui, you might want it to scale to width of your window automatically, but you might want it to extend down only 300 pixels no matter what the resolution is (as long as it is more than 300 vertically of course).

Web pages implement both of these together and they work pretty well so take your inspiration from them.

Hope this helped.

#3 Adam_42   Crossbones+   -  Reputation: 2506

Like
1Likes
Like

Posted 20 February 2012 - 07:27 PM

Ideally you want to support all sensible aspect ratios and resolutions. A basic set might be something like: 640x480, 1280x1024, 1920x1200, 1280x720.

You should be able to handle those without hard coding it for each one. That probably means you need positions and scales that are percentage based, but also have an origin that can be moved (e.g. some things might be placed relative to the bottom left corner of the screen, and others relative to another UI object).

Some people also like to run in windowed mode which ideally they can be stretch to almost any aspect ratio, although you can prevent / limit that.

Of course doing all that can be a lot of work especially if there's lots of 2D UI, so it can make sense in some cases to simply add black borders and have everything run at a fixed aspect ratio, or even fixed resolution.

#4 thecheeselover   Members   -  Reputation: 330

Like
0Likes
Like

Posted 21 February 2012 - 01:27 PM

Thank you both! :)
Hide yo cheese! Hide yo wife!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS