Beispiel #1
0
        public void Render(BxlytShader shader, Vector2[] positions, Vector4[] colors, Vector2[] texCoords0)
        {
            shader.Enable();

            bool buffersWereInitialized = vbo_position != 0 && ibo_position != 0;

            if (!buffersWereInitialized)
            {
                GenerateBuffers(positions, colors, texCoords0);
            }

            shader.EnableVertexAttributes();
            GL.BindBuffer(BufferTarget.ArrayBuffer, vbo_position);
            GL.VertexAttribPointer(shader.GetAttribute("vPosition"), 2, VertexAttribPointerType.Float, false, Vertex.SizeInBytes, 0);
            GL.VertexAttribPointer(shader.GetAttribute("vColor"), 4, VertexAttribPointerType.Float, false, Vertex.SizeInBytes, 8);
            GL.VertexAttribPointer(shader.GetAttribute("vTexCoord0"), 2, VertexAttribPointerType.Float, false, Vertex.SizeInBytes, 24);
            GL.VertexAttribPointer(shader.GetAttribute("vTexCoord1"), 2, VertexAttribPointerType.Float, false, Vertex.SizeInBytes, 32);
            GL.VertexAttribPointer(shader.GetAttribute("vTexCoord2"), 2, VertexAttribPointerType.Float, false, Vertex.SizeInBytes, 40);
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, ibo_position);
            GL.DrawElements(PrimitiveType.Quads, 4, DrawElementsType.UnsignedShort, IntPtr.Zero);
            shader.DisableVertexAttributes();
        }