mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 09:16:11 +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);
|
try glfw.swapInterval(1);
|
||||||
|
|
||||||
// Load OpenGL bindings
|
// 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 {}.{}", .{
|
log.info("loaded OpenGL {}.{}", .{
|
||||||
gl.glad.versionMajor(version),
|
gl.glad.versionMajor(version),
|
||||||
gl.glad.versionMinor(version),
|
gl.glad.versionMinor(version),
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
|
const std = @import("std");
|
||||||
const c = @import("c.zig");
|
const c = @import("c.zig");
|
||||||
|
|
||||||
/// Initialize Glad. This is guaranteed to succeed if no errors are returned.
|
/// Initialize Glad. This is guaranteed to succeed if no errors are returned.
|
||||||
/// The getProcAddress param is an anytype so that we can accept multiple
|
/// The getProcAddress param is an anytype so that we can accept multiple
|
||||||
/// forms of the function depending on what we're interfacing with.
|
/// forms of the function depending on what we're interfacing with.
|
||||||
pub fn load(getProcAddress: anytype) !c_int {
|
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)) {
|
const res = switch (@TypeOf(getProcAddress)) {
|
||||||
// glfw
|
// glfw
|
||||||
fn ([*:0]const u8) callconv(.C) ?fn () callconv(.C) void => c.gladLoadGL(@ptrCast(
|
GlfwFn => c.gladLoadGL(@ptrCast(
|
||||||
fn ([*c]const u8) callconv(.C) ?fn () callconv(.C) void,
|
std.meta.FnPtr(fn ([*c]const u8) callconv(.C) ?GlProc),
|
||||||
getProcAddress,
|
getProcAddress,
|
||||||
)),
|
)),
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user