Archived

This topic is now archived and is closed to further replies.

Coordinates irrespective of display mode?

This topic is 5245 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 just wondering... How can i scale some logical coordinates to map on to my display mode. I mean i am working with a logical coordinate system that is always 1000x1000 i.e the point (1000,1000) will always be the bottom right of the screen no matter what the physical display mode is. No i am a little dumb when it comes to scaling values but how could i scale this to a physical value, depending on the actual display mode. For the above point again 1000,1000 would map to 800,600 if the display mode was 800x600 but 1024,768 if the display mode was 1024x768. Any help welcome Thanks.

Share this post


Link to post
Share on other sites
You could do int actual_x = int(((float)x/1000.0f) * (float)screen_width); All that casting perhaps isn't necessary, but I think it would give you a better result (at the very least, it's more readable). And the same formula should apply to the y axis. Note that this is going to be very slow if you're trying to plot any significant number of coordinates per frame. I've always found it easier to base all my measurements off of the current display size, instead of making a "virtual" display.

Edit - Added some more parentheses.

--------------------


You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming

You are unique. Just like everybody else.

"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Yanroy@usa.com

[edited by - Yanroy on August 7, 2003 10:15:09 AM]

[edited by - Yanroy on August 7, 2003 10:15:26 AM]

Share this post


Link to post
Share on other sites