Mouse projection, small buffer and full screen

I am up to the episode where Casey implements a radial menu. However I am having an issue with my mouse coordinates.

Due to performance, I have had to reduce the size of my back buffer to half what Casey is usin (960 x 540). That means that whilst the mouse cursor works fine when windowed, as soon as I go full screen the mouse cursor if offset (as it now extends further to the right).

I've skipped ahead to where Casey unprojects the mouse cursor however that doesn't really solve my issue.

Can anyone explain how I can translate the mouse coordinates so it works fullscreen with a small buffer size?
Haven't looked at code, so not sure if this will work - you could try to divide coordinates by 2 in platform layer when window is fullscreen. Then pass scaled down values to game layer.
Yes that works mmozeiko. Thanks. Simple solution. The only issue is that I am going to have to update this if I ever change the buffer size right?
Jay
Yes that works mmozeiko. Thanks. Simple solution. The only issue is that I am going to have to update this if I ever change the buffer size right?


More generally, you want to scale the mouse position like this:
1
2
3
4
// buffer_dim is the size of the buffer you rasterize into.
// draw_dim is the size of the viewport you blit into.
vec2 ratio = buffer_dim / draw_dim;
mouse_position *= ratio;

(Note: the mul/div here are component-wise.)

Update draw_dim when you go from windowed to fullscreen (the MONITORINFO struct will give you the dimensions of the screen).

This assumes you're doing all the math in floating point, by the way.