
Using Dynamic VAO's
Posted Thursday, 26 August, 2010 - 21:23 by hannesh inHi,
My game has many VBO's which will change very unfrequently.
The way I'm doing this in pseudo code is as follows:
int VBOHandle = -1; int VAOHandle = -1; void ChangeData() { if (VAOid == -1) //if not created yet { GL.GenVertexArrays(1, out VAOid); GL.GenBuffers(1, out VBOid); GL.BindVertexArray(VAOid); GL.BindBuffer(BufferTarget.ArrayBuffer, VBOid); } else GL.BindVertexArray(VAOid); //otherwise just bind it GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(VertexCount * CubeVertex.SizeInBytes), vertices, BufferUsageHint.DynamicDraw); GL.EnableClientState(ArrayCap.VertexArray); CubeVertex.SetVertexPointers(); GL.BindVertexArray(0); } void Unload() { GL.DeleteVertexArrays(1, ref VAOid); GL.DeleteBuffers(1, ref VBOid); VAOid = -1; VBOid = -1; } void Draw() //I'm positive that this must be right { GL.BindVertexArray(VAOid); GL.DrawArrays(BeginMode.Quads, 0, VertexCount); GL.BindVertexArray(0); }
It draws alright, but as soon as I start changing, I get some odd results. For example objects drawing stuff that was created by a different object.

