mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
opengl: support extension iteration, list in debug mode
This commit is contained in:
@ -124,6 +124,7 @@ const Cursor = struct {
|
||||
);
|
||||
}
|
||||
|
||||
/// Stop the timer. This is idempotent.
|
||||
pub fn stopTimer(self: Cursor) !void {
|
||||
try self.timer.stop();
|
||||
}
|
||||
@ -166,6 +167,12 @@ pub fn create(alloc: Allocator, loop: libuv.Loop, config: *const Config) !*Windo
|
||||
gl.glad.versionMajor(version),
|
||||
gl.glad.versionMinor(version),
|
||||
});
|
||||
if (builtin.mode == .Debug) {
|
||||
var ext_iter = try gl.ext.iterator();
|
||||
while (try ext_iter.next()) |ext| {
|
||||
log.debug("OpenGL extension available name={s}", .{ext});
|
||||
}
|
||||
}
|
||||
|
||||
// Culling, probably not necessary. We have to change the winding
|
||||
// order since our 0,0 is top-left.
|
||||
|
@ -15,6 +15,7 @@ pub const c = @import("opengl/c.zig");
|
||||
pub const glad = @import("opengl/glad.zig");
|
||||
pub usingnamespace @import("opengl/draw.zig");
|
||||
|
||||
pub const ext = @import("opengl/extensions.zig");
|
||||
pub const Buffer = @import("opengl/Buffer.zig");
|
||||
pub const Program = @import("opengl/Program.zig");
|
||||
pub const Shader = @import("opengl/Shader.zig");
|
||||
|
31
src/opengl/extensions.zig
Normal file
31
src/opengl/extensions.zig
Normal file
@ -0,0 +1,31 @@
|
||||
const std = @import("std");
|
||||
const c = @import("c.zig");
|
||||
const errors = @import("errors.zig");
|
||||
|
||||
/// Returns the number of extensions.
|
||||
pub fn len() !u32 {
|
||||
var n: c.GLint = undefined;
|
||||
c.glGetIntegerv(c.GL_NUM_EXTENSIONS, &n);
|
||||
try errors.getError();
|
||||
return @intCast(u32, 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 = c.glGetStringi(c.GL_EXTENSIONS, self.i);
|
||||
try errors.getError();
|
||||
self.i += 1;
|
||||
return std.mem.sliceTo(res, 0);
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user