Open xshrer opened 2 years ago
Jacob and Javidx9 gave the solution on dicord
the winapi gives unsigned values for the mouse position.this can cause some issues when multiple screens are connected,x and y coordinates can have negative values .
so we manually get x and y values from lparam(using bit shifting and masking)
and then use the evil bit hack to tell the system that the variable is singed .Watch the youtube link below from 12:09 to understand the bit hack.
Fast Inverse Square Root — A Quake III Algorithm https://www.youtube.com/watch?v=p8u_k2LIZyo&list=TLPQMTgxMjIwMjEGAriC-8ygvQ&index=7
Javidx9 explains the bit shifting and masking quite beautifully in the nes emulater tutorial https://www.youtube.com/watch?v=F8kx56OZQhg&t=1584s
what is happening here,and why is this method being used instead of simple type casting https://github.com/OneLoneCoder/olcPixelGameEngine/blob/7a20524ae4725120b38b9967583ff1c1e08da286/olcPixelGameEngine.h#L4477