aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/pkg/opengl/VertexArray.zig
diff options
context:
space:
mode:
authorCan Celik <ogulcancelik@gmail.com>2026-04-04 19:22:04 +0300
committerCan Celik <ogulcancelik@gmail.com>2026-04-05 01:23:06 +0300
commit41dd733ca7123c9ac4bfc6c781697a660e95b052 (patch)
tree3fc91815ca139ef2e0b281bba0abda4ef15175f4 /vendor/libghostty-vt/pkg/opengl/VertexArray.zig
parent55c138263e190a1e79d4b997bfb9397306c0ec1f (diff)
feat: finish ghostty pane backend integration
Diffstat (limited to 'vendor/libghostty-vt/pkg/opengl/VertexArray.zig')
-rw-r--r--vendor/libghostty-vt/pkg/opengl/VertexArray.zig116
1 files changed, 116 insertions, 0 deletions
diff --git a/vendor/libghostty-vt/pkg/opengl/VertexArray.zig b/vendor/libghostty-vt/pkg/opengl/VertexArray.zig
new file mode 100644
index 00000000..44bf3162
--- /dev/null
+++ b/vendor/libghostty-vt/pkg/opengl/VertexArray.zig
@@ -0,0 +1,116 @@
+const VertexArray = @This();
+
+const c = @import("c.zig").c;
+const glad = @import("glad.zig");
+const errors = @import("errors.zig");
+
+id: c.GLuint,
+
+/// Create a single vertex array object.
+pub fn create() !VertexArray {
+ var vao: c.GLuint = undefined;
+ glad.context.GenVertexArrays.?(1, &vao);
+ return VertexArray{ .id = vao };
+}
+
+/// glBindVertexArray
+pub fn bind(v: VertexArray) !Binding {
+ glad.context.BindVertexArray.?(v.id);
+ try errors.getError();
+ return .{};
+}
+
+pub fn destroy(v: VertexArray) void {
+ glad.context.DeleteVertexArrays.?(1, &v.id);
+}
+
+pub const Binding = struct {
+ pub fn unbind(self: Binding) void {
+ _ = self;
+ glad.context.BindVertexArray.?(0);
+ }
+
+ pub fn enableAttribArray(_: Binding, idx: c.GLuint) !void {
+ glad.context.EnableVertexAttribArray.?(idx);
+ try errors.getError();
+ }
+
+ pub fn bindingDivisor(_: Binding, idx: c.GLuint, divisor: c.GLuint) !void {
+ glad.context.VertexBindingDivisor.?(idx, divisor);
+ try errors.getError();
+ }
+
+ pub fn attributeBinding(
+ _: Binding,
+ attrib_idx: c.GLuint,
+ binding_idx: c.GLuint,
+ ) !void {
+ glad.context.VertexAttribBinding.?(attrib_idx, binding_idx);
+ try errors.getError();
+ }
+
+ pub fn attributeFormat(
+ _: Binding,
+ idx: c.GLuint,
+ size: c.GLint,
+ typ: c.GLenum,
+ normalized: bool,
+ offset: c.GLuint,
+ ) !void {
+ glad.context.VertexAttribFormat.?(
+ idx,
+ size,
+ typ,
+ @intCast(@intFromBool(normalized)),
+ offset,
+ );
+ try errors.getError();
+ }
+
+ pub fn attributeIFormat(
+ _: Binding,
+ idx: c.GLuint,
+ size: c.GLint,
+ typ: c.GLenum,
+ offset: c.GLuint,
+ ) !void {
+ glad.context.VertexAttribIFormat.?(
+ idx,
+ size,
+ typ,
+ offset,
+ );
+ try errors.getError();
+ }
+
+ pub fn attributeLFormat(
+ _: Binding,
+ idx: c.GLuint,
+ size: c.GLint,
+ offset: c.GLuint,
+ ) !void {
+ glad.context.VertexAttribLFormat.?(
+ idx,
+ size,
+ c.GL_DOUBLE,
+ offset,
+ );
+ try errors.getError();
+ }
+
+ pub fn bindVertexBuffer(
+ _: Binding,
+ idx: c.GLuint,
+ buffer: c.GLuint,
+ offset: c.GLintptr,
+ stride: c.GLsizei,
+ ) !void {
+ glad.context.BindVertexBuffer.?(
+ idx,
+ buffer,
+ offset,
+ stride,
+ );
+ try errors.getError();
+ }
+};