Skip to main content

surfman/
error.rs

1//! Various errors that methods can produce.
2
3/// Various errors that methods can produce.
4#[derive(Debug)]
5pub enum Error {
6    /// The method failed for a miscellaneous reason.
7    Failed,
8    /// The platform doesn't support this method.
9    UnsupportedOnThisPlatform,
10    /// The platform supports this method in theory, but the functionality isn't implemented yet.
11    Unimplemented,
12    /// The system doesn't support the requested OpenGL API type (OpenGL or OpenGL ES).
13    UnsupportedGLType,
14    /// The system doesn't support the requested OpenGL compatibility profile for the supplied
15    /// OpenGL version.
16    ///
17    /// On some systems, like macOS, the compatibility profile is only supported on some GL
18    /// versions.
19    UnsupportedGLProfile,
20    /// The system doesn't support the requested OpenGL API version.
21    UnsupportedGLVersion,
22    /// Choosing an OpenGL pixel format failed.
23    PixelFormatSelectionFailed(WindowingApiError),
24    /// The system couldn't choose an OpenGL pixel format.
25    NoPixelFormatFound,
26    /// The system couldn't create an OpenGL context.
27    ContextCreationFailed(WindowingApiError),
28    /// The system couldn't destroy the OpenGL context.
29    ContextDestructionFailed(WindowingApiError),
30    /// The system couldn't make the OpenGL context current or not current.
31    MakeCurrentFailed(WindowingApiError),
32    /// The system OpenGL library couldn't be located.
33    NoGLLibraryFound,
34    /// An extension necessary for this library to function isn't supported.
35    RequiredExtensionUnavailable,
36    /// Looking up an OpenGL function address failed.
37    GLFunctionNotFound,
38    /// This context renders to an externally-managed render target.
39    ExternalRenderTarget,
40    /// A surface was already attached to this context.
41    SurfaceAlreadyBound,
42    /// No suitable adapter could be found.
43    NoAdapterFound,
44    /// The device couldn't be opened.
45    DeviceOpenFailed,
46    /// The system couldn't create a surface.
47    SurfaceCreationFailed(WindowingApiError),
48    /// The system couldn't import a surface from another thread.
49    SurfaceImportFailed(WindowingApiError),
50    /// The system couldn't create a surface texture from a surface.
51    SurfaceTextureCreationFailed(WindowingApiError),
52    /// The system couldn't present a widget surface.
53    PresentFailed(WindowingApiError),
54    /// A context couldn't be created because there is no current context.
55    NoCurrentContext,
56    /// The current connection couldn't be fetched because there is no current connection.
57    NoCurrentConnection,
58    /// The surface was not created from this context.
59    IncompatibleSurface,
60    /// The context descriptor is from a hardware device, but this is a software device, or vice
61    /// versa.
62    IncompatibleContextDescriptor,
63    /// The context is from a hardware device, but this is a software device, or vice versa.
64    IncompatibleContext,
65    /// The shared context is not compatible for sharing.
66    IncompatibleSharedContext,
67    /// The surface texture is from a hardware device, but this is a software device, or vice
68    /// versa.
69    IncompatibleSurfaceTexture,
70    /// The surface has no window attachment.
71    NoWidgetAttached,
72    /// The surface has a window attachment.
73    WidgetAttached,
74    /// The native widget is invalid.
75    InvalidNativeWidget,
76    /// The surface was not created with the `CPU_READ_WRITE` flag, so it cannot be accessed from
77    /// the CPU.
78    SurfaceDataInaccessible,
79    /// The surface could not be locked for CPU reading due to an OS error.
80    SurfaceLockFailed,
81    /// A connection to the display server could not be opened.
82    ConnectionFailed,
83    /// A connection to the window server is required to open a hardware device.
84    ConnectionRequired,
85    /// The adapter type does not match the supplied connection.
86    IncompatibleAdapter,
87    /// The native widget type does not match the supplied device.
88    IncompatibleNativeWidget,
89    /// The `raw display handle` is incompatible with this backend.
90    IncompatibleRawDisplayHandle,
91    /// The native context does not match the supplied device.
92    IncompatibleNativeContext,
93    /// The native device does not match the supplied connection.
94    IncompatibleNativeDevice,
95}
96
97/// Abstraction of the errors that EGL, CGL, GLX, CGL, etc. return.
98///
99/// They all tend to follow similar patterns.
100#[derive(Clone, Copy, Debug)]
101pub enum WindowingApiError {
102    /// Miscellaneous error.
103    Failed,
104    /// CGL: Invalid pixel format attribute.
105    /// EGL: An unrecognized attribute or attribute value was passed in the attribute list.
106    /// X11: Attribute to get is bad.
107    BadAttribute,
108    /// CGL: Invalid renderer property.
109    BadProperty,
110    /// CGL: Invalid pixel format object.
111    /// X11: Invalid framebuffer configuration, including an unsupported OpenGL version.
112    BadPixelFormat,
113    /// CGL: Invalid renderer information object.
114    BadRendererInfo,
115    /// CGL: Invalid context object.
116    /// EGL: An EGLContext argument does not name a valid EGL rendering context.
117    /// X11: The context is invalid.
118    BadContext,
119    /// Invalid drawable.
120    BadDrawable,
121    /// CGL: Invalid display.
122    /// EGL: An EGLDisplay argument does not name a valid EGL display connection.
123    BadDisplay,
124    /// CGL: Invalid context state.
125    BadState,
126    /// CGL: Invalid numerical value.
127    /// X11: Invalid value.
128    /// GL: Given when a value parameter is not a legal value for that function.
129    BadValue,
130    /// CGL: Invalid share context.
131    /// EGL: Arguments are inconsistent (for example, a valid context requires
132    /// buffers not supplied by a valid surface).
133    BadMatch,
134    /// CGL: Invalid enumerant (constant).
135    /// X11: Invalid enum value.
136    /// GL: Given when an enumeration parameter is not a legal enumeration for that function.
137    BadEnumeration,
138    /// CGL: Invalid off-screen drawable.
139    BadOffScreen,
140    /// CGL: Invalid full-screen drawable.
141    BadFullScreen,
142    /// CGL: Invalid window.
143    BadWindow,
144    /// CGL: Invalid address; e.g. null pointer passed to function requiring
145    /// a non-null pointer argument.
146    BadAddress,
147    /// CGL: Invalid code module.
148    BadCodeModule,
149    /// CGL: Invalid memory allocation; i.e. CGL couldn't allocate memory.
150    /// EGL: EGL failed to allocate resources for the requested operation.
151    BadAlloc,
152    /// CGL: Invalid Core Graphics connection.
153    BadConnection,
154    /// EGL: EGL is not initialized, or could not be initialized, for the
155    /// specified EGL display connection.
156    NotInitialized,
157    /// EGL: EGL cannot access a requested resource (for example a context is
158    /// bound in another thread).
159    BadAccess,
160    /// EGL: The current surface of the calling thread is a window, pixel
161    /// buffer or pixmap that is no longer valid.
162    BadCurrentSurface,
163    /// EGL: An EGLSurface argument does not name a valid surface (window,
164    /// pixel buffer or pixmap) configured for GL rendering.
165    BadSurface,
166    /// EGL: One or more argument values are invalid.
167    BadParameter,
168    /// EGL: A NativePixmapType argument does not refer to a valid native
169    /// pixmap.
170    BadNativePixmap,
171    /// EGL: A NativeWindowType argument does not refer to a valid native
172    /// window.
173    BadNativeWindow,
174    /// EGL: A power management event has occurred. The application must
175    /// destroy all contexts and reinitialise OpenGL ES state and objects to
176    /// continue rendering.
177    ContextLost,
178    /// X11: Screen number is bad.
179    BadScreen,
180    /// X11: The GLX extension is unavailable on the server.
181    NoExtension,
182    /// X11: Visual number not known by GLX.
183    BadVisual,
184    /// GL: Given when the set of state for a command is not legal for the parameters given to that
185    /// command.
186    BadOperation,
187    /// EGL: The EGL configuration is unsupported.
188    BadConfig,
189}