Exemple #1
0
        // Note that buffer capacity is given in bytes while index capacity is given in unsigned shorts.
        public unsafe PrimitiveBuffer(BufferFrequencies frequency, BufferUsages usage, uint bufferCapacity = 0,
                                      uint indexCapacity = 0)
        {
            this.usage = (uint)frequency + (uint)usage;

            GLUtilities.GenerateBuffers(out bufferId, out indexId);

            buffer      = new byte[bufferCapacity];
            indexBuffer = new ushort[indexCapacity];
            maxIndex    = -1;

            if (bufferCapacity > 0)
            {
                allocatedBufferCapacity = bufferCapacity;

                glBindBuffer(GL_ARRAY_BUFFER, bufferId);
                glBufferData(GL_ARRAY_BUFFER, bufferCapacity, (void *)0, this.usage);
            }

            if (indexCapacity > 0)
            {
                allocatedIndexCapacity = sizeof(ushort) * indexCapacity;

                glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexId);
                glBufferData(GL_ELEMENT_ARRAY_BUFFER, allocatedIndexCapacity, (void *)0, this.usage);
            }
        }
Exemple #2
0
 public PrimitiveBuffer(BufferFrequencies frequency, BufferUsages usage, out uint bufferId,
                        out uint indexId, uint bufferCapacity = 0, uint indexCapacity = 0) :
     this(frequency, usage, bufferCapacity, indexCapacity)
 {
     bufferId = this.bufferId;
     indexId  = this.indexId;
 }