Jump to content

Screen resolution for Dx


bradio10

Recommended Posts

Posted

I am needing help with trying to configure a DX so it can be compatible with all resolutions.

I am looking for a simple and easy solution.

I have tried using the guiGetScreenSize but I just can't seem to figure it out.

thanks.

Posted

How to make it :

place the window where you want. Like 400,300 on 1152x864 resolution. After that make the math using calculator.

X = 400/1152

Y = 300/864

Then in dxDraw you put. dxDrawImage(ScreenW*X,ScreenH*Y,.......) this will be at the same place on every resolution.

I hope you get it.

Posted

Well, here is an example for center screen:

local sx, sy = guiGetScreenSize ( ) 
local width = 400 
local height = 200 
local x = ( sx / 2 - width / 2 ) 
local y = ( sy / 2 - height / 2 ) 
addEventHandler ( "onClientRender", root, function ( ) 
    dxDrawRectangle ( x, y, width, height ) 
end ) 
  

Its just basic math.

Posted
How to make it :

place the window where you want. Like 400,300 on 1152x864 resolution. After that make the math using calculator.

X = 400/1152

Y = 300/864

Then in dxDraw you put. dxDrawImage(ScreenW*X,ScreenH*Y,.......) this will be at the same place on every resolution.

I hope you get it.

So, like this?

screenW, screenH = guiGetScreenSize () 
  
function draw() 
x = 400/1024 
y = 300/768 
dxDrawRectangle ( screenW*x, screenH*y, screenW*x, screenH*y, 255, 255, 255, 255, true) 
end 
addEventHandler ("onClientRender", root, draw) 

Posted

Yes it's like that.

for Rectangel W,H you can use another set of math not the same as X,Y if you wanna smaller or bigger Rectangel like 400,3000.

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...