From 74ccc647f443f4abaf9d4c21c3d057340eda383c Mon Sep 17 00:00:00 2001 From: Cat Flynn Date: Thu, 3 Aug 2023 01:01:02 +0200 Subject: [PATCH] chore: simplify time usage --- frag.glsl | 4 +--- src/hello.cpp | 13 ++----------- src/icosphere.cpp | 2 +- src/icosphere.hpp | 2 +- 4 files changed, 5 insertions(+), 16 deletions(-) diff --git a/frag.glsl b/frag.glsl index 60b5caa..95275bd 100644 --- a/frag.glsl +++ b/frag.glsl @@ -2,9 +2,7 @@ out vec4 FragColor; -uniform float _Time; - void main() { - FragColor = vec4(1.0, 0.5, 0.2, 1.0) * sin(_Time) / 2.0 + 0.5; + FragColor = vec4(1.0, 0.5, 0.2, 1.0); } diff --git a/src/hello.cpp b/src/hello.cpp index 9cb92fe..c96d880 100644 --- a/src/hello.cpp +++ b/src/hello.cpp @@ -111,13 +111,6 @@ void updateModelViewProjectionMatrix(GLuint shaderProgram, float time) glUniformMatrix4fv(mvpLocation, 1, GL_FALSE, &mvp[0][0]); } -void updateTime(GLuint shaderProgram, float time) -{ - GLint timeLocation = getShaderUniformLocation(shaderProgram, "_Time"); - float timeValue = time; - glUniform1f(timeLocation, timeValue); -} - int main() { // Calculate period of ISS orbit around the Earth @@ -150,12 +143,10 @@ int main() glUseProgram(shaderProgram); // Update uniforms - float time = glfwGetTime(); - updateTime(shaderProgram, time); - updateModelViewProjectionMatrix(shaderProgram, time); + updateModelViewProjectionMatrix(shaderProgram, glfwGetTime()); // Render objects - sphere.render(time); + sphere.render(); glfwSwapBuffers(window); glfwPollEvents(); diff --git a/src/icosphere.cpp b/src/icosphere.cpp index 9611be5..7eefb43 100644 --- a/src/icosphere.cpp +++ b/src/icosphere.cpp @@ -36,7 +36,7 @@ Icosphere::Icosphere(int subdivisions) glBindVertexArray(0); } -void Icosphere::render(float time) +void Icosphere::render() { glBindVertexArray(_vao); glBindBuffer(GL_ARRAY_BUFFER, _vbo); diff --git a/src/icosphere.hpp b/src/icosphere.hpp index c53c756..c71aaa0 100644 --- a/src/icosphere.hpp +++ b/src/icosphere.hpp @@ -10,7 +10,7 @@ class Icosphere { public: Icosphere(int subdividision); - void render(float time); + void render(); ~Icosphere();