mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-23 03:51:05 +00:00
Report the size of uploaded VBO data, when an error occurs.
This commit is contained in:
parent
37c40f16eb
commit
59ad653760
|
@ -132,24 +132,33 @@ namespace Examples.Tutorial
|
|||
|
||||
// Upload the vertex data.
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, vertex_buffer_object);
|
||||
GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(shape.Vertices.Length * 3 * sizeof(float)), shape.Vertices, BufferUsageHint.StaticDraw);
|
||||
GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(shape.Vertices.Length * 3 * sizeof(float)), shape.Vertices,
|
||||
BufferUsageHint.StaticDraw);
|
||||
GL.GetBufferParameter(BufferTarget.ArrayBuffer, BufferParameterName.BufferSize, out size);
|
||||
if (size != shape.Vertices.Length * 3 * sizeof(Single))
|
||||
throw new ApplicationException("Problem uploading vertex data to VBO");
|
||||
throw new ApplicationException(String.Format(
|
||||
"Problem uploading vertex data to VBO (vertices). Tried to upload {0} bytes, uploaded {1}.",
|
||||
shape.Vertices.Length * 3 * sizeof(Single), size));
|
||||
|
||||
// Upload the color data.
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, color_buffer_object);
|
||||
GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(shape.Colors.Length * sizeof(int)), shape.Colors, BufferUsageHint.StaticDraw);
|
||||
GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(shape.Colors.Length * sizeof(int)), shape.Colors,
|
||||
BufferUsageHint.StaticDraw);
|
||||
GL.GetBufferParameter(BufferTarget.ArrayBuffer, BufferParameterName.BufferSize, out size);
|
||||
if (shape.Colors.Length * sizeof(int) != size)
|
||||
throw new ApplicationException("Problem uploading color data to VBO");
|
||||
if (size != shape.Colors.Length * sizeof(int))
|
||||
throw new ApplicationException(String.Format(
|
||||
"Problem uploading vertex data to VBO (colors). Tried to upload {0} bytes, uploaded {1}.",
|
||||
shape.Colors.Length * sizeof(int), size));
|
||||
|
||||
// Upload the index data (elements inside the vertex data, not color indices as per the IndexPointer function!)
|
||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, element_buffer_object);
|
||||
GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(shape.Indices.Length * sizeof(Int32)), shape.Indices, BufferUsageHint.StaticDraw);
|
||||
GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(shape.Indices.Length * sizeof(Int32)), shape.Indices,
|
||||
BufferUsageHint.StaticDraw);
|
||||
GL.GetBufferParameter(BufferTarget.ElementArrayBuffer, BufferParameterName.BufferSize, out size);
|
||||
if (shape.Indices.Length * 4 != size)
|
||||
throw new ApplicationException("Problem uploading index data to VBO");
|
||||
if (size != shape.Indices.Length * sizeof(int))
|
||||
throw new ApplicationException(String.Format(
|
||||
"Problem uploading vertex data to VBO (offsets). Tried to upload {0} bytes, uploaded {1}.",
|
||||
shape.Indices.Length * sizeof(int), size));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -256,7 +265,7 @@ namespace Examples.Tutorial
|
|||
//if (error != 0)
|
||||
// Debug.Print(Glu.ErrorString(Glu.Enums.ErrorCode.INVALID_OPERATION));
|
||||
|
||||
Context.SwapBuffers();
|
||||
SwapBuffers();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
Loading…
Reference in a new issue