mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-05-30 08:45:23 +00:00
@cImport is going to disappear in Zig 0.17. Its deprecated in Zig 0.16. Let's remove it now. Replace @cImport with addTranslateC across pkg/ packages. Each package now has a c_import.h header that is translated at build time via addTranslateC and exposed as a "cimport" module import. Converted packages: - dcimgui - fontconfig - freetype - glslang - harfbuzz - macos - oniguruma - opengl - sentry - spirv-cross - wuffs Omitted: - gtk4-layer-shell - This has a bit more complexity with how it interacts with GTK headers, so I need to consider this a bit more. - src/ - It'll be cleaner to do this separately.
34 lines
961 B
Zig
34 lines
961 B
Zig
const std = @import("std");
|
|
const c = @import("c");
|
|
const glad = @import("glad.zig");
|
|
|
|
pub const Error = error{
|
|
InvalidEnum,
|
|
InvalidValue,
|
|
InvalidOperation,
|
|
InvalidFramebufferOperation,
|
|
OutOfMemory,
|
|
|
|
Unknown,
|
|
};
|
|
|
|
/// getError returns the error (if any) from the last OpenGL operation.
|
|
pub fn getError() Error!void {
|
|
return switch (glad.context.GetError.?()) {
|
|
c.GL_NO_ERROR => {},
|
|
c.GL_INVALID_ENUM => Error.InvalidEnum,
|
|
c.GL_INVALID_VALUE => Error.InvalidValue,
|
|
c.GL_INVALID_OPERATION => Error.InvalidOperation,
|
|
c.GL_INVALID_FRAMEBUFFER_OPERATION => Error.InvalidFramebufferOperation,
|
|
c.GL_OUT_OF_MEMORY => Error.OutOfMemory,
|
|
else => Error.Unknown,
|
|
};
|
|
}
|
|
|
|
/// mustError just calls getError but always results in an error being returned.
|
|
/// If getError has no error, then Unknown is returned.
|
|
pub fn mustError() Error!void {
|
|
try getError();
|
|
return Error.Unknown;
|
|
}
|