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