# Resolution Independent Programming

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

## Recommended Posts

What is the best way to do resolution independent programming. - When in FullScreen mode we change resolutions, how are we suppose to draw the objects in the bigger resolution (let's say from 800x600 to 1024x768). Objects are obviously small and the screen size and space increases along with resolution increase. - Second in Windowed mode, if the user resizes the Window, how can you resize the objects along with the proportion of the window size? Any clues or hints are welcome :)

##### Share on other sites
use the window sizes for this. Like Rectangle from current window center (w/2, h/2) that extends out from center by 75%(center + (w/2)*75%, etc), instead of programming in constant values such as rectangle at (128, 128, 512, 384).

Hope that helped

##### Share on other sites
If all of your objects are represented using coordinates relative to window/screen size, instead of absolute coordinates, then much of this will become easy. Just make everything go from 0.0 (one edge of the window/screen) to 1.0 (the opposite edge). Values above or below this would be beyond the edge of the window/screen. If you need to keep track of the window/screen ratio (width/height), however, I suppose it gets a bit more complicated, but the above method will still be a large part of the solution.

So if everything is in those relative coordinates, then you only need to calculate actual screen coordinates during the very last step, in order to get the objects onto the screen. Or if you're using a 3D API, you should be able to set up the projection matrix to handle that for you, and you'll never have to worry about it during drawing at all.

##### Share on other sites
Yes ... I am using the same thing as coordinates. Top left of the Window is 0 while top right depends upon the size ... if its 800, then 800 etc.

I think it would be great to not to re-size all the objects in the game with resolution increase. I would rather show some bigger world space then an ordinary 800x600.

That will work.

Thanks!

##### Share on other sites
Play red alert 2, they do a real good job, but they limmit it to about 4 or 5 resoultions sizewise.

##### Share on other sites
I have played it but haven't noticed it. I will play it again and notice it this time for sure.

Thanks!

##### Share on other sites
Essentially you map the coordinates like everybody said, but for 2d data (HUD in 3d games or everything in 2d games) games usually include 2 or 3 versions of all the graphics (for say 800*600, 1152*864, 1600*1200) and then it will stretch the graphic closest to the current resolution (or maybe even blend between the one below and one above).

##### Share on other sites
if you code your own HUD you should make it res independent as well, as it requires a total of maybe 10 lines of code.

1. 1
2. 2
3. 3
Rutin
25
4. 4
5. 5
khawk
14

• 11
• 11
• 23
• 10
• 9
• ### Forum Statistics

• Total Topics
633649
• Total Posts
3013117
×