mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-02-02 23:31:11 +00:00
Report the size of uploaded VBO data, when an error occurs.
This commit is contained in:
parent
223c742648
commit
edd10b86d9
|
@ -132,24 +132,33 @@ namespace Examples.Tutorial
|
||||||
|
|
||||||
// Upload the vertex data.
|
// Upload the vertex data.
|
||||||
GL.BindBuffer(BufferTarget.ArrayBuffer, vertex_buffer_object);
|
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);
|
GL.GetBufferParameter(BufferTarget.ArrayBuffer, BufferParameterName.BufferSize, out size);
|
||||||
if (size != shape.Vertices.Length * 3 * sizeof(Single))
|
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.
|
// Upload the color data.
|
||||||
GL.BindBuffer(BufferTarget.ArrayBuffer, color_buffer_object);
|
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);
|
GL.GetBufferParameter(BufferTarget.ArrayBuffer, BufferParameterName.BufferSize, out size);
|
||||||
if (shape.Colors.Length * sizeof(int) != size)
|
if (size != shape.Colors.Length * sizeof(int))
|
||||||
throw new ApplicationException("Problem uploading color data to VBO");
|
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!)
|
// 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.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);
|
GL.GetBufferParameter(BufferTarget.ElementArrayBuffer, BufferParameterName.BufferSize, out size);
|
||||||
if (shape.Indices.Length * 4 != size)
|
if (size != shape.Indices.Length * sizeof(int))
|
||||||
throw new ApplicationException("Problem uploading index data to VBO");
|
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
|
#endregion
|
||||||
|
@ -256,7 +265,7 @@ namespace Examples.Tutorial
|
||||||
//if (error != 0)
|
//if (error != 0)
|
||||||
// Debug.Print(Glu.ErrorString(Glu.Enums.ErrorCode.INVALID_OPERATION));
|
// Debug.Print(Glu.ErrorString(Glu.Enums.ErrorCode.INVALID_OPERATION));
|
||||||
|
|
||||||
Context.SwapBuffers();
|
SwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
Loading…
Reference in a new issue