Esempio n. 1
0
        /// <summary>
        /// Applies the geometry stream to the graphics device.
        /// </summary>
        public void Apply()
        {
            Contract.EnsureNotDisposed(this, Disposed);

            if (IsUsingVertexArrayObject)
            {
                OpenGLState.BindVertexArrayObject(vao, glElementArrayBufferBinding ?? 0);
            }
            else
            {
                if (ibuffer != null)
                {
                    OpenGLState.BindElementArrayBuffer(ibuffer.OpenGLName);
                }
            }
        }
Esempio n. 2
0
        /// <inheritdoc/>
        public override void Attach(IndexBuffer ibuffer)
        {
            Contract.Require(ibuffer, nameof(ibuffer));
            Contract.EnsureNot(HasIndices, UltravioletStrings.GeometryStreamAlreadyHasIndices);
            Contract.EnsureNotDisposed(this, Disposed);

            Ultraviolet.ValidateResource(ibuffer);

            var oglIndexBuffer     = (OpenGLIndexBuffer)ibuffer;
            var oglIndexBufferName = oglIndexBuffer.OpenGLName;

            this.ibuffer = oglIndexBuffer;

            if (IsUsingVertexArrayObject)
            {
                using (OpenGLState.ScopedBindVertexArrayObject(vao, 0, force: true))
                {
                    OpenGLState.BindElementArrayBuffer(oglIndexBufferName);
                }
            }

            this.glElementArrayBufferBinding = oglIndexBufferName;
            this.indexBufferElementType      = ibuffer.IndexElementType;
        }