mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-07 02:16:34 +00:00
make opengl loader context-aware
This commit is contained in:
@@ -1,26 +1,27 @@
|
||||
const VertexArray = @This();
|
||||
|
||||
const c = @import("c.zig");
|
||||
const glad = @import("glad.zig");
|
||||
|
||||
id: c.GLuint,
|
||||
|
||||
/// Create a single vertex array object.
|
||||
pub inline fn create() !VertexArray {
|
||||
var vao: c.GLuint = undefined;
|
||||
c.glGenVertexArrays(1, &vao);
|
||||
glad.context.GenVertexArrays.?(1, &vao);
|
||||
return VertexArray{ .id = vao };
|
||||
}
|
||||
|
||||
// Unbind any active vertex array.
|
||||
pub inline fn unbind() !void {
|
||||
c.glBindVertexArray(0);
|
||||
glad.context.BindVertexArray.?(0);
|
||||
}
|
||||
|
||||
/// glBindVertexArray
|
||||
pub inline fn bind(v: VertexArray) !void {
|
||||
c.glBindVertexArray(v.id);
|
||||
glad.context.BindVertexArray.?(v.id);
|
||||
}
|
||||
|
||||
pub inline fn destroy(v: VertexArray) void {
|
||||
c.glDeleteVertexArrays(1, &v.id);
|
||||
glad.context.DeleteVertexArrays.?(1, &v.id);
|
||||
}
|
||||
|
Reference in New Issue
Block a user