mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-20 06:20:32 +00:00
renderer/opengl: move opengl API to pkg/opengl
This commit is contained in:
29
pkg/opengl/VertexArray.zig
Normal file
29
pkg/opengl/VertexArray.zig
Normal file
@@ -0,0 +1,29 @@
|
||||
const VertexArray = @This();
|
||||
|
||||
const c = @import("c.zig");
|
||||
const glad = @import("glad.zig");
|
||||
const errors = @import("errors.zig");
|
||||
|
||||
id: c.GLuint,
|
||||
|
||||
/// Create a single vertex array object.
|
||||
pub inline fn create() !VertexArray {
|
||||
var vao: c.GLuint = undefined;
|
||||
glad.context.GenVertexArrays.?(1, &vao);
|
||||
return VertexArray{ .id = vao };
|
||||
}
|
||||
|
||||
// Unbind any active vertex array.
|
||||
pub inline fn unbind() !void {
|
||||
glad.context.BindVertexArray.?(0);
|
||||
}
|
||||
|
||||
/// glBindVertexArray
|
||||
pub inline fn bind(v: VertexArray) !void {
|
||||
glad.context.BindVertexArray.?(v.id);
|
||||
try errors.getError();
|
||||
}
|
||||
|
||||
pub inline fn destroy(v: VertexArray) void {
|
||||
glad.context.DeleteVertexArrays.?(1, &v.id);
|
||||
}
|
||||
Reference in New Issue
Block a user