# Screen Resolution (again)

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

## 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 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 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 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 on other sites
Also, realize that if the upper left corner is (0, 0) your bottom right corner should be (799, 599) not (800, 600)

##### Share on other sites
This might result in some slightly odd graphics, though, due to rounding...at least it would if I'm thinking of this correctly.

##### Share on other sites
Quote:
 Original post by krezA 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.875672 / 768 = 0.8750.875 x 800 = 7000.875 x 600 = 525so, 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 on other sites
if you were using OpenGL then you could set the project matrix up so that an ortho view goes from 0,0 => 800,600 units regardless of the screen size and let the system sort out the scaling for you

##### Share on other sites
No ... I an using DX.

##### Share on other sites
DX via D3D or via the old DirectDraw interface?
Coz, if its via D3D I'd be surprised if there wasnt a way to setup and orthographic project to do above as OpenGL does.

• 18
• 20
• 12
• 21
• 16