glClear

clear buffers to preset values

Signature

glClear( GLbitfield ( mask ) )-> void
glClear( mask )

Parameters

VariablesDescription
mask
Bitwise OR of masks that indicate the buffers to be cleared. The three masks are GL_COLOR_BUFFER_BIT , GL_DEPTH_BUFFER_BIT , and GL_STENCIL_BUFFER_BIT .

Description

glClear sets the bitplane area of the window to values previously selected by glClearColor , glClearDepth , and glClearStencil . Multiple color buffers can be cleared 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. Alpha function, blend function, logical operation, stenciling, texture mapping, and depth-buffering are ignored by glClear .
glClear takes a single argument that is the bitwise OR of several values indicating which buffer is to be cleared.
The values are as follows:
GL_COLOR_BUFFER_BIT
Indicates the buffers currently enabled for color writing.
GL_DEPTH_BUFFER_BIT
Indicates the depth buffer.
GL_STENCIL_BUFFER_BIT
Indicates the stencil buffer.
The value to which each buffer is cleared depends on the setting of the clear value for that buffer.

Notes

If a buffer is not present, then a glClear directed at that buffer has no effect.

Errors

GL_INVALID_VALUE is generated if any bit other than the three defined bits is set in mask .

Associated Gets

glGet with argument GL_DEPTH_CLEAR_VALUE
glGet with argument GL_COLOR_CLEAR_VALUE
glGet with argument GL_STENCIL_CLEAR_VALUE

Version Support

glClear

See Also

Copyright

Copyright
1991-2006 Silicon Graphics, Inc. Copyright
2010-2014 Khronos Group. This document is licensed under the SGI Free Software B License. For details, see .

Sample Code References

The following code samples have been found which appear to reference the functions described here. Take care that the code may be old, broken or not even use PyOpenGL.

glClear
OpenGLContext OpenGLContext/browser/passes.py Lines: 54
OpenGLContext OpenGLContext/scenegraph/spherebackground.py Lines: 62, 144
OpenGLContext OpenGLContext/shadow/passes.py Lines: 239
OpenGLContext OpenGLContext/passes/flatcompat.py Lines: 117, 219
OpenGLContext OpenGLContext/passes/flatcore.py Lines: 106, 206
OpenGLContext OpenGLContext/passes/_flat.py Lines: 371, 484
OpenGLContext OpenGLContext/passes/rendervisitor.py Lines: 226
OpenGLContext tests/shadow_1.py Lines: 248
OpenGLContext tests/gldrawpixelssynth.py Lines: 37
OpenGLContext tests/_bitmap_font.py Lines: 47
OpenGLContext tests/glutmousewheel.py Lines: 18
OpenGLContext tests/shadow_2.py Lines: 155
OpenGLContext tests/redbook_alpha3D.py Lines: 117
OpenGLContext tests/glut_font.py Lines: 30
OpenGLContext tests/wgl_font.py Lines: 45
OpenGLContext tests/gldrawpixels.py Lines: 52
OpenGLContext tests/wx_font.py Lines: 32
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson11.py Lines: 78
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson18.py Lines: 188
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson6.py Lines: 114
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson41.py Lines: 223
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson16.py Lines: 79
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson23.py Lines: 144
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson5.py Lines: 92
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson4.py Lines: 90
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson26.py Lines: 141
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson12.py Lines: 70
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson3.py Lines: 78
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson13.py Lines: 147
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson1.py Lines: 78
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson19.py Lines: 143
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson42.py Lines: 258, 298
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson2.py Lines: 78
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson6-multi.py Lines: 151
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson45.py Lines: 374
OpenGL-Demo PyOpenGL-Demo/proesch/stereo/stereoDemo.py Lines: 76, 81, 84, 88, 91, 98
OpenGL-Demo PyOpenGL-Demo/proesch/nurbs/nurbs.py Lines: 142
OpenGL-Demo PyOpenGL-Demo/dek/texturesurf.py Lines: 47
OpenGL-Demo PyOpenGL-Demo/dek/tile.py Lines: 33
OpenGL-Demo PyOpenGL-Demo/da/dots.py Lines: 43
OpenGL-Demo PyOpenGL-Demo/GLE/texas.py Lines: 42
OpenGL-Demo PyOpenGL-Demo/GLE/helix.py Lines: 12
OpenGL-Demo PyOpenGL-Demo/GLE/cone.py Lines: 16
OpenGL-Demo PyOpenGL-Demo/GLUT/gears.py Lines: 137
OpenGL-Demo PyOpenGL-Demo/GLUT/shader_test.py Lines: 81
OpenGL-Demo PyOpenGL-Demo/GLUT/glutplane.py Lines: 47
OpenGL-Demo PyOpenGL-Demo/GLUT/molehill.py Lines: 41
OpenGL-Demo PyOpenGL-Demo/GLUT/tom/checker.py Lines: 57
OpenGL-Demo PyOpenGL-Demo/GLUT/tom/lorentz.py Lines: 67
OpenGL-Demo PyOpenGL-Demo/GLUT/tom/arraytest.py Lines: 57
OpenGL-Demo PyOpenGL-Demo/GLUT/tom/text.py Lines: 50
OpenGL-Demo PyOpenGL-Demo/GLUT/tom/cone.py Lines: 59
OpenGL-Demo PyOpenGL-Demo/redbook/hello.py Lines: 63
OpenGL-Demo PyOpenGL-Demo/redbook/scene.py Lines: 85
OpenGL-Demo PyOpenGL-Demo/redbook/drawf.py Lines: 78
OpenGL-Demo PyOpenGL-Demo/redbook/lines.py Lines: 78
OpenGL-Demo PyOpenGL-Demo/redbook/movelight.py Lines: 94
OpenGL-Demo PyOpenGL-Demo/redbook/smooth.py Lines: 79
OpenGL-Demo PyOpenGL-Demo/redbook/fog.py Lines: 106
OpenGL-Demo PyOpenGL-Demo/redbook/double.py Lines: 67
OpenGL-Demo PyOpenGL-Demo/redbook/teapots.py Lines: 130
OpenGL-Demo PyOpenGL-Demo/redbook/cube.py Lines: 69
OpenGL-Demo PyOpenGL-Demo/tom/demo.py Lines: 50, 70, 78
OpenGL-Demo PyOpenGL-Demo/tom/first.py Lines: 8
OpenGL-Demo PyOpenGL-Demo/tom/conechecker.py Lines: 11, 47
OpenGL-Demo PyOpenGL-Demo/tom/conesave.py Lines: 28
OpenGL-Demo PyOpenGL-Demo/tom/checker.py Lines: 11
OpenGL-Demo PyOpenGL-Demo/tom/fog.py Lines: 66
OpenGL-Demo PyOpenGL-Demo/tom/Line.py Lines: 8
OpenGL-Demo PyOpenGL-Demo/tom/poly.py Lines: 39
OpenGL-Demo PyOpenGL-Demo/tom/lorentz.py Lines: 53
OpenGL-Demo PyOpenGL-Demo/tom/arraytest.py Lines: 27
OpenGL-Demo PyOpenGL-Demo/tom/cone.py Lines: 25
OpenGL-Demo py2exe-example/shader_test.py Lines: 82
{Artistic License} PymmLib pymmlib/applications/glutviewer.py Lines: 178
{Artistic License} PymmLib pymmlib/mmLib/OpenGLDriver.py Lines: 169
{LGPL} PyUI2 renderers/openglBase.py Lines: 291
{LGPL} PyUI2 system/openglgraphics.py Lines: 43
{LGPL} VisionEgg VisionEgg/Core.py Lines: 584
{LGPL} PyMT examples/apps/3Ddrawing/3Ddrawing.py Lines: 81, 123, 155
{LGPL} PyMT examples/apps/3Dviewer/3Dviewer.py Lines: 39
{LGPL} PyMT examples/apps/paint/paint.py Lines: 117
{LGPL} PyMT pymt/tools/designerapp/qtmtwindow.py Lines: 51
{LGPL} PyMT pymt/ui/window/__init__.py Lines: 18, 324
{LGPL} PyMT pymt/graphx/fbo.py Lines: 19, 112, 114
{LGPL} PyMT pymt/graphx/stencil.py Lines: 22, 42, 78
{LGPL} Pyggel pyggel/misc.py Lines: 25
{LGPL} Pyggel pyggel/view.py Lines: 331, 333
{LGPL} Pyggel pyggel/data.py Lines: 545, 607, 623
{LGPL} Pyggel pyggel/scene.py Lines: 171
{LGPL} pygl2d pygl2d/display.py Lines: 48
{GPL} Scocca scocca/graphics/opengl/color.py Lines: 27
{LGPL or GPL or MPL} Kamaelia Code/Python/Kamaelia/Kamaelia/UI/OpenGL/OpenGLDisplay.py Lines: 596
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/Experiments/Cubes.py Lines: 176
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/Experiments/Spheres.py Lines: 115
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Kamaelia/UI/OpenGL/OpenGLDisplay.py Lines: 578
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Examples/simplecube/simplecube.py Lines: 55
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/Display3D.py Lines: 523
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/THF/Sketches/playground/Display3D.py Lines: 425
{LGPL or GPL or MPL} Kamaelia Sketches/MPS/Old/SoC/simplecube.py Lines: 87
{LGPL or GPL or MPL} Kamaelia Sketches/THF/simplecube/simplecube_controlled.py Lines: 110
{LGPL or GPL or MPL} Kamaelia Sketches/THF/simplecube/simplecube.py Lines: 55
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/Display3D.py Lines: 523
{LGPL or GPL or MPL} Kamaelia Sketches/THF/3D/playground/Display3D.py Lines: 425
Gloopy gloopy/view/render.py Lines: 104
OpenGL Tutorial (Python Translation) t02.playing-with-colors/FragPosition.py Lines: 83
OpenGL Tutorial (Python Translation) t02.playing-with-colors/VertexColors.py Lines: 86
OpenGL Tutorial (Python Translation) t01.hello-triangle/HelloTriangle.py Lines: 97
Visvis core/baseFigure.py Lines: 837, 853
{GPL3} OpenGL-Programmable 05-shader.py Lines: 231
{GPL3} OpenGL-Programmable 07-attrib.py Lines: 250
{GPL3} OpenGL-Programmable 03-array.py Lines: 146
{GPL3} OpenGL-Programmable 09-gles2.py Lines: 293
{GPL3} OpenGL-Programmable 06-perpixel.py Lines: 239
{GPL3} OpenGL-Programmable 10-gl3.2core.py Lines: 303
{GPL3} OpenGL-Programmable 02-displaylist.py Lines: 144
{GPL3} OpenGL-Programmable 04-vbo.py Lines: 165
{GPL3} OpenGL-Programmable 01-direct.py Lines: 135
{GPL3} OpenGL-Programmable 08-pbo.py Lines: 272