Clearing the viewport

Started by
2 comments, last by rotos 20 years, 6 months ago
Is there any way to clear just the area of the screne covered by the viewport. I''m implementing a gui system, but need to clear the depth value of a window before draing 3d stuff on top. glClear clears the entire window, not just the viewport.
Advertisement
Don''t know why you''re doing it, but if you must.. simply glClear(GL_DEPTH_BUFFER); Just don''t pass GL_COLOR_DEPTH_BUFFER, only use the GL_DEPTH_BUFFER and it''ll only clear that one.
I don't suppose glScissor would help. . . The spec says it restricts drawing to the area specified by the scissor, but I guess clearing doesn't really mean drawing. . .

You could always disable the depth test and render a quad to the depth buffer at the maximum extent of your frustum in ortho mode.

[edited by - Ostsol on September 23, 2003 6:31:06 PM]
-Ostsol
quote:Original post by Ostsol
I don''t suppose glScissor would help. . . The spec says it restricts drawing to the area specified by the scissor, but I guess clearing doesn''t really mean drawing. . .

glScissors will restrict the area cleared by glClear. Taken from MSDN on glClear.
quote:
The pixel-ownership test, the scissor test, dithering, and the buffer writemasks affect the operation of glClear. The scissor box bounds the cleared region.

Note that the viewport alone does not affect glClear.

This topic is closed to new replies.

Advertisement