public UniformBufferObject CreateUniformBlock(string uniformBlockName, BufferObjectHint hint)
        {
            UniformBlockBinding uniformBlockBinding = GetUniformBlock(uniformBlockName);

            if (uniformBlockBinding == null)
            {
                throw new ArgumentException("no uniform block with such name", "uniformBlockName");
            }

            UniformBufferObject uniformBuffer = new UniformBufferObject(hint);

            uniformBuffer.Create(uniformBlockBinding.DataSize);

            return(uniformBuffer);
        }
        public void CreateUniformBlock(string uniformBlockName, UniformBufferObject uniformBuffer)
        {
            if (uniformBuffer == null)
            {
                throw new ArgumentNullException("uniformBuffer");
            }

            UniformBlockBinding uniformBlockBinding = GetUniformBlock(uniformBlockName);

            if (uniformBlockBinding == null)
            {
                throw new ArgumentException("no uniform block with such name", "uniformBlockName");
            }

            // Create/Update
            uniformBuffer.Create(uniformBlockBinding.DataSize);
        }
        /// <summary>
        /// Set uniform state variable (floating-point variable).
        /// </summary>
        /// <param name="ctx">
        /// A <see cref="GraphicsContext"/> used for operations.
        /// </param>
        /// <param name="uniformName">
        /// A <see cref="String"/> that specify the variable name in the shader source.
        /// </param>
        /// <param name="v">
        /// A <see cref="Single"/> holding the uniform variabile data.
        /// </param>
        public void SetUniformBlock(GraphicsContext ctx, string uniformBlockName, UniformBufferObject uniformBuffer)
        {
            if (ctx == null)
            {
                throw new ArgumentNullException("ctx");
            }
            if (uniformBuffer == null)
            {
                throw new ArgumentNullException("uniformBuffer");
            }

            UniformBlockBinding uniformBlockBinding = GetUniformBlock(uniformBlockName);

            if (uniformBlockBinding == null)
            {
                throw new ArgumentException("no uniform block with such name", "uniformBlockName");
            }

            // Select a binding point
            ctx.Bind(uniformBuffer);
            // Link the uniform buffer
            Gl.UniformBlockBinding(ObjectName, uniformBlockBinding.Index, uniformBuffer.BindingIndex);
        }