Jump to content

  • Log In with Google      Sign In   
  • Create Account

Scaling Graphics for different Resolutions


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 destructivArts   Members   -  Reputation: 205

Like
0Likes
Like

Posted 22 August 2012 - 02:06 PM

Recently a friend tried to run a game I am creating on his computer. We both have mac's but his being a laptop had a much different resolution than my desktop. When he tried to run it all the graphics were scaled poorly, as in I have a function that scales the graphics, but not uniformly.

My question is this:
What is the best way to allow the game to run on different resolutions?
The only option I see is to scale the graphics uniformly and allow the screen to show less.
ie. On a higher resolution computer, scale everything up uniformly so the backgrounds either fit perfectly or are larger than the screen.

Any help is much appreciated,
Thanks,
Peter
-------------------------------------
"Other than that, I have no opinion."
My Blog - Check it Out

Sponsor:

#2 Bacterius   Crossbones+   -  Reputation: 8945

Like
0Likes
Like

Posted 22 August 2012 - 09:32 PM

What are you using to display stuff? SDL, DirectX, .........?

You're not supposed to render at one resolution and then resize as needed, you should get the screen resolution at the start of the program (or better yet, via some kind of configuration option) and render at that resolution. In 3D games you do this by abstracting resolution information away by dividing all widths by the total screen width and all heights by the total screen height (so you then have coordinates between 0 and 1) and just using the aspect ratio to render.

YMMV depending on your answer to my question.

Also, it's possible to resize stuff like textures to an arbitrary resolution, by interpolating (but there should be a function available in whatever library you use to render to do this for you, probably along the lines of StretchBlt or something). The new resolution doesn't have to be a multiple of the old one for it to work.

The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis


#3 DekuTree64   Members   -  Reputation: 986

Like
0Likes
Like

Posted 22 August 2012 - 09:46 PM

Yep, it's a problem.

My preference for 2D side scrollers and such is to work in low native resolution (like 320x240), and scale up by 2x, 3x, 4x, etc. until it's as big as can fit on the screen, and just leave the border black (unless it's in a window and then you don't need a border).

Another option for 2D games is to have a larger "viewport" in high resolution... so you can just see more of the map on screen. But it's annoying as a designer not to have control over how far ahead the player can see, or how tall the screen is relative to a background (for doing levels with no vertical camera movement).

For single screen games like tetris, you can do the integer scale up thing, but have a border image instead of just black. The border image will get chopped off at the edges of the screen depending on how well matched the resolutions are, but it's just there to fill space so who cares if you can't see all of it.

For 3D or vector graphics games, you can do actual resolution independence. Make HUD graphics where they position relative to the corners of the screen rather than spanning from one side to the other, and possibly use different sized fonts for text boxes in different resolutions so they look consistent.

#4 nfries88   Members   -  Reputation: 259

Like
0Likes
Like

Posted 23 August 2012 - 10:28 AM

If you're using DirectX or OpenGL directly, render to texture is the best solution. Render to a fixed-sized texture same as you would normally render to the window, then stretch that texture to fit the game window.

If you're using SDL (1.2 probably), then render to a fixed-size Surface then later stretch that surface to fit SDL's main screen surface (you may need SDL_gfx for this)
Looking for paid or open-source C++ programming work. Been programming since 2005. No degree.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS