W
W
Way2018-11-25 16:21:04
OpenGL
Way, 2018-11-25 16:21:04

How to resize gui based on screen size?

Good afternoon! I'm making a small game and decided to do gui. The gui itself is the size of the entire game window. And the fact is that the same GUI looks different at different screen resolutions (all elements are static). For example, I have a layout of my design with a resolution of 1024x768, at 800x600 the gui floor is not visible, and at 1920x1080 a "blank zone" is formed. How can I resize the gui so that the gui looks the same at almost any resolution?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2018-11-25
@GavriKos

Two ways, both of which are necessary:
​​1) Set the coordinates of elements relative not only to the upper left, but relative to any corner or center. Then if the button should be in the top right, it will always be in the top right
2) Scale coordinates and sizes depending on the current resolution. You set the resolution for which it was made up, you get new coordinates by simple scaling.
See how it works in any popular engines - it will become easier to understand.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question