Esempio n. 1
0
        private static ClearBufferMask GetClearFlags(GraphicsBuffersFormat.BufferType bufferMask)
        {
            ClearBufferMask clearFlags = 0;

            if ((bufferMask & GraphicsBuffersFormat.BufferType.Color) != 0)
            {
                clearFlags |= ClearBufferMask.ColorBufferBit;
            }
            if ((bufferMask & GraphicsBuffersFormat.BufferType.Depth) != 0)
            {
                clearFlags |= ClearBufferMask.DepthBufferBit;
            }
            if ((bufferMask & GraphicsBuffersFormat.BufferType.Stencil) != 0)
            {
                clearFlags |= ClearBufferMask.StencilBufferBit;
            }

            return(clearFlags);
        }
Esempio n. 2
0
        /// <summary>
        /// Clear surface buffers.
        /// </summary>
        /// <param name="ctx">
        /// A <see cref="GraphicsContext"/> used for clearing buffers.
        /// </param>
        /// <param name="bufferMask">
        /// A <see cref="GraphicsBuffersFormat.BufferType"/> indicating which buffers to clear.
        /// </param>
        public void Clear(GraphicsContext ctx, GraphicsBuffersFormat.BufferType bufferMask)
        {
            // Update clear values (only what is necessary)
            if ((bufferMask & GraphicsBuffersFormat.BufferType.Color) != 0)
            {
                Gl.ClearColor(mClearColor.Red, mClearColor.Green, mClearColor.Blue, mClearColor.Alpha);
            }
            if ((bufferMask & GraphicsBuffersFormat.BufferType.Depth) != 0)
            {
                Gl.ClearDepth(mClearDepth);
            }
            if ((bufferMask & GraphicsBuffersFormat.BufferType.Stencil) != 0)
            {
                Gl.ClearStencil(mClearStencil);
            }

            // Clear
            Gl.Clear(GetClearFlags(bufferMask));
        }