Jump to content

  • Log In with Google      Sign In   
  • Create Account

Scaling Graphics for different Resolutions

Old topic!

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

#1 destructivArts   Members   -  Reputation: 205


Posted 22 August 2012 - 02:06 PM


My question is this:

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


#2 Bacterius   Crossbones+   -  Reputation: 9305


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.



- Pessimal Algorithms and Simplexity Analysis

#3 DekuTree64   Members   -  Reputation: 986


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


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!