Jump to content

Adaptation to different screen resolutions


Recommended Posts

Greetings. I faced such problem that similar adaptation:

local screenW, screenH = guiGetScreenSize()
local px, py=screenW/1920, screenH/1080

Doesn't work correctly on 2560x1080 and above. To be more precise, the dx element is stretched and does not display correctly on the same 1920x1080 or less.

I tried to change "local px, py = screenW / 2560, screenH / 1080", then this method does not work on 1920x1080 and on other screens.

Are there any ways for such a resolution so that adaptation for resolutions works for example at 2560x1080

Thanks to

Link to comment

Make sure to use the scaling for both position and size like so:

local sW,sH = guiGetScreenSize();
local scalex,scaley = sW/1920, sH/1080;
-- make sure to check they look good on 1920*1080!
-- so to draw a square or 200*200px on the middle of the screen:
local width, height = 200, 200;
dxDrawRectangle(sW/2-(width*scalex)/2, sH/2-(height*scaley)/2, width*scalex, height*scaley);

 

Also i suggest you to checkout this tutorial:

 

Link to comment
On 22/07/2022 at 21:22, WagnerAlpha said:

Greetings. I faced such problem that similar adaptation:

local screenW, screenH = guiGetScreenSize()
local px, py=screenW/1920, screenH/1080

Doesn't work correctly on 2560x1080 and above. To be more precise, the dx element is stretched and does not display correctly on the same 1920x1080 or less.

I tried to change "local px, py = screenW / 2560, screenH / 1080", then this method does not work on 1920x1080 and on other screens.

Are there any ways for such a resolution so that adaptation for resolutions works for example at 2560x1080

Thanks to

local sx, sy = guiGetScreenSize()
local px = math.min(1, math.max(sx/1920, sy/1080))

dxDrawImage (500*px, 500*px, 256*px, 100*px, texture)

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...