chore: simplify time usage

This commit is contained in:
Cat Flynn 2023-08-03 01:01:02 +02:00
parent 0ce3d54139
commit 74ccc647f4
4 changed files with 5 additions and 16 deletions

View File

@ -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);
}

View File

@ -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();

View File

@ -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);

View File

@ -10,7 +10,7 @@ class Icosphere
{
public:
Icosphere(int subdividision);
void render(float time);
void render();
~Icosphere();