Sign in to follow this  

Screen Resolution (again)

This topic is 4837 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Two simple questions (again) this is what I thought to program something to go with different resolutions in 2D: - How do I divide the screen into boxes to easily know the coordinates. Top most corner of the window be (0,0) where as the bottom right corner be (1000, 1000) or any other value? - How do I convert those screen coordinates like (0,0) is the center of the screen to (0,0) top most corner of the screen? Please help? I know the second one but the first one is really turning out to be a pain. anyone?

Share this post


Link to post
Share on other sites
Um.

Are you trying to determine the current screen resolution?

Or to make a mapping from your own coordinate system to the screen coordinates?

If the latter, then you should be aware that trying to map a square coordinate space (1000x1000) onto a non-square display (which monitors generally are; 4:3 ratio) is going to squish things.

Share this post


Link to post
Share on other sites
OK! so I changed my mind.

I am using 800x600 and have coordinates like top left is (0,0) while bottom right is (800,600).

If I switch to 1024x768 and I want the bottom right to be (800,600) is that possible or not.

I only need a resolution independent program :(

Share this post


Link to post
Share on other sites
A x B is the actual resolution (i.e. 1024 x 768)
C x D is the "faked" resolution (i.e. 800 x 600)
X and Y are the actual coordinates (i.e. (896, 672))

get the ratio of the real coordinates you have to the screen size, and then multiply them by your virtual resolution.

for example, let's choose the point (896, 672) in your 1024x768 screen.

896 / 1024 = 0.875
672 / 768 = 0.875

0.875 x 800 = 700
0.875 x 600 = 525

so, in your virtual 800x600 screen, the point would be at (700, 525).

you can also do this in the other direction, the important part is that you find the ratio and then apply it to the resolution you are aiming for.

Share this post


Link to post
Share on other sites
Quote:
Original post by krez
A x B is the actual resolution (i.e. 1024 x 768)
C x D is the "faked" resolution (i.e. 800 x 600)
X and Y are the actual coordinates (i.e. (896, 672))

get the ratio of the real coordinates you have to the screen size, and then multiply them by your virtual resolution.

for example, let's choose the point (896, 672) in your 1024x768 screen.

896 / 1024 = 0.875
672 / 768 = 0.875

0.875 x 800 = 700
0.875 x 600 = 525

so, in your virtual 800x600 screen, the point would be at (700, 525).

you can also do this in the other direction, the important part is that you find the ratio and then apply it to the resolution you are aiming for.


Thanks ... it worked but what if I have to scale some objects. It does work fine ... but when I scale (eg) a sprite ... there are some problems. I have tried several options like multiplying with the scale value etc ... but didn't get any thing working for scale.

Any clues ?

Share this post


Link to post
Share on other sites

This topic is 4837 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

Sign in to follow this