diff --git a/src/Window.zig b/src/Window.zig index 1fecffbff..cee4258f1 100644 --- a/src/Window.zig +++ b/src/Window.zig @@ -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. diff --git a/src/opengl.zig b/src/opengl.zig index 5ea8994e8..79882b012 100644 --- a/src/opengl.zig +++ b/src/opengl.zig @@ -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"); diff --git a/src/opengl/extensions.zig b/src/opengl/extensions.zig new file mode 100644 index 000000000..086c154ec --- /dev/null +++ b/src/opengl/extensions.zig @@ -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); + } +};