Translating between different Resolutions Please Help
PROBLEM:
I am starting on my pac-man clone.
I just finished my break-out clone and only allowed Full-screen (1280x1024) and windowed mode (800x600).
Now with pac-man I want to offer the user the ablity to run in any availible resolution. I am wondering how most developers appoarch this problem.
HOW I HANDELED IT BEFORE:
I programed the whole game as if it will 1280x1024 and then when it came time to actualy draw the sprites to the screen I would translate sprite cooridinates and texture size.
For Example 800/1280 = 0.625 600/1024 = 0.59
So if I were to draw a sprite at (330,455) in fullScreen in windowed mode I would draw it at (206.5,268.45)
And this works but the rounding errors create times where sprites or tiles wouldn't line up perfectly.
Is this how most people handle it or am I way off.
Some games are complety resizable for example WOW in windowed mode the window can be strecthed to any resolution and it just scales the game even if its skewed how do they do this?
Thanks alot in advance
-Marc
For my gui, I tend to only do that sort of division a few times. If tile B needs to be next to tile A, then B->left=A->right+1; Tile B might be 1/3 across the screen, in which case I'll use a division, but anything in relative position must be an integer operation from that approximation.
I imagine this will run into issues at extreme resolutions, but works good enough for my first project. I imagine full 3D things will scale much more easily. It also might be possible to render everything to a 1600x1200 offscreen surface and then resize that [or have the rendering api resize that] to the current visible resolution.
Sorry if this wasn't much help.
I imagine this will run into issues at extreme resolutions, but works good enough for my first project. I imagine full 3D things will scale much more easily. It also might be possible to render everything to a 1600x1200 offscreen surface and then resize that [or have the rendering api resize that] to the current visible resolution.
Sorry if this wasn't much help.
Hi Telastyn,
What Graphics API do you use? When you use OpenGL (with an orthogonal Projection Matrix), you can tell it that the screen coordinates shall always be interpreted between e.g. 0 and 800 for x, and 0 and 600 for y (for 800x600), no mather what the real resolution of your window is. This way you should have a perfect looking picture, no mather what resolution you are running the game at.
Direct3D should have a similar feature.
So for this purpose i would advice you to switch to a 3D API such as OpenGL or Direct3D, since resizing stuff is a lot faster, easier and cleaner in this APIs.
What Graphics API do you use? When you use OpenGL (with an orthogonal Projection Matrix), you can tell it that the screen coordinates shall always be interpreted between e.g. 0 and 800 for x, and 0 and 600 for y (for 800x600), no mather what the real resolution of your window is. This way you should have a perfect looking picture, no mather what resolution you are running the game at.
Direct3D should have a similar feature.
So for this purpose i would advice you to switch to a 3D API such as OpenGL or Direct3D, since resizing stuff is a lot faster, easier and cleaner in this APIs.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement