clear method

void clear([
  1. bool color = true,
  2. bool depth = true,
  3. bool stencil = true
])

Implementation

void clear([bool color = true, bool depth = true, bool stencil = true]) {
			int bits = 0;

			if ( color ) {
				// check if we're trying to clear an integer target
				bool isIntegerFormat = false;
				if ( _currentRenderTarget != null ) {
					final targetFormat = _currentRenderTarget!.texture.format;
					isIntegerFormat = targetFormat == RGBAIntegerFormat ||
						targetFormat == RGIntegerFormat ||
						targetFormat == RedIntegerFormat;
				}

				// use the appropriate clear functions to clear the target if it's a signed
				// or unsigned integer target
				if ( isIntegerFormat ) {
					final targetType = _currentRenderTarget!.texture.type;
					final isUnsignedType = targetType == UnsignedByteType ||
						targetType == UnsignedIntType ||
						targetType == UnsignedShortType ||
						targetType == UnsignedInt248Type ||
						targetType == UnsignedShort4444Type ||
						targetType == UnsignedShort5551Type;

					final clearColor = background.getClearColor();
					final a = background.getClearAlpha();
					final r = clearColor.red;
					final g = clearColor.green;
					final b = clearColor.blue;

					if ( isUnsignedType ) {
						uintClearColor[ 0 ] = (r*255).toInt();
						uintClearColor[ 1 ] = (g*255).toInt();
						uintClearColor[ 2 ] = (b*255).toInt();
						uintClearColor[ 3 ] = (a*255).toInt();
						_gl.clearBufferuiv( WebGL.COLOR, 0, uintClearColor.buffer.asByteData().getUint32(0) );
					}
        else {
						intClearColor[ 0 ] = (r*255).toInt();
						intClearColor[ 1 ] = (g*255).toInt();
						intClearColor[ 2 ] = (b*255).toInt();
						intClearColor[ 3 ] = (a*255).toInt();
						_gl.clearBufferiv( WebGL.COLOR, 0, intClearColor.buffer.asByteData().getInt32(0) );
					}

				}
      else {
					bits |= WebGL.COLOR_BUFFER_BIT;
				}
			}

			if ( depth ) bits |= WebGL.DEPTH_BUFFER_BIT;
			if ( stencil ) {
				bits |= WebGL.STENCIL_BUFFER_BIT;
				state.buffers['stencil'].setMask( 0xffffffff );
			}

			_gl.clear( bits );
}