/// <summary>
        /// 一个vertex array object。(即VAO)
        /// <para>VAO是用来管理VBO的。可以进一步减少DrawCall。</para>
        /// </summary>
        /// <param name="propertyBuffers">给出此VAO要管理的所有VBO。</param>
        public VertexArrayObject(params BufferRenderer[] propertyBuffers)
        {
            bool indexBufferExists = false;

            this.bufferRenderers = propertyBuffers;
            foreach (var item in propertyBuffers)
            {
                var renderer = item as IndexBufferRendererBase;
                if (renderer != null)
                {
                    if (this.indexBufferRenderer != null)
                    {
                        throw new Exception("More than 1 index buffer renderer!");
                    }
                    else
                    {
                        indexBufferRenderer = renderer;
                        indexBufferExists = true;
                    }
                }
            }

            if (!indexBufferExists)
            {
                throw new Exception("No index buffer renderer exists!");
            }
        }
Exemple #2
0
        /// <summary>
        /// 一个vertex array object。(即VAO)
        /// <para>VAO是用来管理VBO的。可以进一步减少DrawCall。</para>
        /// </summary>
        /// <param name="propertyBuffers">给出此VAO要管理的所有VBO。</param>
        public VertexArrayObject(params BufferRenderer[] propertyBuffers)
        {
            bool indexBufferExists = false;

            this.bufferRenderers = propertyBuffers;
            foreach (var item in propertyBuffers)
            {
                if (item == null)
                {
                    throw new ArgumentException();
                }

                var renderer = item as IndexBufferRendererBase;
                if (renderer != null)
                {
                    if (this.indexBufferRenderer != null)
                    {
                        throw new Exception("More than 1 index buffer renderer!");
                    }
                    else
                    {
                        indexBufferRenderer = renderer;
                        indexBufferExists   = true;
                    }
                }
            }

            if (!indexBufferExists)
            {
                throw new Exception("No index buffer renderer exists!");
            }
        }
Exemple #3
0
        private void Dispose(bool disposing)
        {
            if (this.disposedValue == false)
            {
                if (disposing)
                {
                    // Dispose managed resources.
                }

                // Dispose unmanaged resources.
                uint[] arrays = new uint[] { this.ID };
                this.ID = 0;
                GL.DeleteVertexArrays(1, new uint[] { this.ID });
                foreach (var item in this.bufferRenderers)
                {
                    item.Dispose();
                }
                this.indexBufferRenderer.Dispose();
                this.bufferRenderers     = null;
                this.indexBufferRenderer = null;
            }

            this.disposedValue = true;
        }
        private void Dispose(bool disposing)
        {
            if (this.disposedValue == false)
            {
                if (disposing)
                {
                    // Dispose managed resources.

                }

                // Dispose unmanaged resources.
                uint[] arrays = new uint[] { this.ID };
                this.ID = 0;
                GL.DeleteVertexArrays(1, new uint[] { this.ID });
                foreach (var item in this.bufferRenderers)
                {
                    item.Dispose();
                }
                this.indexBufferRenderer.Dispose();
                this.bufferRenderers = null;
                this.indexBufferRenderer = null;
            }

            this.disposedValue = true;
        }