Wraps glDrawArrays(uint mode, int first, int count).
Inheritance: IndexBuffer
Exemple #1
0
        internal override uint Search(RenderEventArgs arg,
                                      int x, int y,
                                      uint lastVertexId, ZeroIndexRenderer modernRenderer)
        {
            ZeroIndexBufferPtr zeroIndexBufferPtr = modernRenderer.IndexBufferPtr;
            ZeroIndexBufferPtr indexBufferPtr     = null;

            // when the temp index buffer could be long, it's no longer needed.
            // what a great OpenGL API design!
            using (var buffer = new ZeroIndexBuffer(DrawMode.Points,
                                                    zeroIndexBufferPtr.FirstVertex, zeroIndexBufferPtr.VertexCount))
            {
                indexBufferPtr = buffer.GetBufferPtr() as ZeroIndexBufferPtr;
            }
            modernRenderer.Render4InnerPicking(arg, indexBufferPtr);
            uint id = ColorCodedPicking.ReadPixel(x, y, arg.CanvasRect.Height);

            indexBufferPtr.Dispose();

            if (zeroIndexBufferPtr.FirstVertex <= id &&
                id < zeroIndexBufferPtr.FirstVertex + zeroIndexBufferPtr.VertexCount)
            {
                return(id);
            }
            else
            {
                throw new Exception("This should not happen!");
            }
        }
Exemple #2
0
        public IndexBufferPtr GetIndex()
        {
            if (indexBufferPtr == null)
            {
                using (var buffer = new ZeroIndexBuffer(
                    DrawMode.LineStrip, 0, BigDipperModel.positions.Length))
                {
                    indexBufferPtr = buffer.GetBufferPtr() as IndexBufferPtr;
                }
                //using (var buffer = new OneIndexBuffer<uint>(
                //    DrawMode.Lines, BufferUsage.StaticDraw))
                //{
                //    buffer.Alloc(BigDipperModel.positions.Length);
                //    unsafe
                //    {
                //        var array = (uint*)buffer.Header.ToPointer();
                //        for (uint i = 0; i < BigDipperModel.positions.Length; i++)
                //        {
                //            array[i] = i;
                //        }
                //        array[0] = uint.MaxValue;
                //        array[4] = uint.MaxValue;
                //        array[10] = uint.MaxValue;
                //    }
                //    indexBufferPtr = buffer.GetBufferPtr() as IndexBufferPtr;
                //}
            }

            return indexBufferPtr;
        }
        internal override uint[] Search(RenderEventArgs arg,
                                        int x, int y,
                                        uint lastVertexId, ZeroIndexRenderer modernRenderer)
        {
            ZeroIndexBufferPtr zeroIndexBufferPtr = modernRenderer.IndexBufferPtr;
            ZeroIndexBufferPtr indexBufferPtr     = null;

            // when the temp index buffer could be long, it's no longer needed.
            // what a great OpenGL API design!
            using (var buffer = new ZeroIndexBuffer(DrawMode.LineLoop,
                                                    zeroIndexBufferPtr.FirstVertex, zeroIndexBufferPtr.VertexCount))
            {
                indexBufferPtr = buffer.GetBufferPtr() as ZeroIndexBufferPtr;
            }
            modernRenderer.Render4InnerPicking(arg, indexBufferPtr);
            uint id = ColorCodedPicking.ReadPixel(x, y, arg.CanvasRect.Height);

            indexBufferPtr.Dispose();

            if (id == zeroIndexBufferPtr.FirstVertex)
            {
                return(new uint[] { (uint)(zeroIndexBufferPtr.FirstVertex + zeroIndexBufferPtr.VertexCount - 1), id, });
            }
            else
            {
                return(new uint[] { id - 1, id, });
            }
        }
Exemple #4
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public IndexBufferPtr GetIndexBufferPtr()
        {
            if (indexBufferPtr == null)
            {
                using (var buffer = new ZeroIndexBuffer(
                           DrawMode.LineStrip, 0, BigDipperModel.positions.Length))
                {
                    indexBufferPtr = buffer.GetBufferPtr();
                }
                //using (var buffer = new OneIndexBuffer<uint>(
                //    DrawMode.Lines, BufferUsage.StaticDraw))
                //{
                //    buffer.Alloc(BigDipperModel.positions.Length);
                //    unsafe
                //    {
                //        var array = (uint*)buffer.Header.ToPointer();
                //        for (uint i = 0; i < BigDipperModel.positions.Length; i++)
                //        {
                //            array[i] = i;
                //        }
                //        array[0] = uint.MaxValue;
                //        array[4] = uint.MaxValue;
                //        array[10] = uint.MaxValue;
                //    }
                //    indexBufferPtr = buffer.GetBufferPtr();
                //}
            }

            return(indexBufferPtr);
        }
        public IndexBuffer GetIndexBuffer()
        {
            if (this.indexBuffer == null)
            {
                this.indexBuffer = ZeroIndexBuffer.Create(DrawMode.Quads, 0, 4);
            }

            return(this.indexBuffer);
        }
Exemple #6
0
        public IndexBuffer GetIndexBuffer()
        {
            if (this.indexBuffer == null)
            {
                this.indexBuffer = ZeroIndexBuffer.Create(DrawMode.TriangleStrip, 0, positions.Length);
            }

            return(this.indexBuffer);
        }
Exemple #7
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public ZeroIndexBuffer GetIndexBuffer()
        {
            if (this.buffer == null)
            {
                this.buffer = ZeroIndexBuffer.Create(this.Mode, this.FirstVertex, this.VertexCount, this.PrimCount);
            }

            return(this.buffer);
        }
Exemple #8
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public CSharpGL.IndexBuffer GetIndexBuffer()
 {
     if ((indexBuffer == null))
     {
         int             vertexCount = this.pointPositions.Length;
         ZeroIndexBuffer buffer      = ZeroIndexBuffer.Create(DrawMode.Points, 0, vertexCount);
         this.indexBuffer = buffer;
     }
     return(indexBuffer);
 }
 public CSharpGL.IndexBuffer GetIndexBuffer()
 {
     if (this.indexBuffer == null)
     {
         int             vertexCount = this.pointCount;
         ZeroIndexBuffer buffer      = ZeroIndexBuffer.Create(DrawMode.Points, 0, vertexCount);
         this.indexBuffer = buffer;
     }
     return(this.indexBuffer);
 }
Exemple #10
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public IndexBuffer GetIndexBuffer()
        {
            if (this.indexBuffer == null)
            {
                int             vertexCount = maxCharCount * 4;
                ZeroIndexBuffer buffer      = ZeroIndexBuffer.Create(DrawMode.Quads, 0, vertexCount);
                this.indexBuffer = buffer;
            }

            return(this.indexBuffer);
        }
Exemple #11
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public IndexBuffer GetIndexBuffer()
        {
            if (this.indexBuffer == null)
            {
                int             vertexCount = positions.Length;
                ZeroIndexBuffer buffer      = ZeroIndexBuffer.Create(DrawMode.Lines, 0, vertexCount);
                this.indexBuffer = buffer;
            }

            return(this.indexBuffer);
        }
Exemple #12
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public IndexBuffer GetIndexBuffer()
        {
            if (this.indexBuffer == null)
            {
                int vertexCount = this.model.Positions.Length;
                ZeroIndexBuffer buffer = ZeroIndexBuffer.Create(DrawMode.LineStrip, 0, vertexCount);
                this.indexBuffer = buffer;
            }

            return this.indexBuffer;
        }
Exemple #13
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public IndexBuffer GetIndexBuffer()
        {
            if (indexBuffer == null)
            {
                ZeroIndexBuffer buffer = ZeroIndexBuffer.Create(DrawMode.LineStrip, 0, BigDipperModel.positions.Length);

                this.indexBuffer = buffer;
            }

            return(indexBuffer);
        }
Exemple #14
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public IndexBuffer GetIndexBuffer()
        {
            if (this.indexBuffer == null)
            {
                int             vertexCount = this.model.positions.Length;
                ZeroIndexBuffer buffer      = ZeroIndexBuffer.Create(this.model.GetDrawModel(), 0, vertexCount);
                this.indexBuffer = buffer;
            }

            return(this.indexBuffer);
        }
Exemple #15
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public IndexBuffer GetIndexBuffer()
        {
            if (this.indexBuffer == null)
            {
                int vertexCount = maxCharCount * 4;
                ZeroIndexBuffer buffer = ZeroIndexBuffer.Create(DrawMode.Quads, 0, vertexCount);
                this.indexBuffer = buffer;
            }

            return this.indexBuffer;
        }
 public CSharpGL.IndexBufferPtr GetIndexBufferPtr()
 {
     if ((indexBufferPtr == null))
     {
         using (var buffer = new ZeroIndexBuffer(DrawMode.Points, 0, this.pointCount))
         {// begin of using
             indexBufferPtr = buffer.GetBufferPtr();
         }// end of using
     }
     return(indexBufferPtr);
 }
Exemple #17
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public IndexBuffer GetIndexBuffer()
        {
            if (this.indexBuffer == null)
            {
                int primCount  = 1;
                int frameCount = 2;
                this.indexBuffer = ZeroIndexBuffer.Create(DrawMode.Quads, 0, positions.Length, primCount, frameCount);
            }

            return(this.indexBuffer);
        }
        public IndexBuffer GetIndexBuffer()
        {
            if (this.indexBuffer == null)
            {
                int             uCount = GetUCount(interval);
                ZeroIndexBuffer buffer = ZeroIndexBuffer.Create(DrawMode.Points, 0, uCount);
                this.indexBuffer = buffer;
            }

            return(this.indexBuffer);
        }
 public IndexBufferPtr GetIndex()
 {
     if (this.indexBufferPtr == null)
     {
         using (var buffer = new ZeroIndexBuffer(DrawMode.Lines, 0, codedColors.Length * 2 + 4))
         {
             this.indexBufferPtr = buffer.GetBufferPtr() as IndexBufferPtr;
         }
     }
     return this.indexBufferPtr;
 }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public IndexBufferPtr GetIndexBufferPtr()
        {
            if (this.indexBufferPtr == null)
            {
                using (var buffer = new ZeroIndexBuffer(this.Mode, this.FirstVertex, this.VertexCount, this.PrimCount))
                {
                    this.indexBufferPtr = buffer.GetBufferPtr();
                }
            }

            return(this.indexBufferPtr);
        }
Exemple #21
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public IndexBufferPtr GetIndex()
        {
            if (indexBufferPtr == null)
            {
                using (var buffer = new ZeroIndexBuffer(this.model.GetDrawModel(), 0, this.model.positions.Length))
                {
                    indexBufferPtr = buffer.GetBufferPtr() as IndexBufferPtr;
                }
            }

            return(indexBufferPtr);
        }
Exemple #22
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public IndexBufferPtr GetIndexBufferPtr()
        {
            if (indexBufferPtr == null)
            {
                using (var buffer = new ZeroIndexBuffer(
                           DrawMode.LineStrip, 0, this.model.Positions.Length))
                {
                    indexBufferPtr = buffer.GetBufferPtr();
                }
            }

            return(indexBufferPtr);
        }
Exemple #23
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public IndexBufferPtr GetIndex()
        {
            if (indexBufferPtr == null)
            {
                using (var buffer = new ZeroIndexBuffer(
                           DrawMode.QuadStrip, 0, positions.Length))
                {
                    indexBufferPtr = buffer.GetBufferPtr() as IndexBufferPtr;
                }
            }

            return(indexBufferPtr);
        }
Exemple #24
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public IndexBufferPtr GetIndex()
        {
            if (indexBufferPtr == null)
            {
                using (var buffer = new ZeroIndexBuffer(
                           DrawMode.Quads, 0, maxCharCount * 4))
                {
                    indexBufferPtr = buffer.GetBufferPtr() as ZeroIndexBufferPtr;
                }
            }

            return(indexBufferPtr);
        }
Exemple #25
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public IndexBuffer GetIndexBuffer()
        {
            if (this.indexBuffer == null)
            {
                int primCount   = 1;
                int frameCount  = 1;
                var indexBuffer = ZeroIndexBuffer.Create(DrawMode.Quads, 0, this.Capacity * 4, primCount, frameCount);
                // note: use ZeroIndexBuffer.Draw(ControlMode.Random) to enable this property.
                indexBuffer.RenderingVertexCount = 0;
                this.indexBuffer = indexBuffer;
            }

            return(this.indexBuffer);
        }
        internal override uint[] Search(RenderEventArgs arg,
            int x, int y,
            uint lastVertexId, ZeroIndexRenderer modernRenderer)
        {
            ZeroIndexBufferPtr zeroIndexBufferPtr = modernRenderer.IndexBufferPtr;
            ZeroIndexBufferPtr indexBufferPtr = null;
            // when the temp index buffer could be long, it's no longer needed.
            // what a great OpenGL API design!
            using (var buffer = new ZeroIndexBuffer(DrawMode.LineLoop,
                zeroIndexBufferPtr.FirstVertex, zeroIndexBufferPtr.VertexCount))
            {
                indexBufferPtr = buffer.GetBufferPtr() as ZeroIndexBufferPtr;
            }
            modernRenderer.Render4InnerPicking(arg, indexBufferPtr);
            uint id = ColorCodedPicking.ReadPixel(x, y, arg.CanvasRect.Height);

            indexBufferPtr.Dispose();

            if (id == zeroIndexBufferPtr.FirstVertex)
            { return new uint[] { (uint)(zeroIndexBufferPtr.FirstVertex + zeroIndexBufferPtr.VertexCount - 1), id, }; }
            else
            { return new uint[] { id - 1, id, }; }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="arg"></param>
        /// <param name="lastVertexId"></param>
        /// <param name="picker"></param>
        /// <returns></returns>
        internal override uint Search(PickingEventArgs arg,
                                      uint lastVertexId, ZeroIndexPicker picker)
        {
            var zeroIndexBuffer = picker.Node.PickingRenderUnit.VertexArrayObject.IndexBuffer as ZeroIndexBuffer;
            // when the temp index buffer could be long, it's no longer needed.
            // what a great OpenGL API design!
            ZeroIndexBuffer indexBuffer = ZeroIndexBuffer.Create(DrawMode.Points, zeroIndexBuffer.FirstVertex, zeroIndexBuffer.RenderingVertexCount, zeroIndexBuffer.InstanceCount);

            picker.Node.Render4InnerPicking(arg, indexBuffer);
            uint id = ColorCodedPicking.ReadStageVertexId(arg.X, arg.Y);

            indexBuffer.Dispose();

            if (zeroIndexBuffer.FirstVertex <= id &&
                id < zeroIndexBuffer.FirstVertex + zeroIndexBuffer.RenderingVertexCount)
            {
                return(id);
            }
            else
            {
                throw new Exception("This should not happen!");
            }
        }
        internal override uint Search(RenderEventArg arg,
            int x, int y,
            uint lastVertexId, ZeroIndexRenderer modernRenderer)
        {
            ZeroIndexBufferPtr zeroIndexBufferPtr = modernRenderer.IndexBufferPtr;
            ZeroIndexBufferPtr indexBufferPtr = null;
            // when the temp index buffer could be long, it's no longer needed.
            // what a great OpenGL API design!
            using (var buffer = new ZeroIndexBuffer(DrawMode.Points,
                zeroIndexBufferPtr.FirstVertex, zeroIndexBufferPtr.VertexCount))
            {
                indexBufferPtr = buffer.GetBufferPtr() as ZeroIndexBufferPtr;
            }
            modernRenderer.Render4InnerPicking(arg, indexBufferPtr);
            uint id = ColorCodedPicking.ReadPixel(x, y, arg.CanvasRect.Height);

            indexBufferPtr.Dispose();

            if (zeroIndexBufferPtr.FirstVertex <= id
                && id < zeroIndexBufferPtr.FirstVertex + zeroIndexBufferPtr.VertexCount)
            { return id; }
            else
            { throw new Exception("This should not happen!"); }
        }
Exemple #29
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="arg"></param>
        /// <param name="x">mouse position(Left Down is (0, 0)).</param>
        /// <param name="y">mouse position(Left Down is (0, 0)).</param>
        /// <param name="lastVertexId"></param>
        /// <param name="modernRenderer"></param>
        /// <returns></returns>
        internal override uint Search(RenderEventArgs arg,
                                      int x, int y,
                                      uint lastVertexId, ZeroIndexRenderer modernRenderer)
        {
            ZeroIndexBuffer zeroIndexBuffer = modernRenderer.IndexBuffer;
            // when the temp index buffer could be long, it's no longer needed.
            // what a great OpenGL API design!
            ZeroIndexBuffer indexBuffer = ZeroIndexBuffer.Create(DrawMode.Points, zeroIndexBuffer.FirstVertex, zeroIndexBuffer.RenderingVertexCount, zeroIndexBuffer.PrimCount);

            modernRenderer.Render4InnerPicking(arg, indexBuffer);
            uint id = ColorCodedPicking.ReadStageVertexId(x, y);

            indexBuffer.Dispose();

            if (zeroIndexBuffer.FirstVertex <= id &&
                id < zeroIndexBuffer.FirstVertex + zeroIndexBuffer.RenderingVertexCount)
            {
                return(id);
            }
            else
            {
                throw new Exception("This should not happen!");
            }
        }
Exemple #30
0
        /// <summary>
        /// Creates a <see cref="ZeroIndexBuffer"/> object directly in server side(GPU) without initializing its value.
        /// </summary>
        /// <param name="mode"></param>
        /// <param name="firstVertex"></param>
        /// <param name="vertexCount"></param>
        /// <param name="primCount"></param>
        /// <returns></returns>
        public static ZeroIndexBuffer Create(DrawMode mode, int firstVertex, int vertexCount, int primCount = 1)
        {
            ZeroIndexBuffer buffer = new ZeroIndexBuffer(mode, firstVertex, vertexCount, primCount);

            return buffer;
        }
 public ZeroIndexBufferController(ZeroIndexBuffer indexBuffer)
 {
     this.indexBuffer = indexBuffer;
 }
Exemple #32
0
        /// <summary>
        /// Creates a <see cref="ZeroIndexBuffer"/> object directly in server side(GPU) without initializing its value.
        /// <para><see cref="ZeroIndexBuffer"/> is not a real buffer like <see cref="OneIndexBuffer"/>.</para>
        /// </summary>
        /// <param name="mode"></param>
        /// <param name="firstVertex"></param>
        /// <param name="vertexCount"></param>
        /// <param name="primCount"></param>
        /// <returns></returns>
        public static ZeroIndexBuffer Create(DrawMode mode, int firstVertex, int vertexCount, int primCount = 1)
        {
            ZeroIndexBuffer buffer = new ZeroIndexBuffer(mode, firstVertex, vertexCount, primCount);

            return(buffer);
        }