VertexAttribPointer() public static method

public static VertexAttribPointer ( int index, int size, VertexAttribPointerType type, bool normalized, int stride, int offset ) : void
index int
size int
type VertexAttribPointerType
normalized bool
stride int
offset int
return void
Ejemplo n.º 1
0
        protected override void OnLoad()
        {
            GL.ClearColor(1f, 1f, 1f, 1.0f);

            VertexBufferObject = GL.GenBuffer();
            GL.BindBuffer(BufferTarget.ArrayBuffer, VertexBufferObject);
            GL.BufferData(BufferTarget.ArrayBuffer, vertices.Length * sizeof(float), vertices, BufferUsageHint.StaticDraw);

            VertexArrayObject = GL.GenVertexArray();
            GL.BindVertexArray(VertexArrayObject);
            GL.BindBuffer(BufferTarget.ArrayBuffer, VertexArrayObject);
            GL.BufferData(BufferTarget.ArrayBuffer, vertices.Length * sizeof(float), vertices, BufferUsageHint.StaticDraw);

            ElementBufferObject = GL.GenBuffer();
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, ElementBufferObject);
            GL.BufferData(BufferTarget.ElementArrayBuffer, indices.Length * sizeof(uint), indices, BufferUsageHint.StaticDraw);

            GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 3 * sizeof(float), 0);
            GL.EnableVertexAttribArray(0);

            Shader = new Shader(
                Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"shaders\shader.vert.glsl")),
                Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"shaders\shader.frag.glsl")));

            Shader.Use();

            _timer = new Stopwatch();
            _timer.Start();

            base.OnLoad();
        }
Ejemplo n.º 2
0
 public void SetupAttributePointersNew()
 {
     foreach (AttributeBinding binding in bindings)
     {
         GL.EnableVertexAttribArray(binding.AttributeMapping.Slot);
         if (
             (binding.Type == VertexAttribPointerType.Double) ||
             (binding.Type == VertexAttribPointerType.Float) ||
             (binding.Type == VertexAttribPointerType.HalfFloat)
             )
         {
             GL.VertexAttribPointer(
                 binding.AttributeMapping.Slot,
                 binding.Size,
                 binding.Type,
                 binding.Normalized,
                 binding.Stride,
                 (IntPtr)((long)(binding.Offset) /* + (vertexBufferRange.OffsetBytes)*/)
                 );
         }
         else
         {
             GL.VertexAttribIPointer(
                 binding.AttributeMapping.Slot,
                 binding.Size,
                 (VertexAttribIPointerType)binding.Type,
                 binding.Stride,
                 (IntPtr)((long)(binding.Offset) /* + (vertexBufferRange.OffsetBytes)*/)
                 );
         }
     }
 }
Ejemplo n.º 3
0
 private static void overrideDataInAttributeList(int ID, int attrib, int coordSize, float[] data)
 {
     GL.BindBuffer(BufferTarget.ArrayBuffer, ID);
     GL.BufferData(BufferTarget.ArrayBuffer, sizeof(float) * data.Length, data, BufferUsageHint.DynamicDraw);
     GL.VertexAttribPointer(attrib, coordSize, VertexAttribPointerType.Float, false, 0, 0);
     GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
 }
Ejemplo n.º 4
0
        private static int storeDataInAttributeList(int attrib, int coordSize, float[] data)
        {
            int vboID = GL.GenBuffer();

            VBOs.Add(vboID);

            GL.BindBuffer(BufferTarget.ArrayBuffer, vboID);
            GL.BufferData(BufferTarget.ArrayBuffer, sizeof(float) * data.Length, data, BufferUsageHint.DynamicDraw);
            GL.VertexAttribPointer(attrib, coordSize, VertexAttribPointerType.Float, false, 0, 0);
            GL.BindBuffer(BufferTarget.ArrayBuffer, 0);

            return(vboID);
        }
Ejemplo n.º 5
0
        public static void LoadVertexPositions(int shaderProgramHandle, Vector3[] positionVboData)
        {
            int positionVboHandle;

            GL.GenBuffers(1, out positionVboHandle);
            GL.BindBuffer(BufferTarget.ArrayBuffer, positionVboHandle);
            GL.BufferData <Vector3>(BufferTarget.ArrayBuffer,
                                    new IntPtr(positionVboData.Length * Vector3.SizeInBytes),
                                    positionVboData, BufferUsageHint.StaticDraw);


            GL.EnableVertexAttribArray(0);
            GL.BindAttribLocation(shaderProgramHandle, 0, "inPosition");
            GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, Vector3.SizeInBytes, 0);
        }
Ejemplo n.º 6
0
 public void VertexAttribPointer(int index, int size, GLDataType type, bool normalized, int stride, int offset)
 {
     GL.VertexAttribPointer(index, size, (VertexAttribPointerType)type, normalized, stride, offset);
 }