Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Bit manipulation returning wrong data

$
0
0
Hi, I'm trying to return two 32 bit int values (_mouseX and _mouseY) from a function by packing them into a 64 bit value first, then unpacking them elsewhere in the code when I use them. However, the data is completely incorrect when I get it through this function. I already confirmed that the original _mouseX and _mouseY data and the SetOrientation functions are fine; the problem is somewhere in the bitshifting or maybe casting or teh types Im using in this GetMouseXY function. Could you please have a look? Thanks. long int Input::GetMouseXY() { return (_mouseX << 32) |_mouseY; } long int mouseY = pInput->GetMouseXY() & 0xFFFFFFFF; long int mouseX = (pInput->GetMouseXY() >> 32) & 0xFFFFFFFF; _CamPosition->SetOrientation(XMFLOAT3((float)mouseY, (float)mouseX, 0.f));

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>