title: Failed to change color over time in OpenGL
body: <p>I am studying OpenGL using OpenGL superbible 7th edition. However, when I tried to run the example in Chapter 2, I found a problem that the color is not changing over time as intended.</p>
  
  <p>Here is the main program:</p>
  
  <pre><code>int main(int argc, char** argv) {
      if (!glfwInit())
      {
          fprintf(stderr, "Failed to initialize GLFW\n");
          return 1;
      }
  
      GLFWwindow* window;
      window = glfwCreateWindow(800, 600, "My First OpenGL Project", NULL, NULL);
      if (!window)
      {
          fprintf(stderr, "Failed to open window\n");
          return 1;
      }
      glfwMakeContextCurrent(window);
  
      gl3wInit();
  
      bool running = true;
  
      do
      {
          double current_time = glfwGetTime();
          static const GLfloat color[] = {
              (float)sin(current_time) * 0.5f + 0.5f,
              (float)cos(current_time) * 0.5f + 0.5f,
              0.0f,
              1.0f };
          std::cout &lt;&lt; current_time &lt;&lt; std::endl;
          std::cout &lt;&lt; color[0] &lt;&lt; std::endl;
          glClearBufferfv(GL_COLOR, 0, color);
  
          glfwSwapBuffers(window);
          glfwPollEvents();
  
          running &amp;= (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_RELEASE);
          running &amp;= (glfwWindowShouldClose(window) != GL_TRUE);
      } while (running);
  
      glfwDestroyWindow(window);
      glfwTerminate();
      return 0;
  }
  </code></pre>
  
  <p>It appears that the value of current_time is changing over time but the value of color[0] is not. Why is that?</p>