Reputation: 2975
i'm trying to clear the screen framebuffer with
glClear(GL_COLOR_BUFFER_BIT);
i want the framebuffer to become black.
but this doesn't seem to do anything and the last drawn shader is still on the screen.
what's my bug?
Upvotes: 0
Views: 1157
Reputation: 48247
Are you swapping frames after clearing?
The clear operation, depending on how the window is set up (double-buffered or no), will likely only clear the backbuffer. This leaves the frontbuffer, which is visible, unchanged.
In order for any operations to become visible, you need to swap your buffers. This is done different ways depending on platform, it may be wglSwapBuffers
, glxSwapBuffers
, or any number of others; check your docs.
You may be able to dodge that requirement by using a single buffer, but that will have rather large performance implications.
Upvotes: 3
Reputation: 25318
Have you set an clear color with glClearColor
? If no, set it, otherwise your code looks correct.
glClearColor(0.0, 0.0, 0.0, 1.0); // Call before glClear()
Upvotes: 0
Reputation: 1177
Are you using depth buffer (glEnable(GL_DEPTH_TEST);
) ? If yes, try to clear also that buffer:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
Upvotes: 0