0

I am using this tutorial and OpenGL superbible to learn OpenGL(4.3 and above) as a part of learning the concepts in 3D Computer Graphics and Rendering.

I wanted to try some initial experiments which involves the changing of color of window. For that I am using following code

time_t tt;
time(&tt);

GLfloat color[4];

color[0] = (float)sin(tt) * 0.5f + 0.5f;
color[1] = (float)cos(tt) * 0.5f + 0.5f;
color[2] = 0.0f;
color[3] = 1.0f;

glClearBufferfv(GL_COLOR, 0, color);`

I tried inserting it in RenderFunction() and below the fprintf function of Chapter1.c, but still the window does not change the color. I know this is a dumb enough experiment which animates the window but I just wanted to try and learn. My question is, where should I put my code or what modifications should I do in this tutorial code so that it will change the color of the window?

UPDATE: I read this question which is somewhat relevant but still I am not able to animate the window.

Community
  • 1
  • 1
Recker
  • 1,915
  • 25
  • 55
  • What output is generated? – ApproachingDarknessFish Nov 29 '13 at 01:21
  • VS2013 Express stops the program without showing the window with any color. – Recker Nov 29 '13 at 01:24
  • Are you using a double buffered pixel format? I would make sure `glDrawBuffer (...)` is set to `GL_FRONT` if you are using a single buffered format (bad idea anyway) and `GL_BACK` if you are using double buffered. If you are using double buffered, then also swap your buffers at some point for this to take effect (the window always displays your front buffer's contents). The last part is the most important, because `glDrawBuffer (...)` actually defaults to the two states I mentioned above depending on your pixel format. – Andon M. Coleman Nov 29 '13 at 02:08
  • I do not see any `glDrawBuffer(...)` function in the tutorial code.I think I am using double buffering since I am using `glutSwapBuffers()` function somewhere in the code. – Recker Nov 29 '13 at 02:56

0 Answers0