mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 00:36:07 +03:00
new opengl function calls for stage2
This commit is contained in:
@ -191,7 +191,10 @@ pub fn create(alloc: Allocator, loop: libuv.Loop, config: *const Config) !*Windo
|
||||
try glfw.swapInterval(1);
|
||||
|
||||
// Load OpenGL bindings
|
||||
const version = try gl.glad.load(glfw.getProcAddress);
|
||||
const version = try gl.glad.load(switch (builtin.zig_backend) {
|
||||
.stage1 => glfw.getProcAddress,
|
||||
else => &glfw.getProcAddress,
|
||||
});
|
||||
log.info("loaded OpenGL {}.{}", .{
|
||||
gl.glad.versionMajor(version),
|
||||
gl.glad.versionMinor(version),
|
||||
|
@ -1,13 +1,17 @@
|
||||
const std = @import("std");
|
||||
const c = @import("c.zig");
|
||||
|
||||
/// Initialize Glad. This is guaranteed to succeed if no errors are returned.
|
||||
/// The getProcAddress param is an anytype so that we can accept multiple
|
||||
/// forms of the function depending on what we're interfacing with.
|
||||
pub fn load(getProcAddress: anytype) !c_int {
|
||||
const GlProc = std.meta.FnPtr(fn () callconv(.C) void);
|
||||
const GlfwFn = std.meta.FnPtr(fn ([*:0]const u8) callconv(.C) ?GlProc);
|
||||
|
||||
const res = switch (@TypeOf(getProcAddress)) {
|
||||
// glfw
|
||||
fn ([*:0]const u8) callconv(.C) ?fn () callconv(.C) void => c.gladLoadGL(@ptrCast(
|
||||
fn ([*c]const u8) callconv(.C) ?fn () callconv(.C) void,
|
||||
GlfwFn => c.gladLoadGL(@ptrCast(
|
||||
std.meta.FnPtr(fn ([*c]const u8) callconv(.C) ?GlProc),
|
||||
getProcAddress,
|
||||
)),
|
||||
|
||||
|
Reference in New Issue
Block a user