clear screen

Can I clear some portion of the screen?. Suppose I want to clear the area between (10,10) to (50,50). Is it possible?.


glClear clears viewport part of screen.
So, do glViewport(10,10,40,40);
glViewport(0,0,width, height);-restore original viewport

is wrong i believe you meant
clear screen

Wouldn’t either work?

I guess both would work, but as far as I remember RedBook says something like “blinding fast” about it, so I guess thats the way to go…


glViewport does not affect the area which is cleared, but glScissor does.

WinAPIHelp:“The glClear function clears buffers within the viewport.”

Copied fom the OpenGL Specification document:

When Clear is called, the only per-fragment operations that are applied (if enabled) are the pixel ownership test, the scissor test, and dithering.

Does not mention the viewpor, nor is the viewport mentioned somewhere related to glClear.

Originally posted by RandyU:
WinAPIHelp:“The glClear function clears buffers within the viewport.”

thats not excact, glClear clears the framebuffer, no matter how you set your viewport (just tested it , because wasn’t sure myself)

// form Windows Platform SDK : OpenGL

"The glClear function sets the bitplane area of the window to values previously selected by glClearColor, glClearIndex, glClearDepth, glClearStencil, and glClearAccum. You can clear multiple color buffers simultaneously by selecting more than one buffer at a time using glDrawBuffer.

The pixel-ownership test, the scissor test, dithering, and the buffer writemasks affect the operation of glClear. The scissor box bounds the cleared region. The glClear function ignores the alpha function, blend function, logical operation, stenciling, texture mapping, and z-buffering."

In my level editor I have a split screen mode with 3 ortho and one perpective view. The ortho views have a clear color of light blue and the persp. has a black clear color. As well as setting the viewport, to clear the viewport I have to use the scissor test. It works fine.