diff --git a/Input/Input.cpp b/Input/Input.cpp index 1e8e5d8..1a0ab09 100644 --- a/Input/Input.cpp +++ b/Input/Input.cpp @@ -36,8 +36,8 @@ Input::Input(INPUT_PTR in) : in(in) { glfwSetKeyCallback(in, [](GLFWwindow* in, int key, int scancode, int action, int mods) { int state = (action == GLFW_PRESS || action == GLFW_REPEAT); - static const char* action_strings[] = { "RELEASE", "PRESS", "REPEAT" }; - Log::info("Event Received:Key:\"%s\" %s\n", glfwGetKeyName(key, scancode), action_strings[action]); + // static const char* action_strings[] = { "RELEASE", "PRESS", "REPEAT" }; + // Log::info("Event Received:Key:\"%s\" %s\n", glfwGetKeyName(key, scancode), action_strings[action]); Input* input = reinterpret_cast(glfwGetWindowUserPointer(in)); InputModifierBit i_mods = eNONE; diff --git a/Renderer/Renderer.cpp b/Renderer/Renderer.cpp index 466c164..7fe6b91 100644 --- a/Renderer/Renderer.cpp +++ b/Renderer/Renderer.cpp @@ -320,17 +320,16 @@ void Renderer::draw() { const auto p = glm::perspective(glm::radians(90.0f), static_cast(sz.width) / static_cast(sz.height), 0.01f, 2000.0f); - const auto t = static_cast(frame) * 0.0167f; uniform_buffer->upload(UniformData{ .mvp = p * cam.view(), - .time = t, + .time = time, .aspect_ratio = static_cast(sz.width)/static_cast(sz.height), }); //command_buffer->draw(std::size(triangle), 1, 0, 0); - command_buffer->command_buffer.drawIndexed(models[0]->indices.size(), 1, 0, 0, 0); + command_buffer->command_buffer.drawIndexed(models[0]->indices.size(), 10, 0, 0, 0); /*command_buffer->bind(*models[1]->vertex_buffer); command_buffer->command_buffer.bindIndexBuffer(*models[1]->index_buffer, 0, vk::IndexType::eUint16); @@ -385,6 +384,7 @@ void Renderer::present() { } frame++; + time += 0.0167f * speed * static_cast(running); } Renderer::~Renderer() { diff --git a/Renderer/Renderer.hpp b/Renderer/Renderer.hpp index 78d4a13..b4c709b 100644 --- a/Renderer/Renderer.hpp +++ b/Renderer/Renderer.hpp @@ -64,4 +64,8 @@ struct Renderer { bool capture_mouse = false; bool flycam = false; + /* time speed */ + float time = 0.0; + float speed = 1.0; + bool running = true; }; diff --git a/assets/shaders/basic.frag b/assets/shaders/basic.frag index 1e64096..f852fc8 100644 --- a/assets/shaders/basic.frag +++ b/assets/shaders/basic.frag @@ -12,5 +12,5 @@ layout (set = 0, binding = 0) uniform Matrices { layout (set = 0, binding = 1) uniform sampler2D tex; void main() { - FragColor = vec4(0.0, 0.0, 0.0, 1.0); + FragColor = vec4(norm, 1.0); } \ No newline at end of file diff --git a/assets/shaders/basic.frag.spv b/assets/shaders/basic.frag.spv index 24651e1..f3ff5b2 100644 Binary files a/assets/shaders/basic.frag.spv and b/assets/shaders/basic.frag.spv differ diff --git a/assets/shaders/basic.vert b/assets/shaders/basic.vert index df1816c..b670d34 100644 --- a/assets/shaders/basic.vert +++ b/assets/shaders/basic.vert @@ -12,8 +12,7 @@ layout (set = 0, binding = 0) uniform Matrices { }; void main() { - //gl_Position = mvp * vec4(aPos, 1.0); - gl_Position = vec4(aPos, 1.0); + gl_Position = vec4(aPos + (vec3(10.0) * gl_InstanceIndex), 1.0); texCoord = aTexCoord; norm = aNorm; } \ No newline at end of file diff --git a/assets/shaders/basic.vert.spv b/assets/shaders/basic.vert.spv index e9568b1..4555263 100644 Binary files a/assets/shaders/basic.vert.spv and b/assets/shaders/basic.vert.spv differ diff --git a/pléascach.cpp b/pléascach.cpp index c0df946..7ac76c9 100644 --- a/pléascach.cpp +++ b/pléascach.cpp @@ -21,7 +21,6 @@ int main(int argc, char* argv[]) { auto in = win.getInput(); Renderer ren(win); - bool paused = false; while (!in->shouldClose()) { Timer frame_timer; in->poll(); @@ -63,11 +62,15 @@ int main(int argc, char* argv[]) { ren.capture_mouse = !ren.capture_mouse; in->setCursor(!ren.capture_mouse); } else if (event.key.key == GLFW_KEY_R && event.key.state == GLFW_PRESS) { - ren.frame = 0; + ren.time = 0; } else if (event.key.key == GLFW_KEY_C && event.key.state == GLFW_PRESS) { ren.flycam = !ren.flycam; } else if (event.key.key == GLFW_KEY_P && event.key.state == GLFW_PRESS) { - paused = !paused; + ren.running = !ren.running; + } else if (event.key.key == GLFW_KEY_T && event.key.state == GLFW_PRESS) { + ren.speed *= 10.0; + } else if (event.key.key == GLFW_KEY_Y && event.key.state == GLFW_PRESS) { + ren.speed /= 10.0; } break; } @@ -80,8 +83,6 @@ int main(int argc, char* argv[]) { while (frame_timer.read() < 16.60) ; - if(paused) - ren.frame -= 1; } } catch (const std::string& e) {