int[] vertexData = new int[] { 0, 1, 2, 3 }; int vertexBufferId = GL.GenBuffer(); GL.BindBuffer(BufferTarget.ArrayBuffer, vertexBufferId); GL.BufferData(BufferTarget.ArrayBuffer, vertexData.Length * sizeof(int), vertexData, BufferUsageHint.StaticDraw);
float[] colorData = new float[] { 1.0f, 0.0f, 0.0f, 1.0f }; int colorBufferId = GL.GenBuffer(); GL.BindBuffer(BufferTarget.ArrayBuffer, colorBufferId); GL.BufferData(BufferTarget.ArrayBuffer, colorData.Length * sizeof(float), colorData, BufferUsageHint.DynamicDraw);In this example, we create a float array called colorData and generate a new color buffer. We then bind the buffer to the ArrayBuffer and upload the data to it using the Gl BufferData method. The DynamicDraw usage hint specifies that the data may be modified frequently. Overall, the Gl BufferData method is a useful tool for uploading data to buffer objects when working with graphics in C#.