Exemple #1
0
void CApplication::MouseInputCallback(int iButton, tinker_mouse_state_t iState)
{
	if (iState == 1)
	{
		if (m_flLastMousePress < 0 || GetTime() - m_flLastMousePress > 0.25f)
			MouseInput(iButton, iState);
		else
			MouseInput(iButton, TINKER_MOUSE_DOUBLECLICK);
		m_flLastMousePress = GetTime();
	}
	else
		MouseInput(iButton, iState);
}
Exemple #2
0
bool TDCamera::onTick(float fElapsedTime, CTerrain* terrain)
{
	static float fTime(0.f);
	KeyboardInput(fElapsedTime);
	if (m_bDragging || m_bFollowing) MouseInput();
	UpdateAxis();
	if (m_bFollowing) {
		if (m_bGravity) m_pvPos.y = terrain->GetHeight(m_pvPos.x, m_pvPos.z); 
		m_vecEyePosition = m_pvPos - m_vecDirection * m_fFollowDist 
			+ m_vOffset - m_vecRight * (.5f * m_fFollowDist + .5f);
		D3DXMatrixRotationY(m_pTransform, m_fYaw - D3DX_PI);
		m_pTransform->_41 = m_pvPos.x; m_pTransform->_42 = m_pvPos.y; m_pTransform->_43 = m_pvPos.z;
	}
	ApplyCamera();
	if (m_bFollowing) {
		std::string action;
		if (m_bMoving) {
			if (m_bRunning) action = "run";
			else action = "walk";
		} else action = "stand";
		if (GetAsyncKeyState(VK_LBUTTON) & 0x8000) {
			action = "attack";
			fTime += fElapsedTime;
			// Animation Specific Parameters
			if (fTime > 1.2f) {
				fTime = 0.f;
				return true;
			}
		} else fTime = .6f;
		m_pPlayer->SetAction(action.c_str(), true, 5.f, .5f);
	}
	return false;
}
void Ready::Execute(float totalTime, Bird* pBird)
{

	
	MouseInput(pBird);
	

	totalTime;
	pBird;
}
Exemple #4
0
void Player::Update(sf::RenderWindow &renderWindow)
{
	KeyboardInput();
	MouseInput(renderWindow);

	origin = sf::Vector2f(position.x + (width / 2), position.y + (height / 2));

	for (int i = 0; i < projectiles.size(); i++)
	{
		projectiles[i].Update();
	}
}
Exemple #5
0
MouseInput SDLInput::dequeueMouseInput()
{
    MouseInput mouseInput;

    if (mMouseInputQueue.empty())
        return MouseInput();

    mouseInput = mMouseInputQueue.front();
    mMouseInputQueue.pop();

    return mouseInput;
}
Exemple #6
0
//----读取触摸点坐标-----------------------------------------------------------
//功能: 读取stmpe811采集到的触摸点坐标,如果有多点,则平均之
//参数: touch_data,采集到的坐标
//返回: 1=触摸笔按下,0=触摸笔提起,
//-----------------------------------------------------------------------------
static ufast_t read_touch_data(struct tagSingleTouchMsg *touch_data)
{
	 static s32 x=0,y=0,z=0;

	if(ts_is_down())
	{
		ts_get_data_raw(&x,&y);
		z =1;
		ts_translate_data(&x,&y);
		touch_data->x =x;
		touch_data->y =y;
        touch_data->z = z;

        return 1;

	}
	MouseInput(x,y,0);
	return 0;

}
Exemple #7
0
    void DirectX3DInput:: dispatchMessage(HWND window, MSG message)
    {
        KeyInput keyInput;
        MouseInput mouseInput;
        WPARAM wParam = message.wParam;
        LPARAM lParam = message.lParam;

        switch (message.message)
        {
            case WM_SYSKEYDOWN:
            case WM_KEYDOWN:
                {
                    unsigned char kbstate[256];
	                GetKeyboardState(kbstate);
                    keyInput.setKey(Key(convertKeyCharacter(wParam, lParam, kbstate)));
                    keyInput.setType(KeyInput::Pressed);
                    keyInput.setShiftPressed(kbstate[VK_SHIFT] & 0x80);
	                keyInput.setControlPressed(kbstate[VK_CONTROL] & 0x80);
	                keyInput.setAltPressed(kbstate[VK_MENU] & 0x80);
                    keyInput.setNumericPad(wParam >= VK_NUMPAD0
                                            && wParam <= VK_DIVIDE);

                    mKeyInputQueue.push(keyInput);
                }
                break;
            case WM_SYSKEYUP:
            case WM_KEYUP:
                {
                    unsigned char kbstate[256];
	                GetKeyboardState(kbstate);
                    keyInput.setKey(Key(convertKeyCharacter(wParam, lParam, kbstate)));
                    keyInput.setType(KeyInput::Released);
                    keyInput.setShiftPressed(kbstate[VK_SHIFT] & 0x80);
	                keyInput.setControlPressed(kbstate[VK_CONTROL] & 0x80);
	                keyInput.setAltPressed(kbstate[VK_MENU] & 0x80);
                    keyInput.setNumericPad(wParam >= VK_NUMPAD0
                                            && wParam <= VK_DIVIDE);

                    mKeyInputQueue.push(keyInput);
                }
                break;
            case WM_LBUTTONDOWN:
                {
                    int x = (int)((signed short)(LOWORD(lParam)));
                    int y = (int)((signed short)(HIWORD(lParam)));
               
                    mouseInput.setX(x);
                    mouseInput.setY(y);
                    mouseInput.setButton(MouseInput::Left);
                    mouseInput.setType(MouseInput::Pressed);
                    mouseInput.setTimeStamp(GetTickCount());
                    mMouseInputQueue.push(mouseInput);
                    mMouseDown = true;
                    SetCapture(window);
                    break;
                }
            case WM_MBUTTONDOWN:
                {
                    int x = (int)((signed short)(LOWORD(lParam)));
                    int y = (int)((signed short)(HIWORD(lParam)));
                   
                    mouseInput.setX(x);
                    mouseInput.setY(y);
                    mouseInput.setButton(MouseInput::Middle);
                    mouseInput.setType(MouseInput::Pressed);
                    mouseInput.setTimeStamp(GetTickCount());
                    mMouseInputQueue.push(mouseInput);
                    mMouseDown = true;
                    SetCapture(window);
                    break;
                }
            case WM_RBUTTONDOWN:
                {
                    int x = (int)((signed short)(LOWORD(lParam)));
                    int y = (int)((signed short)(HIWORD(lParam)));
                   
                    mouseInput.setX(x);
                    mouseInput.setY(y);
                    mouseInput.setButton(MouseInput::Right);
                    mouseInput.setType(MouseInput::Pressed);
                    mouseInput.setTimeStamp(GetTickCount());
                    mMouseInputQueue.push(mouseInput);
                    mMouseDown = true;
                    SetCapture(window);
                    break;
                }
            case WM_LBUTTONUP:
                {
                    int x = (int)((signed short)(LOWORD(lParam)));
                    int y = (int)((signed short)(HIWORD(lParam)));
                   
                    mouseInput.setX(x);
                    mouseInput.setY(y);
                    mouseInput.setButton(MouseInput::Left);
                    mouseInput.setType(MouseInput::Released);
                    mouseInput.setTimeStamp(GetTickCount());
                    mMouseInputQueue.push(mouseInput);
                    mMouseDown = false;
                    ReleaseCapture();
                    break;
                }
            case WM_MBUTTONUP:
                {
                    int x = (int)((signed short)(LOWORD(lParam)));
                    int y = (int)((signed short)(HIWORD(lParam)));
                   
                    mouseInput.setX(x);
                    mouseInput.setY(y);
                    mouseInput.setButton(MouseInput::Middle);
                    mouseInput.setType(MouseInput::Released);
                    mouseInput.setTimeStamp(GetTickCount());
                    mMouseInputQueue.push(mouseInput);
                    mMouseDown = false;
                    ReleaseCapture();
                    break;
                }
            case WM_RBUTTONUP:
                {
                    int x = (int)((signed short)(LOWORD(lParam)));
                    int y = (int)((signed short)(HIWORD(lParam)));
                  
                    mouseInput.setX(x);
                    mouseInput.setY(y);
                    mouseInput.setButton(MouseInput::Right);
                    mouseInput.setType(MouseInput::Released);
                    mouseInput.setTimeStamp(GetTickCount());
                    mMouseInputQueue.push(mouseInput);
                    mMouseDown = false;
                    ReleaseCapture();
                    break;
                }
            case WM_MOUSEMOVE:
                {
                    int x = (int)((signed short)(LOWORD(lParam)));
                    int y = (int)((signed short)(HIWORD(lParam)));
                    /*
                    POINT point = {x,y};
                    ScreenToClient(hWnd, &point);
                   
                    RECT rect; 
                    GetClientRect(hWnd, &rect);*/
                    /*
                    if (!mMouseDown
                        && mMouseInWindow
                        && (point.x < 0 
                            || point.y < 0 
                            || point.x > rect.right 
                            || point.y > rect.bottom))
                    {
                        mouseInput.setX(-1);
                        mouseInput.setY(-1);
                        mouseInput.setButton(MouseInput::Empty);
                        mouseInput.setType(MouseInput::Moved);
                        mouseInput.setTimeStamp(GetTickCount());
                   
                        mMouseInputQueue.push(mouseInput);
                        mMouseInWindow = false;
                    }
                    else if (mMouseDown
                              || (point.x >= 0 
                                    && point.y >= 0 
                                    && point.x < rect.right 
                                    && point.y < rect.bottom))
                    {
                        mouseInput.setX(point.x);
                        mouseInput.setY(point.y);
                        mouseInput.setButton(MouseInput::Empty);
                        mouseInput.setType(MouseInput::Moved);
                        mouseInput.setTimeStamp(GetTickCount());
                   
                        mMouseInputQueue.push(mouseInput);
                    }
                    
                    mMouseInWindow = point.x >= 0 
                                        && point.y >= 0 
                                        && point.x < rect.right 
                                        && point.y < rect.bottom;
                */
                        mouseInput.setX(x);
                        mouseInput.setY(y);
                        mouseInput.setButton(MouseInput::Empty);
                        mouseInput.setType(MouseInput::Moved);
                        mouseInput.setTimeStamp(GetTickCount());
                   
                        mMouseInputQueue.push(mouseInput);
                    break;
                }
            // For some reason WM_MOUSEWHEEL isn't defined at some systems
            // (including mine), but 0x020A should be equal to the WM_MOUSEWHEEL
            // value.
            case 0x020A: // WM_MOUSEWHEEL         
                int mouseZ = (short)HIWORD(wParam);
                int x = (int)((signed short)(LOWORD(lParam)));
                int y = (int)((signed short)(HIWORD(lParam)));
                POINT point = {x,y};
                ScreenToClient(window, &point);

                RECT rect; 
                GetClientRect(window, &rect);

                if (point.x < 0 
                    || point.y < 0 
                    || point.x > rect.right 
                    || point.y > rect.bottom)
                {
                    break;
                }

                // Mouse wheels doesn't have to move 120 units anymore, new
                // mouses can move less than 120, therefore we need to check
                // that the mouse has at least moved 120 units before we push
                // an input event.
                if (mLastMouseZ + mouseZ >= 120)
                {
                    mMouseInputQueue.push(MouseInput(MouseInput::Empty,
                                                     MouseInput::WheelMovedUp,
                                                     point.x,
                                                     point.y,
                                                     GetTickCount()));
                    mLastMouseZ = 0;
                }
                else if (mLastMouseZ + mouseZ <= -120)
                {     
                    mMouseInputQueue.push(MouseInput(MouseInput::Empty,
                                                     MouseInput::WheelMovedDown,
                                                     point.x,
                                                     point.y,
                                                     GetTickCount()));
                    mLastMouseZ = 0;
                }
                else
                {
                    mLastMouseZ += mouseZ;
                }

                break;
        } // end switch
    }
    void  HGEInput::pollMouseInput()
    {
        float curMouseX, curMouseY;
        int mouseWheel;

        bool leftBtn, rightBtn, centerBtn;

        mHGE->Input_GetMousePos(&curMouseX, &curMouseY);
        mouseWheel = mHGE->Input_GetMouseWheel();

        leftBtn = mHGE->Input_GetKeyState(HGEK_LBUTTON);
        rightBtn = mHGE->Input_GetKeyState(HGEK_RBUTTON);
        centerBtn = mHGE->Input_GetKeyState(HGEK_MBUTTON);

        // Check mouse movement
        if (mMouseX != curMouseX 
            || mMouseY != curMouseY)
        {
            mMouseInputQueue.push(MouseInput(MouseInput::Empty,
                                             MouseInput::Moved,
                                             curMouseX,
                                             curMouseY,
                                             0));
     
            mMouseX = curMouseX;
            mMouseY = curMouseY;
        }

        // Check mouse wheel
        if (mouseWheel > 0)
        {
            mMouseInputQueue.push(MouseInput(MouseInput::Empty,
                                             MouseInput::WheelMovedUp,
                                             curMouseX,
                                             curMouseY,
                                             0));
        }
        else if (mouseWheel < 0)
        {
            mMouseInputQueue.push(MouseInput(MouseInput::Empty,
                                             MouseInput::WheelMovedDown,
                                             curMouseX,
                                             curMouseY,
                                             0));
        }

        //check mouse buttons
        if (!mLeftMouseButtonDown && leftBtn)
        {
            mMouseInputQueue.push(MouseInput(MouseInput::Left,
                                             MouseInput::Pressed,
                                             curMouseX,
                                             curMouseY,
                                             0));
        }
        else if (mLeftMouseButtonDown && !leftBtn )
        {
            mMouseInputQueue.push(MouseInput(MouseInput::Left,
                                             MouseInput::Released,
                                             curMouseX,
                                             curMouseY,
                                             0));
        }
        else if (!mRightMouseButtonDown && rightBtn)
        {
            mMouseInputQueue.push(MouseInput(MouseInput::Right,
                                             MouseInput::Pressed,
                                             curMouseX,
                                             curMouseY,
                                             0));
        }
        else if (mRightMouseButtonDown &&  !rightBtn)
        {
            mMouseInputQueue.push(MouseInput(MouseInput::Right,
                                             MouseInput::Released,
                                             curMouseX,
                                             curMouseY,
                                             0));
        }
        else if (!mMiddleMouseButtonDown && centerBtn)
        {
            mMouseInputQueue.push(MouseInput(MouseInput::Middle,
                                             MouseInput::Pressed,
                                             curMouseX,
                                             curMouseY,
                                             0));
        }
        else if (mMiddleMouseButtonDown && !centerBtn)
        {
            mMouseInputQueue.push(MouseInput(MouseInput::Middle,
                                             MouseInput::Released,
                                             curMouseX,
                                             curMouseY,
                                             0));
        }

        mLeftMouseButtonDown  = leftBtn;
        mRightMouseButtonDown = rightBtn;
        mMiddleMouseButtonDown  = centerBtn;
    }
    void ExtendedAllegroInput::pollMouseInput()
    {
        if (mouse_needs_poll())
        {
            poll_mouse();
        }
        int mouseX = mouse_x / 2;
        int mouseY = mouse_y / 2;
        int mouseZ = mouse_z;
        int mouseB1 = mouse_b & 1;
        int mouseB2 = mouse_b & 2;
        int mouseB3 = mouse_b & 4;

        // Check mouse movement
        if (mouseX != mLastMouseX || mouseY != mLastMouseY)
        {
            mMouseQueue.push(MouseInput(MouseInput::EMPTY,
                                        MouseInput::MOVED,
                                        mouseX,
                                        mouseY,
                                        0));
            mLastMouseX = mouseX;
            mLastMouseY = mouseY;
        }

        // Check mouse Wheel
        while (mLastMouseZ < mouseZ)
        {
            mMouseQueue.push(MouseInput(MouseInput::EMPTY,
                                        MouseInput::WHEEL_MOVED_UP,
                                        mouseX,
                                        mouseY,
                                        0));
            mLastMouseZ++;
        }

        while (mLastMouseZ > mouseZ)
        {
            mMouseQueue.push(MouseInput(MouseInput::EMPTY,
                                        MouseInput::WHEEL_MOVED_DOWN,
                                        mouseX,
                                        mouseY,
                                        0));
            mLastMouseZ--;
        }

        // Check mouse buttons
        if (!mMouseButton1 && mouseB1)
        {
            mMouseQueue.push(MouseInput(MouseInput::LEFT,
                                        MouseInput::PRESSED,
                                        mouseX,
                                        mouseY,
                                        0));
        }

        if (mMouseButton1 && !mouseB1)
        {
            mMouseQueue.push(MouseInput(MouseInput::LEFT,
                                        MouseInput::RELEASED,
                                        mouseX,
                                        mouseY,
                                        0));
        }


        if (!mMouseButton2 && mouseB2)
        {
            mMouseQueue.push(MouseInput(MouseInput::RIGHT,
                                        MouseInput::PRESSED,
                                        mouseX,
                                        mouseY,
                                        0));
        }

        if (mMouseButton2 && !mouseB2)
        {
            mMouseQueue.push(MouseInput(MouseInput::RIGHT,
                                        MouseInput::RELEASED,
                                        mouseX,
                                        mouseY,
                                        0));
        }


        if (!mMouseButton3 && mouseB3)
        {
            mMouseQueue.push(MouseInput(MouseInput::MIDDLE,
                                        MouseInput::PRESSED,
                                        mouseX,
                                        mouseY,
                                        0));
        }

        if (mMouseButton3 && !mouseB3)
        {
            mMouseQueue.push(MouseInput(MouseInput::MIDDLE,
                                        MouseInput::RELEASED,
                                        mouseX,
                                        mouseY,
                                        0));
        }

        mMouseButton1 = mouseB1;
        mMouseButton2 = mouseB2;
        mMouseButton3 = mouseB3;
    }
    void OpenLayerInput::pollMouseInput()
    {
        if (mouse_needs_poll())
        {
            poll_mouse();
        }
        int mouseX = mouse_x;
        int mouseY = mouse_y;
        int mouseZ = mouse_z;
        int mouseB1 = mouse_b & 1;
        int mouseB2 = mouse_b & 2;
        int mouseB3 = mouse_b & 4;

        // Check mouse movement
        if (mouseX != mLastMouseX || mouseY != mLastMouseY)
        {
            mMouseQueue.push(MouseInput(MouseInput::Empty,
                                        MouseInput::Moved,
                                        mouseX,
                                        mouseY,
                                        0));
            mLastMouseX = mouseX;
            mLastMouseY = mouseY;
        }

        // Check mouse Wheel
        while (mLastMouseZ < mouseZ)
        {
            mMouseQueue.push(MouseInput(MouseInput::Empty,
                                        MouseInput::WheelMovedUp,
                                        mouseX,
                                        mouseY,
                                        0));
            mLastMouseZ++;
        }

        while (mLastMouseZ > mouseZ)
        {
            mMouseQueue.push(MouseInput(MouseInput::Empty,
                                        MouseInput::WheelMovedDown,
                                        mouseX,
                                        mouseY,
                                        0));
            mLastMouseZ--;
        }

        // Check mouse buttons
        if (!mMouseButton1 && mouseB1)
        {
            mMouseQueue.push(MouseInput(MouseInput::Left,
                                        MouseInput::Pressed,
                                        mouseX,
                                        mouseY,
                                        0));
        }

        if (mMouseButton1 && !mouseB1)
        {
            mMouseQueue.push(MouseInput(MouseInput::Left,
                                        MouseInput::Released,
                                        mouseX,
                                        mouseY,
                                        0));
        }


        if (!mMouseButton2 && mouseB2)
        {
            mMouseQueue.push(MouseInput(MouseInput::Right,
                                        MouseInput::Pressed,
                                        mouseX,
                                        mouseY,
                                        0));
        }

        if (mMouseButton2 && !mouseB2)
        {
            mMouseQueue.push(MouseInput(MouseInput::Right,
                                        MouseInput::Released,
                                        mouseX,
                                        mouseY,
                                        0));
        }


        if (!mMouseButton3 && mouseB3)
        {
            mMouseQueue.push(MouseInput(MouseInput::Middle,
                                        MouseInput::Pressed,
                                        mouseX,
                                        mouseY,
                                        0));
        }

        if (mMouseButton3 && !mouseB3)
        {
            mMouseQueue.push(MouseInput(MouseInput::Middle,
                                        MouseInput::Released,
                                        mouseX,
                                        mouseY,
                                        0));
        }

        mMouseButton1 = mouseB1;
        mMouseButton2 = mouseB2;
        mMouseButton3 = mouseB3;
    }
Exemple #11
0
    void  HGEInput::pollMouseInput()
    {
        float curMouseX, curMouseY;
        int mouseWheel;

        bool leftBtn, rightBtn, centerBtn;

        mHGE->Input_GetMousePos(&curMouseX, &curMouseY);
        mouseWheel = mHGE->Input_GetMouseWheel();

        leftBtn = mHGE->Input_GetKeyState(HGEK_LBUTTON);
        rightBtn = mHGE->Input_GetKeyState(HGEK_RBUTTON);
        centerBtn = mHGE->Input_GetKeyState(HGEK_MBUTTON);

        // Check mouse movement
        if (mMouseX != curMouseX 
            || mMouseY != curMouseY )
        {
            mMouseInputQueue.push(MouseInput(MouseInput::EMPTY,
                                             MouseInput::MOVED,
                                             curMouseX,
                                             curMouseY,
                                             0));
     
            mMouseX = curMouseX;
            mMouseY = curMouseY;
        }

        // Check mouse wheel
        if (mouseWheel > 0)
        {
            mMouseInputQueue.push(MouseInput(MouseInput::EMPTY,
                                             MouseInput::WHEEL_MOVED_UP,
                                             curMouseX,
                                             curMouseY,
                                             0));
        }
        else if (mouseWheel < 0)
        {
            mMouseInputQueue.push(MouseInput(MouseInput::EMPTY,
                                             MouseInput::WHEEL_MOVED_DOWN,
                                             curMouseX,
                                             curMouseY,
                                             0));
        }

        //check mouse buttons
        if (!mLeftMouseButtonDown && leftBtn)
        {
            mMouseInputQueue.push(MouseInput(MouseInput::LEFT,
                                             MouseInput::PRESSED,
                                             curMouseX,
                                             curMouseY,
                                             0));
        }
        else if (mLeftMouseButtonDown && !leftBtn )
        {
            mMouseInputQueue.push(MouseInput(MouseInput::LEFT,
                                             MouseInput::RELEASED,
                                             curMouseX,
                                             curMouseY,
                                             0));
        }
        else if (!mRightMouseButtonDown && rightBtn)
        {
            mMouseInputQueue.push(MouseInput(MouseInput::RIGHT,
                                             MouseInput::PRESSED,
                                             curMouseX,
                                             curMouseY,
                                             0));
        }
        else if (mRightMouseButtonDown &&  !rightBtn)
        {
            mMouseInputQueue.push(MouseInput(MouseInput::RIGHT,
                                             MouseInput::RELEASED,
                                             curMouseX,
                                             curMouseY,
                                             0));
        }
        else if (!mMiddleMouseButtonDown && centerBtn)
        {
            mMouseInputQueue.push(MouseInput(MouseInput::MIDDLE,
                                             MouseInput::PRESSED,
                                             curMouseX,
                                             curMouseY,
                                             0));
        }
        else if (mMiddleMouseButtonDown && !centerBtn)
        {
            mMouseInputQueue.push(MouseInput(MouseInput::MIDDLE,
                                             MouseInput::RELEASED,
                                             curMouseX,
                                             curMouseY,
                                             0));
        }

        mLeftMouseButtonDown  = leftBtn;
        mRightMouseButtonDown = rightBtn;
        mMiddleMouseButtonDown  = centerBtn;
    }
Exemple #12
0
void Run() {

		SetKey(GLFW_KEY_ESCAPE, std::bind(&Terminate));

		deltaTime = 1.0 / 60.0;
		InitializeWindow();


		//Init values and objects

		// Build the broadphase
		btBroadphaseInterface* broadphase = new btDbvtBroadphase();

		// Set up the collision configuration and dispatcher
		btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
		btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration);

		// The actual physics solver
		btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver;

		// The world.
		btDiscreteDynamicsWorld* world = new btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration);
		world->setGravity(btVector3(0, -9.82f*METER, 0));


		Terrain testObj = Terrain(world);
		Object* terrain = &testObj;
		objects.push_back(terrain);

		Anatomy testOrg = Anatomy(world);
		Object* testOrgP = &testOrg;
		objects.push_back(testOrgP);



		//timer info for loop
		double t = 0.0f;
		double currentTime = glfwGetTime();
		double accumulator = 0.0f;

		glfwPollEvents();		//stop loop when glfw exit is called
		glfwSetCursorPos(mainThread, SCREEN_SIZE.x / 2.0f, SCREEN_SIZE.y / 2.0f);



		while (!glfwWindowShouldClose(mainThread)) {
			double newTime = glfwGetTime();
			double frameTime = newTime - currentTime;
			//std::cout << "FPS:: " <<1.0f / frameTime << std::endl;

			//setting up timers
			if (frameTime > 0.25) {
				frameTime = 0.25;
			}
			currentTime = newTime;
			accumulator += frameTime;

			//# of updates based on accumulated time

			while (accumulator >= deltaTime) {

				
				MouseInput();//update mouse change
				glfwPollEvents(); //executes all set input callbacks

				CameraInput(); //bypasses input system for direct camera manipulation
				Update(deltaTime); //updates all objects based on the constant deltaTime.

				world->stepSimulation(deltaTime, 10);

				t += deltaTime;
				accumulator -= deltaTime;
			}


			//draw
			glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


			Draw();

			glfwSwapBuffers(mainThread);
	}



	//cleanup
		delete world;
		delete solver;
		delete dispatcher;
		delete collisionConfiguration;
		delete broadphase;

}
Exemple #13
0
bool Screen::RecheckMouseInput()
	{
	return MouseInput(C4MC_Button_None, Mouse.x, Mouse.y, Mouse.dwKeys, NULL, NULL);
	}