clear screen

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

Thanks,
Kannan

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

is wrong i believe you meant
glScissor(x,y,width,height)
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…

Chris

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.