Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float speed = 3.0f;
- float deadZone = 0.10f;
- glm::vec2 direction(0.0f);
- while (!glfwWindowShouldClose(window))
- {
- currentTime = glfwGetTime();
- deltaTime = (currentTime - lastUpdate) * 1000.0f;
- //Update logic
- inputHandler->tick(deltaTime);
- float inputX, inputY;
- inputX = inputHandler->getGamepad(0)->getAxes(AXIS::HORIZONTAL);
- inputY = inputHandler->getGamepad(0)->getAxes(AXIS::VERTICAL);
- float magnitude = sqrtf((inputX * inputX) + (inputY * inputY));
- if (magnitude > deadZone) //Radial dead zone detection
- {
- //Could the stutter be caused by type casting?
- direction.x += inputX * float((speed * deltaTime) / 1000.0f);
- direction.y += inputY * float((speed * deltaTime) / 1000.0f);
- }
- ... //Set vertex values and UV coord
- //Set the matrix values according to the joystick input
- glm::mat4 MVP(1.0f);
- MVP = glm::translate(MVP, glm::vec3(direction, 0.0f));
- glUniformMatrix4fv(mvpID, 1, GL_FALSE, glm::value_ptr(MVP));
- glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
- ...
- }
- #version 150
- in vec2 vertexPosition_modelspace;
- in vec2 UV;
- uniform mat4 MVP;
- out vec2 vUV;
- void main() {
- vUV = UV;
- gl_Position = MVP * vec4(vertexPosition_modelspace, 0, 1);
- }
Add Comment
Please, Sign In to add comment