chore: simplify time usage
This commit is contained in:
parent
0ce3d54139
commit
74ccc647f4
|
@ -2,9 +2,7 @@
|
||||||
|
|
||||||
out vec4 FragColor;
|
out vec4 FragColor;
|
||||||
|
|
||||||
uniform float _Time;
|
|
||||||
|
|
||||||
void main()
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,13 +111,6 @@ void updateModelViewProjectionMatrix(GLuint shaderProgram, float time)
|
||||||
glUniformMatrix4fv(mvpLocation, 1, GL_FALSE, &mvp[0][0]);
|
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()
|
int main()
|
||||||
{
|
{
|
||||||
// Calculate period of ISS orbit around the Earth
|
// Calculate period of ISS orbit around the Earth
|
||||||
|
@ -150,12 +143,10 @@ int main()
|
||||||
glUseProgram(shaderProgram);
|
glUseProgram(shaderProgram);
|
||||||
|
|
||||||
// Update uniforms
|
// Update uniforms
|
||||||
float time = glfwGetTime();
|
updateModelViewProjectionMatrix(shaderProgram, glfwGetTime());
|
||||||
updateTime(shaderProgram, time);
|
|
||||||
updateModelViewProjectionMatrix(shaderProgram, time);
|
|
||||||
|
|
||||||
// Render objects
|
// Render objects
|
||||||
sphere.render(time);
|
sphere.render();
|
||||||
|
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
|
|
|
@ -36,7 +36,7 @@ Icosphere::Icosphere(int subdivisions)
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Icosphere::render(float time)
|
void Icosphere::render()
|
||||||
{
|
{
|
||||||
glBindVertexArray(_vao);
|
glBindVertexArray(_vao);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||||
|
|
|
@ -10,7 +10,7 @@ class Icosphere
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Icosphere(int subdividision);
|
Icosphere(int subdividision);
|
||||||
void render(float time);
|
void render();
|
||||||
|
|
||||||
~Icosphere();
|
~Icosphere();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue