Jump to content

View more

Image of the Day

Inventory ! Va falloir trouver une autre couleur pour le cadre D: #AzTroScreenshot #screenshotsaturday https://t.co/PvxhGL7cOH
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Sign up now

Scaling Graphics for different Resolutions

4: Adsense

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   


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,
"Other than that, I have no opinion."
My Blog - Check it Out

#2 Bacterius   Members   


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.

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

#3 DekuTree64   Members   


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   


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)

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.