Example #1
0
        public static void CreateVertexArraysQBF(int size, out int vertexArrayID, out int vertexBufferID)
        {
            Shader s = ShaderUtil.GetShader("qb");

            vertexBufferID = GL.GenBuffer();
            GL.BindBuffer(BufferTarget.ArrayBuffer, vertexBufferID);
            GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(size), IntPtr.Zero, BufferUsageHint.DynamicDraw);
            GL.BindBuffer(BufferTarget.ArrayBuffer, 0);

            vertexArrayID = GL.GenVertexArray();
            GL.BindVertexArray(vertexArrayID);
            GL.BindBuffer(BufferTarget.ArrayBuffer, vertexBufferID);

            GL.EnableVertexAttribArray(0);
            GL.VertexAttribPointer(s.getartributelocation("position"), 3, VertexAttribPointerType.Float, false, sizeof(float) * 4, 0);

            GL.EnableVertexAttribArray(1);
            GL.VertexAttribPointer(s.getartributelocation("color"), 1, VertexAttribPointerType.Float, false, sizeof(float) * 4, sizeof(float) * 3);

            //GL.EnableVertexAttribArray(2);
            //GL.VertexAttribPointer(s.getartributelocation("light"), 1, VertexAttribPointerType.Float, false, sizeof(float) * 7, sizeof(float) * 6);

            //GL.BindBuffer(BufferTarget.ElementArrayBuffer, indexBuffer);
            GL.BindVertexArray(0);
        }
        public override void Initialize()
        {
            // bottom left
            colors[0] = Color4.Black;

            //bottom riht
            colors[1] = new Color4(.5f, 0, 0, 1);

            // top right
            colors[2] = Color4.Red;

            // top left
            colors[3] = Color4.White;

            data = new float[28];

            bufferID = GL.GenBuffer();
            GL.BindBuffer(BufferTarget.ArrayBuffer, bufferID);

            GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(sizeof(float) * data.Length), IntPtr.Zero, BufferUsageHint.DynamicDraw);
            GL.BindBuffer(BufferTarget.ArrayBuffer, 0);

            arrayID = GL.GenVertexArray();
            GL.BindVertexArray(arrayID);
            GL.BindBuffer(BufferTarget.ArrayBuffer, bufferID);

            GL.EnableVertexAttribArray(0);
            GL.VertexAttribPointer(quadInterpolation.getartributelocation("position"), 2, VertexAttribPointerType.Float, false, sizeof(float) * 7, 0);

            GL.EnableVertexAttribArray(1);
            GL.VertexAttribPointer(quadInterpolation.getartributelocation("in_uv"), 2, VertexAttribPointerType.Float, false, sizeof(float) * 7, sizeof(float) * 2);

            GL.EnableVertexAttribArray(2);
            GL.VertexAttribPointer(quadInterpolation.getartributelocation("in_color"), 3, VertexAttribPointerType.Float, false, sizeof(float) * 7, sizeof(float) * 4);

            GL.BindVertexArray(0);
        }