mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 09:16:11 +03:00
opengl: more bindings
This commit is contained in:
12
src/main.zig
12
src/main.zig
@ -57,16 +57,8 @@ pub fn main() !void {
|
||||
try vao.bind();
|
||||
var binding = try vbo.bind(c.GL_ARRAY_BUFFER);
|
||||
try binding.setData(&vertices, c.GL_STATIC_DRAW);
|
||||
|
||||
c.glVertexAttribPointer(
|
||||
0,
|
||||
3,
|
||||
c.GL_FLOAT,
|
||||
c.GL_FALSE,
|
||||
3 * @sizeOf(f32),
|
||||
null,
|
||||
);
|
||||
c.glEnableVertexAttribArray(0);
|
||||
try binding.vertexAttribPointer(0, 3, c.GL_FLOAT, false, 3 * @sizeOf(f32), null);
|
||||
try binding.enableVertexAttribArray(0);
|
||||
|
||||
binding.unbind();
|
||||
try gl.VertexArray.unbind();
|
||||
|
@ -52,11 +52,26 @@ pub const Binding = struct {
|
||||
try errors.getError();
|
||||
}
|
||||
|
||||
pub inline fn enableVertexAttribArray(_: Binding, idx: c.GLuint) !void {
|
||||
c.glEnableVertexAttribArray(idx);
|
||||
}
|
||||
|
||||
pub inline fn vertexAttribPointer(
|
||||
_: Binding,
|
||||
idx: c.GLuint,
|
||||
size: c.GLint,
|
||||
typ: c.GLenum,
|
||||
normalized: bool,
|
||||
stride: c.GLsizei,
|
||||
ptr: ?*const anyopaque,
|
||||
) !void {
|
||||
const normalized_c: c.GLboolean = if (normalized) c.GL_TRUE else c.GL_FALSE;
|
||||
c.glVertexAttribPointer(idx, size, typ, normalized_c, stride, ptr);
|
||||
try errors.getError();
|
||||
}
|
||||
|
||||
pub inline fn unbind(b: *Binding) void {
|
||||
c.glBindBuffer(b.target, 0);
|
||||
|
||||
// By setting this to undefined, this ensures that any future calls
|
||||
// error in safe build modes.
|
||||
b.* = undefined;
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user