• Advertisement
Sign in to follow this  

Image stretching issue

This topic is 2095 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

At the risk of sounding completely out of touch with things, I'm working on windowed game (not full screen) using DirectX7 and C++.

One thing that I had left for quite some time is this issue I have where the graphics that I'm using appear too small on higher resolution screens. So I did some work to allow the window to be sized and to stretch the image to whatever size the user wants and everything worked out fine except for the buttons I have as part of the UI.

Currently, the button is placed onto the main surface I'm working on and then that surface is stretched to the window size. The button stretches with the image but I don't know how to update the co-ordinates I have in the background to recognize if the mouse is on the button and clicking it.

Any suggestions on how to approach this?

Share this post


Link to post
Share on other sites
Advertisement
I'd suggest taking the easiest approach and converting your mouse coordinates to be in the same scale as the screen before resizing.

So, if you have built your UI at say (640,480) but are rendering to a window thats (1024, 768) then convert your mouse x,y like:
((((float)x/1024.0f)*640.0f), (((float)x/768.0f)*480.0f)

Share this post


Link to post
Share on other sites
Thanks smile.png, it helped knowing that was the right direction to go. It was a ridiculously simple thing that got muddled up between the offsets that I've been using and not thinking clearly about which way the ratio should go. Problem solved.

Share this post


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

  • Advertisement