Or Arbel
Or Arbel

Reputation: 2975

OpenGL ES 2.0 iPhone - glClear on frame buffer does nothing

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

Answers (3)

ssube
ssube

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

JustSid
JustSid

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

Artur Ozierański
Artur Ozierański

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

Related Questions