Пример #1
0
        public void SetVertexAttrib(uint index, GpuBuffer buffer, int size, bool normalized = false, int stride = 0, uint offset = 0)
        {
            Bind();
            buffer.Bind();

            GL.VertexAttribPointer(index, size, (uint)buffer.Type, normalized, stride, new IntPtr(offset));
            GL.EnableVertexAttribArray(index);
        }
Пример #2
0
        public static GpuBuffer[] Create(int n, BufferTarget target = BufferTarget.Array)
        {
            uint[] handles = new uint[n];
            GL.GenBuffers(n, handles);

            var result = new GpuBuffer[n];

            for (int i = 0; i < n; i++)
            {
                result[i] = new GpuBuffer(handles[i], target);
            }

            return(result);
        }
Пример #3
0
        public static GpuBuffer[] Create(BufferTarget[] targets)
        {
            int n = targets.Length;

            uint[] handles = new uint[n];
            GL.GenBuffers(n, handles);

            var result = new GpuBuffer[n];

            for (int i = 0; i < n; i++)
            {
                result[i] = new GpuBuffer(handles[i], targets[i]);
            }

            return(result);
        }
Пример #4
0
        public void SetVertexAttrib(uint index, GpuBuffer buffer, int size, DataType type, bool normalized = false, int stride = 0, uint offset = 0)
        {
            Bind();
            buffer.Bind();

            switch (type)
            {
            case DataType.Byte:
            case DataType.UnsignedByte:
            case DataType.Short:
            case DataType.UnsignedShort:
            case DataType.Int:
            case DataType.UnsignedInt:
                GL.VertexAttribIPointer(index, size, (uint)type, stride, new IntPtr(offset));
                break;

            default:
                GL.VertexAttribPointer(index, size, (uint)type, normalized, stride, new IntPtr(offset));
                break;
            }
            GL.EnableVertexAttribArray(index);
        }