mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 17:26:09 +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();
|
try vao.bind();
|
||||||
var binding = try vbo.bind(c.GL_ARRAY_BUFFER);
|
var binding = try vbo.bind(c.GL_ARRAY_BUFFER);
|
||||||
try binding.setData(&vertices, c.GL_STATIC_DRAW);
|
try binding.setData(&vertices, c.GL_STATIC_DRAW);
|
||||||
|
try binding.vertexAttribPointer(0, 3, c.GL_FLOAT, false, 3 * @sizeOf(f32), null);
|
||||||
c.glVertexAttribPointer(
|
try binding.enableVertexAttribArray(0);
|
||||||
0,
|
|
||||||
3,
|
|
||||||
c.GL_FLOAT,
|
|
||||||
c.GL_FALSE,
|
|
||||||
3 * @sizeOf(f32),
|
|
||||||
null,
|
|
||||||
);
|
|
||||||
c.glEnableVertexAttribArray(0);
|
|
||||||
|
|
||||||
binding.unbind();
|
binding.unbind();
|
||||||
try gl.VertexArray.unbind();
|
try gl.VertexArray.unbind();
|
||||||
|
@ -52,11 +52,26 @@ pub const Binding = struct {
|
|||||||
try errors.getError();
|
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 {
|
pub inline fn unbind(b: *Binding) void {
|
||||||
c.glBindBuffer(b.target, 0);
|
c.glBindBuffer(b.target, 0);
|
||||||
|
|
||||||
// By setting this to undefined, this ensures that any future calls
|
|
||||||
// error in safe build modes.
|
|
||||||
b.* = undefined;
|
b.* = undefined;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user