コード例 #1
0
            private void CreateVBOs()
            {
                this.positionVboHandle = GL.CreateBuffer();
                this.elementsHandle    = GL.CreateBuffer();
                GL.BindBuffer(GL.GL_ARRAY_BUFFER, this.positionVboHandle);
                GL.BindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, this.elementsHandle);

                this.vaoHandle = GL.CreateVertexArray();
                GL.BindVertexArray(this.vaoHandle);

                GL.BindBuffer(GL.GL_ARRAY_BUFFER, this.positionVboHandle);

                GL.EnableVertexAttribArray(this.attributePositon);
                GL.EnableVertexAttribArray(this.attributeUV);
                GL.EnableVertexAttribArray(this.attributeColor);

                GL.VertexAttribPointer(this.attributePositon, 2, GL.GL_FLOAT, false, Marshal.SizeOf <DrawVertex>(), Marshal.OffsetOf <DrawVertex>("pos").ToInt32());
                GL.VertexAttribPointer(this.attributeUV, 2, GL.GL_FLOAT, false, Marshal.SizeOf <DrawVertex>(), Marshal.OffsetOf <DrawVertex>("uv").ToInt32());
                GL.VertexAttribPointer(this.attributeColor, 4, GL.GL_FLOAT, true, Marshal.SizeOf <DrawVertex>(), Marshal.OffsetOf <DrawVertex>("color").ToInt32());

                Utility.CheckWebGLError();
            }