Пример #1
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;
                IntPtr ptr = Win32.wglGetCurrentContext();
                if (ptr != IntPtr.Zero)
                {
                    glDeleteVertexArrays(1, new uint[] { this.ID });
                }
                {
                    BufferPtr[] propertyBufferPtrs = this.propertyBufferPtrs;
                    foreach (var item in propertyBufferPtrs)
                    {
                        item.Dispose();
                    }
                }
                {
                    IndexBufferPtr indexBufferPtr = this.indexBufferPtr;
                    indexBufferPtr.Dispose();
                }
            }

            this.disposedValue = true;
        }
        /// <summary>
        /// 设置要高亮显示的图元。
        /// </summary>
        /// <param name="mode">要高亮显示的图元类型</param>
        /// <param name="indexes">要高亮显示的图元的索引。</param>
        public void SetHighlightIndexes(DrawMode mode, params uint[] indexes)
        {
            int indexesLength = indexes.Length;

            if (indexesLength > this.maxElementCount)
            {
                IndexBufferPtr original = this.indexBufferPtr;
                using (var buffer = new OneIndexBuffer(IndexElementType.UInt,
                                                       mode, BufferUsage.DynamicDraw))
                {
                    buffer.Create(indexesLength);
                    this.indexBufferPtr = buffer.GetBufferPtr() as OneIndexBufferPtr;
                }
                this.maxElementCount = indexesLength;
                original.Dispose();
            }

            var    indexBufferPtr = this.indexBufferPtr as OneIndexBufferPtr;
            IntPtr pointer        = indexBufferPtr.MapBuffer(MapBufferAccess.WriteOnly);

            unsafe
            {
                var array = (uint *)pointer.ToPointer();
                for (int i = 0; i < indexesLength; i++)
                {
                    array[i] = indexes[i];
                }
            }
            indexBufferPtr.UnmapBuffer();

            indexBufferPtr.Mode         = mode;
            indexBufferPtr.ElementCount = indexesLength;
        }
Пример #3
0
        private void Dispose(bool disposing)
        {
            if (this.disposedValue == false)
            {
                if (disposing)
                {
                    // Dispose managed resources.
                }

                // Dispose unmanaged resources.
                IntPtr ptr = Win32.wglGetCurrentContext();
                if (ptr != IntPtr.Zero)
                {
                    {
                        glDeleteVertexArrays(1, this.ids);
                        this.ids[0] = 0;
                    }
                    {
                        VertexAttributeBufferPtr[] vertexAttributeBufferPtrs = this.VertexAttributeBufferPtrs;
                        if (vertexAttributeBufferPtrs != null)
                        {
                            foreach (var item in vertexAttributeBufferPtrs)
                            {
                                item.Dispose();
                            }
                        }
                    }
                    {
                        IndexBufferPtr indexBufferPtr = this.IndexBufferPtr;
                        indexBufferPtr.Dispose();
                    }
                }
            }

            this.disposedValue = true;
        }