glfw: Denormalize errors (#115)
Closes hexops/mach#96 Co-authored-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
233fc53a17
commit
3648d6b9c4
11 changed files with 457 additions and 206 deletions
|
|
@ -4,6 +4,12 @@ const c = @import("c.zig").c;
|
|||
|
||||
/// Errors that GLFW can produce.
|
||||
pub const Error = error{
|
||||
/// GLFW has not been initialized.
|
||||
///
|
||||
/// This occurs if a GLFW function was called that must not be called unless the library is
|
||||
/// initialized.
|
||||
NotInitialized,
|
||||
|
||||
/// No context is current for this thread.
|
||||
///
|
||||
/// This occurs if a GLFW function was called that needs and operates on the current OpenGL or
|
||||
|
|
@ -11,6 +17,12 @@ pub const Error = error{
|
|||
/// glfw.SwapInterval.
|
||||
NoCurrentContext,
|
||||
|
||||
/// One of the arguments to the function was an invalid enum value.
|
||||
///
|
||||
/// One of the arguments to the function was an invalid enum value, for example requesting
|
||||
/// glfw.red_bits with glfw.getWindowAttrib.
|
||||
InvalidEnum,
|
||||
|
||||
/// One of the arguments to the function was an invalid value.
|
||||
///
|
||||
/// One of the arguments to the function was an invalid value, for example requesting a
|
||||
|
|
@ -78,9 +90,9 @@ pub const Error = error{
|
|||
fn convertError(e: c_int) Error!void {
|
||||
return switch (e) {
|
||||
c.GLFW_NO_ERROR => {},
|
||||
c.GLFW_NOT_INITIALIZED => unreachable,
|
||||
c.GLFW_NOT_INITIALIZED => Error.NotInitialized,
|
||||
c.GLFW_NO_CURRENT_CONTEXT => Error.NoCurrentContext,
|
||||
c.GLFW_INVALID_ENUM => unreachable,
|
||||
c.GLFW_INVALID_ENUM => Error.InvalidEnum,
|
||||
c.GLFW_INVALID_VALUE => Error.InvalidValue,
|
||||
c.GLFW_OUT_OF_MEMORY => Error.OutOfMemory,
|
||||
c.GLFW_API_UNAVAILABLE => Error.APIUnavailable,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue