Skip to content

Instantly share code, notes, and snippets.

@JonRurka
Created January 3, 2015 04:10
Show Gist options
  • Save JonRurka/ea3b2b2d85dcdddf34d4 to your computer and use it in GitHub Desktop.
Save JonRurka/ea3b2b2d85dcdddf34d4 to your computer and use it in GitHub Desktop.
public void Flush()
{
try
{
unsafe
{
fixed (float* pVert = vertexBuffer, pTex = texCoordBuffer, pCol = ColorBuffer)
{
GL.VertexPointer(3, 0, 0, (IntPtr)pVert);
if (hasTexture)
GL.TexCoordPointer(2, 0, 0, (IntPtr)pTex);
if (hasColor)
GL.ColorPointer(3, 0, 0, (IntPtr)pCol);
GL.EnableClientState(ArrayCap.VertexArray);
if (hasTexture)
GL.EnableClientState(ArrayCap.TextureCoordArray);
if (hasColor)
GL.EnableClientState(ArrayCap.ColorArray);
GL.DrawArrays(PrimitiveType.Quads, 0, vertices);
GL.DisableClientState(ArrayCap.VertexArray);
if (hasTexture)
GL.DisableClientState(ArrayCap.TextureCoordArray);
if (hasColor)
GL.DisableClientState(ArrayCap.ColorArray);
GL.Finish();
Clear();
}
}
}
catch (Exception e)
{
System.Windows.Forms.MessageBox.Show(e.Message, "Flush Error", System.Windows.Forms.MessageBoxButtons.OK);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment