Beispiel #1
0
        internal void DeleteBuffer(glBuffer Buffer)
        {
            int bufferHandle = Buffer.Handle;

            lock (this)
            {
#if NET_STANDARD_13
                _glDeleteBuffers(1, &bufferHandle);
#else
                if (_CurrentThreadId == Thread.CurrentThread.ManagedThreadId)
                {
                    _glDeleteBuffers(1, &bufferHandle);
                }
                else
                {
                    if (_PendingBufferDeleteCount == _PendingBufferDelete.Length)
                    {
                        Array.Resize <int>(ref _PendingBufferDelete, _PendingBufferDelete.Length * 2);
                    }
                    _PendingBufferDelete[_PendingBufferDeleteCount] = bufferHandle;
                    _PendingBufferDeleteCount++;
                }
#endif
            }
        }
Beispiel #2
0
        public glBuffer[] GenBuffers(int numBuffers)
        {
            int[] bufferHandle = new int[numBuffers];
            fixed(int *pbufferHandles = &bufferHandle[0])
            {
                _glGenBuffers(numBuffers, pbufferHandles);
            }

            glBuffer[] buffers = new glBuffer[numBuffers];
            for (int n = 0; n < numBuffers; n++)
            {
                buffers[n] = new glBuffer(this, bufferHandle[n]);
            }
            return(buffers);
        }
Beispiel #3
0
        internal void BufferData(glBuffer Buffer, glBuffer.BindTarget Target, int Size, IntPtr Data, glBuffer.Usage Usage)
        {
            int indexTarget = GlTargetTobufferTargetIndex(Target);

            if (Size < 0)
            {
                throw new Exception("Negative buffer size are not allowed");
            }
            lock (_Buffers)
            {
                if (_Buffers[indexTarget] != Buffer)
                {
                    throw new Exception("Trying to set buffer data while the buffer is not bound to the specified target");
                }
                _glBufferData((int)Target, new IntPtr(Size), Data.ToPointer(), (int)Usage);
            }
        }
Beispiel #4
0
        internal void BindBuffer(glBuffer Buffer, glBuffer.BindTarget Target)
        {
            int indexTarget = GlTargetTobufferTargetIndex(Target);

            lock (_Buffers)
            {
                if (Buffer == null)
                {
                    _glBindBuffer((int)Target, 0);
                    _Buffers[indexTarget] = null;
                }
                else
                {
                    _glBindBuffer((int)Target, Buffer.Handle);
                    _Buffers[indexTarget] = Buffer;
                }
            }
        }