View Full Version : clear screen

suresh kannan
03-21-2001, 07:35 PM
Can I clear some portion of the screen?. Suppose I want to clear the area between (10,10) to (50,50). Is it possible?.


03-21-2001, 07:50 PM
glClear clears viewport part of screen.
So, do glViewport(10,10,40,40);
glViewport(0,0,width, height);-restore original viewport

03-21-2001, 08:13 PM
is wrong http://www.opengl.org/discussion_boards/ubb/smile.gif i believe you meant
clear screen

03-21-2001, 08:26 PM
Wouldn't either work?

03-21-2001, 11:58 PM
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...


03-22-2001, 01:13 AM
glViewport does not affect the area which is cleared, but glScissor does.

03-22-2001, 08:07 PM
WinAPIHelp:"The glClear function clears buffers within the viewport."

03-22-2001, 11:42 PM
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.

03-23-2001, 01:52 AM
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)

Serge K
03-23-2001, 06:29 PM
// form Windows Platform SDK : OpenGL

"The glClear (http://msdn.microsoft.com/library/default.asp?URL=/library/psdk/opengl/glfunc01_8koi.htm) 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."

Tim Stirling
03-24-2001, 12:32 AM
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.