Esempio n. 1
0
        public void ExampleCreateArrayBufferObject(GraphicsContext ctx)
        {
            using (ArrayBuffer <Vertex3f> vertexPosition = new ArrayBuffer <Vertex3f>(BufferUsage.StaticDraw)) {
                // Define CPU data
                vertexPosition.Create(new Vertex3f[] {
                    Vertex3f.UnitX, Vertex3f.UnitY, Vertex3f.UnitZ
                });
                // Create GPU data
                vertexPosition.Create(ctx);
            }

            using (ArrayBuffer <ColorRGBAF> vertexColor = new ArrayBuffer <ColorRGBAF>(BufferUsage.StaticDraw)) {
                // Define GPU items count
                vertexColor.Create(256);
                // Reserve GPU memory
                vertexColor.Create(ctx);
                // Update
                vertexColor.Create(ctx, new ColorRGBAF[] { ColorRGBAF.ColorRed, ColorRGBAF.ColorGreen, ColorRGBAF.ColorBlue });
            }

            // By ArrayBufferItemType
            using (ArrayBuffer buffer = ArrayBuffer.CreateArrayObject(ArrayBufferItemType.Float3x3, BufferUsage.StaticDraw)) {
                // ...
            }
        }