Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6821

Can't properly scale down mouse coordinates to a smaller RenderTarget

$
0
0

@kameko wrote:

I've been trying for ages now to properly map my mouse coordinates to my game world, which is smaller than the screen and stretched out using a RenderTarget2D. Here's the relevant code if anyone wants to take a look: https://pastebin.com/YKpQb2pt
The relevant calculation is on line 39, with the matrix transformation.

The issue I'm having is the calculation is off by a margin, and that margin increases as the mouse moves from the upper-left of the window to the lower-right. If the window isn't the same size as the RenderTarget for the game world, it'll make boarders on either the left/right or top/bottom. If it's left/right the mouse coordinates lag behind the actual mouse, and if it's top/bottom they're ahead. No matter what I try I can't get it right.

Nobody's been able to help me with this. I'm almost starting to think this is somehow impossible, but if that's the case, how do I render my game in a larger window while being able to use a mouse? Is this really something that nobody in the history of XNA/MonoGame has ever done? Has every XNA/MonoGame game in existence been rendered in a window that's exactly the same resolution as the game? Even tiny 600x800 games like mine that would be microscopic on modern 4K monitors? I don't know what I'm doing wrong, and it would be miserable for me to have to give up my mouse or forcefully render my game in it's native resolution.

Thanks for reading, I've asked this question around the internet about a dozen times over a few months but I hope someone has some sort of solution for me.

Posts: 3

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 6821

Trending Articles