Resolution Independent Programming

Started by
6 comments, last by Dreddnafious Maelstrom 19 years, 8 months ago
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 :)
Advertisement
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

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.
"We should have a great fewer disputes in the world if words were taken for what they are, the signs of our ideas only, and not for things themselves." - John Locke
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!
Play red alert 2, they do a real good job, but they limmit it to about 4 or 5 resoultions sizewise.
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
I have played it but haven't noticed it. I will play it again and notice it this time for sure.

Thanks!
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).
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
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.
"Let Us Now Try Liberty"-- Frederick Bastiat

This topic is closed to new replies.

Advertisement