Exemple #1
0
        public Voxel(Shader shader)
            : base()
        {
            this.shader = shader;
            geometry = new VertexArray(PrimitiveType.Triangles);
            vertex = geometry.CreateBuffer("vertex", BufferTarget.ArrayBuffer);
            colors = geometry.CreateBuffer("colors", BufferTarget.ArrayBuffer);
            normal = geometry.CreateBuffer("normal", BufferTarget.ArrayBuffer);

            Byte3[] colorData =  ColorData(new Byte3(255, 0, 0), new Byte3(0, 255, 255),
                                           new Byte3(0, 255, 0), new Byte3(255, 0, 255),
                                           new Byte3(0, 0, 255), new Byte3(255, 255, 0));
            vertex.BufferData<Byte3>(ref vertexData);
            colors.BufferData<Byte3>(ref colorData);
            normal.BufferData<SByte3>(ref normalData);

            geometry.AddPointer("vertex", new VertexAttribute(this.shader, "vPosition", VertexAttribPointerType.UnsignedByte, 3, 0, false));
            geometry.AddPointer("colors", new VertexAttribute(this.shader, "vColor", VertexAttribPointerType.UnsignedByte, 3, 0, true));
            geometry.AddPointer("normal", new VertexAttribute(this.shader, "vNormal", VertexAttribPointerType.Byte, 3, 0, true));
        }