Jump to content
  • Advertisement
Sign in to follow this  
vicer1234

Screen resolution

This topic is 3612 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, I am making a gui for my application where there are options for dialogs to slide in and out...I made this gui setting a resolution of 1024X768 and give static values to sliding...Know when i change the screen resolutionto say 800x600 or 1400X900 or 1280X1024 the sliding is not comming proper..boz of static positions..How to get a general formula to fix this issue...so that i can run in any resolution......

Share this post


Link to post
Share on other sites
Advertisement
What you need to do is work out how much room the visuals take up, as well as their offsets, in a percentage of the current width and height of the display. For instance, say you have a text box that is 150 pixels wide, and 30 pixels high in your 1024x768 pixel display. Divide the 150 by 1024, and you get roughly 0.1465 (14.65% of the total width), divide 30 by 768 and you get roughly 0.0391 (3.9% of the total height). Multiply those values by the current width and height, and you now have the dimensions of your visuals. Unfortunately, you'll have to recalculate the sizes every single time the dimensions of the window change, but you can usually use one small function to set the offsets and sizes for all of your visuals, and another to iterate through them all.

If your GUI's using Windows' components (or something similar), you might want to ensure that the text boxes have a minimum height to ensure that they can actually display the text, but aside from that, percentages are about the only way to go.

Share this post


Link to post
Share on other sites
Sure, there's another way... Define a set of static values for the different resolutions. Doesn't quite scale too well if people try using unsupported resolutions, but that's the only other way to do it.

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!