Exemple #1
0
        private static void initBuffers()
        {
            triangleVertexPositionBuffer = new PositionBuffer();
            triangleVertexPositionBuffer.Buffer = gl.CreateBuffer();
            gl.BindBuffer(gl.ArrayBuffer, triangleVertexPositionBuffer.Buffer);
            var vertices = new [] {
                 0.0,  1.0,  0.0,
                -1.0, -1.0,  0.0,
                 1.0, -1.0,  0.0
            };
            gl.BufferData(gl.ArrayBuffer, Float32Array.Create(vertices), gl.StaticDraw);
            triangleVertexPositionBuffer.ItemSize = 3;
            triangleVertexPositionBuffer.NumItems = 3;

            squareVertexPositionBuffer = new PositionBuffer();
            squareVertexPositionBuffer.Buffer = gl.CreateBuffer();
            gl.BindBuffer(gl.ArrayBuffer, squareVertexPositionBuffer.Buffer);
            vertices = new [] {
                 1.0,  1.0,  0.0,
                -1.0,  1.0,  0.0,
                 1.0, -1.0,  0.0,
                -1.0, -1.0,  0.0
            };
            gl.BufferData(gl.ArrayBuffer, Float32Array.Create(vertices), gl.StaticDraw);
            squareVertexPositionBuffer.ItemSize = 3;
            squareVertexPositionBuffer.NumItems = 4;
        }