Exemplo n.º 1
0
 public Pixel GetPixel(VectorI2d a)
 {
     return(GetPixel(a.x, a.y));
 }
Exemplo n.º 2
0
 public bool SetPixel(VectorI2d a, Pixel p)
 {
     return(SetPixel(a.x, a.y, p));
 }
Exemplo n.º 3
0
        public void UpdateInput(VectorI2d vViewPos, VectorI2d vWindowSize, VectorI2d vScreenSize)
        {
            Action <HWButton[], bool[], bool[], UInt32> ScanHardware = (pKeys, pStateOld, pStateNew, nKeyCount) =>
            {
                for (UInt32 i = 0; i < nKeyCount; i++)
                {
                    pKeys[i].bPressed  = false;
                    pKeys[i].bReleased = false;
                    if (pStateNew[i] != pStateOld[i])
                    {
                        if (pStateNew[i])
                        {
                            pKeys[i].bPressed = !pKeys[i].bHeld;
                            pKeys[i].bHeld    = true;
                        }
                        else
                        {
                            pKeys[i].bReleased = true;
                            pKeys[i].bHeld     = false;
                        }
                    }
                    pStateOld[i] = pStateNew[i];
                }
            };

            ScanHardware(pKeyboardState, pKeyOldState, pKeyNewState, 256);
            ScanHardware(pMouseState, pMouseOldState, pMouseNewState, nMouseButtons);

            // Mouse coords come in screen space
            // But leave in pixel space

            // Full Screen mode may have a weird viewport we must clamp to
            if (vMousePos.x != vMousePosCache.x || vMousePos.y != vMousePosCache.y)
            {
                int x = vMousePosCache.x - vViewPos.x;
                int y = vMousePosCache.y - vViewPos.y;
                vMousePosCache.x = (Int32)(((float)x / (float)(vWindowSize.x - (vViewPos.x * 2)) * (float)vScreenSize.x));
                vMousePosCache.y = (Int32)(((float)y / (float)(vWindowSize.y - (vViewPos.y * 2)) * (float)vScreenSize.y));
                if (vMousePosCache.x >= (Int32)vScreenSize.x)
                {
                    vMousePosCache.x = vScreenSize.x - 1;
                }
                if (vMousePosCache.y >= (Int32)vScreenSize.y)
                {
                    vMousePosCache.y = vScreenSize.y - 1;
                }
                if (vMousePosCache.x < 0)
                {
                    vMousePosCache.x = 0;
                }
                if (vMousePosCache.y < 0)
                {
                    vMousePosCache.y = 0;
                }

                // Cache mouse coordinates so they remain consistent during frame
                vMousePos.assign(vMousePosCache);
            }
            nMouseWheelDelta      = nMouseWheelDeltaCache;
            nMouseWheelDeltaCache = 0;
        }