Fixed timing
This commit is contained in:
parent
762c994e5c
commit
0bba09a055
@ -85,7 +85,7 @@ void Input::handleMovementKeys(Renderer& ren) {
|
|||||||
}
|
}
|
||||||
const auto right = glm::normalize(glm::cross(forward, glm::vec3(0.0, 1.0, 0.0)));
|
const auto right = glm::normalize(glm::cross(forward, glm::vec3(0.0, 1.0, 0.0)));
|
||||||
auto speed = glfwGetKey(in, GLFW_KEY_LEFT_SHIFT)? 2.0f : 1.0f;
|
auto speed = glfwGetKey(in, GLFW_KEY_LEFT_SHIFT)? 2.0f : 1.0f;
|
||||||
speed *= ren.speed;
|
speed *= ren.speed * ren.frametime / 8.0;
|
||||||
|
|
||||||
if(glfwGetKey(in, GLFW_KEY_UP)) {
|
if(glfwGetKey(in, GLFW_KEY_UP)) {
|
||||||
ren.cam.theta -= 0.01;
|
ren.cam.theta -= 0.01;
|
||||||
|
|||||||
@ -60,7 +60,7 @@ void Swapchain::create(vk::SwapchainKHR old_swapchain) {
|
|||||||
/* see if this allows see through windows on Wayland */
|
/* see if this allows see through windows on Wayland */
|
||||||
.compositeAlpha = vk::CompositeAlphaFlagBitsKHR::eOpaque,
|
.compositeAlpha = vk::CompositeAlphaFlagBitsKHR::eOpaque,
|
||||||
/* waits for refresh (V-Sync), consider playing with relaxed fifo later on*/
|
/* waits for refresh (V-Sync), consider playing with relaxed fifo later on*/
|
||||||
// .presentMode = vk::PresentModeKHR::eFifo,
|
// .presentMode = vk::PresentModeKHR::eFifoRelaxed,
|
||||||
.presentMode = vk::PresentModeKHR::eMailbox,
|
.presentMode = vk::PresentModeKHR::eMailbox,
|
||||||
.clipped = VK_TRUE,
|
.clipped = VK_TRUE,
|
||||||
.oldSwapchain = old_swapchain,
|
.oldSwapchain = old_swapchain,
|
||||||
|
|||||||
@ -127,7 +127,7 @@ UI::UI(Renderer* ren) : ren(ren), dev(ren->dev) {
|
|||||||
console->System().RegisterVariable("visibility_testing", ren->visibility_testing, csys::Arg<bool>("value"));
|
console->System().RegisterVariable("visibility_testing", ren->visibility_testing, csys::Arg<bool>("value"));
|
||||||
console->System().RegisterVariable("flycam", ren->flycam, csys::Arg<bool>("value"));
|
console->System().RegisterVariable("flycam", ren->flycam, csys::Arg<bool>("value"));
|
||||||
console->System().RegisterVariable("speed", ren->speed, csys::Arg<float>("value"));
|
console->System().RegisterVariable("speed", ren->speed, csys::Arg<float>("value"));
|
||||||
console->System().RegisterVariable("max_fps", ren->speed, csys::Arg<float>("value"));
|
console->System().RegisterVariable("max_fps", ren->max_fps, csys::Arg<float>("value"));
|
||||||
|
|
||||||
console->System().Log(csys::ItemType::eINFO) << "Welcome to Pleascach!" << csys::endl;
|
console->System().Log(csys::ItemType::eINFO) << "Welcome to Pleascach!" << csys::endl;
|
||||||
}
|
}
|
||||||
@ -143,6 +143,7 @@ void UI::newFrame() {
|
|||||||
ImGui::Text("# of Indices: %zu", ren->n_indices);
|
ImGui::Text("# of Indices: %zu", ren->n_indices);
|
||||||
ImGui::Text("FPS: %f", ren->fps);
|
ImGui::Text("FPS: %f", ren->fps);
|
||||||
ImGui::Text("Time: %f", ren->time);
|
ImGui::Text("Time: %f", ren->time);
|
||||||
|
ImGui::Text("Speed: %f", ren->speed * ren->frametime / 8.0);
|
||||||
|
|
||||||
if(ren->in_menu)
|
if(ren->in_menu)
|
||||||
console->Draw();
|
console->Draw();
|
||||||
|
|||||||
@ -77,7 +77,7 @@ int main(int argc, char* argv[]) {
|
|||||||
ren.frametime = frame_timer.read();
|
ren.frametime = frame_timer.read();
|
||||||
ren.fps = 1000.0f / ren.frametime;
|
ren.fps = 1000.0f / ren.frametime;
|
||||||
|
|
||||||
while (frame_timer.read() < 1000 / ren.max_fps)
|
while (frame_timer.read() < 1000.0 / ren.max_fps)
|
||||||
;
|
;
|
||||||
|
|
||||||
ren.frametime = frame_timer.read();
|
ren.frametime = frame_timer.read();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user