Jump to content
  • Advertisement
Sign in to follow this  
buumchakalaka

Manage multiple resolutions

This topic is 2126 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,
this is my first post, hope you can help me with this and sorry for my begginer english :P

Im working with c++ and SDL.
I want to make a 2D game that get the user`s resolution and set it for the game screen. But the images that use in the game will have wrong size and wrong position if the resolution is bigger or smaler than the resolution at which the game is done.
So, what can I do for keep the size and position of the images at the diferent resolutions?

Thanks in advance :)

Share this post


Link to post
Share on other sites
Advertisement
You are using SDL's software rendering to draw (SDL_BlitSurface)?
In that case, just create a surface at the resolution the game is meant to be drawn at; blit to that, and stretch it to fit later. The alternative is to maintain a variable that is the ratio the player's resolution vs the expected (IE, if the player's resolution is 800x600, but the game is meant for 640x480, this variable will be 800/640 or 1.25), then multiply all rectangle's values by that variable (either pass it to each rendering function [ideal], store it in a global variable, or use a singleton), but this will likely require modifying a ton of code. Keep in mind that no matter what you do, in order to create useable mouse-input, you will need to convert real screen coordinates to expected screen coordinates (divide by the ratio mentioned above).

Share this post


Link to post
Share on other sites
Thanks you! Im going to try with this smile.png

EDIT: By the way, I found an article that have good information for this (if anyone have the same problem):
http://www.codeproject.com/Articles/293971/How-to-Correctly-Manage-Screen-Resolutions-in-Game Edited by buumchakalaka

Share this post


Link to post
Share on other sites
Also, don't stretch your GUI -- it makes things ugly.
Draw GUI after you stretch the game (and obviously, no need to convert coordinates if it's in the GUI).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!