mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-09-19 20:18:07 +00:00
This migrates all remaining uses of cImport (and addTranslateC for good measure) to using translate-c for C translation, ensuring that we are ready for when cImport is removed from the language, and also that all sources of C translation are using the same snapshot of the external package (when can then be updated when we need to fix something). A couple of notes: * A few options have been added to support the new translations, namely the ability to link libraries (passed through to linkLibrary on the Translator side) and whether or not to initialize default values (looks like cImport did this without a way to control it, but translate-c does not do it by default). * Using the new library linking option actually simplifies the process of translating a number of the C packages as we have been shipping the necessary headers for these packages already with the applicable libraries. For some of the more complex translation processes though, we still include the appropriate directories directly.
33 lines
875 B
Zig
33 lines
875 B
Zig
const std = @import("std");
|
|
const c = @import("opengl_c");
|
|
const errors = @import("errors.zig");
|
|
const glad = @import("glad.zig");
|
|
|
|
/// Returns the number of extensions.
|
|
pub fn len() !u32 {
|
|
var n: c.GLint = undefined;
|
|
glad.context.GetIntegerv.?(c.GL_NUM_EXTENSIONS, &n);
|
|
try errors.getError();
|
|
return @intCast(n);
|
|
}
|
|
|
|
/// Returns an iterator for the extensions.
|
|
pub fn iterator() !Iterator {
|
|
return Iterator{ .len = try len() };
|
|
}
|
|
|
|
/// Iterator for the available extensions.
|
|
pub const Iterator = struct {
|
|
/// The total number of extensions.
|
|
len: c.GLuint = 0,
|
|
i: c.GLuint = 0,
|
|
|
|
pub fn next(self: *Iterator) !?[]const u8 {
|
|
if (self.i >= self.len) return null;
|
|
const res = glad.context.GetStringi.?(c.GL_EXTENSIONS, self.i);
|
|
try errors.getError();
|
|
self.i += 1;
|
|
return std.mem.sliceTo(res, 0);
|
|
}
|
|
};
|