Thanks for the reply guys, Just have another question regarding my input. I have my keyboard input working perfectly, and very responsive. Only problem is using my mouse in conjunction with my keys, at the moment I can only do one or the other, move with my keyboard or move with my mouse. Here is my controls function i use for the program
void computeMatricesFromInputs(sf::RenderWindow& window, float time){
//get mouse position
sf::Vector2i mousePos = sf::Mouse::getPosition(window);
//set position of mouse so it does not move at all
sf::Mouse::setPosition(sf::Vector2i(400, 300), window);
//since the mouse position is always set to the center of the screen, any slight movements
// are added to the horizontal and vertical angle. (400,300) must also equal zero for the
// cube to remain still at origin, so that's why the mouse position is the subtractor to
// the center of the screen
horizontalAngle += mouseSpeed * (800/2 - mousePos.x);
verticalAngle += mouseSpeed * (600/2 - mousePos.y);
// Direction : Spherical coordinates to Cartesian coordinates conversion
direction = glm::vec3(
cos(verticalAngle) * sin(horizontalAngle),
sin(verticalAngle),
cos(verticalAngle) * cos(horizontalAngle)
);
// Right vector
right = glm::vec3(
sin(horizontalAngle - 3.14f/2.0f),
0,
cos(horizontalAngle - 3.14f/2.0f)
);
// Up vector
glm::vec3 up = glm::cross( right, direction );
// Projection matrix : 45° Field of View, 4:3 ratio, display range : 0.1 unit <-> 100 units
ProjectionMatrix = glm::perspective(45.0f, 4.0f / 3.0f, 0.1f, 100.0f);
// Camera matrix
ViewMatrix = glm::lookAt(
position, //camera position
position+direction, //look at origin
up //head up
);
if (sf::Keyboard::isKeyPressed(sf::Keyboard::W)){
position += direction * time * speed;
}else if(sf::Keyboard::isKeyPressed(sf::Keyboard::S)){
position -= direction * time * speed;
}else if(sf::Keyboard::isKeyPressed(sf::Keyboard::D)){
position += right * time * speed;
}else if(sf::Keyboard::isKeyPressed(sf::Keyboard::A)){
position -= right * time * speed;
}
}
what I can notice right now is that I check for keyboard function before my mouse, do I need to use threading in order to have these inputs work in conjunction? Thanks!