ghostty/src/opengl/draw.zig
Mitchell Hashimoto 544286509f grid render a few cells
2022-04-14 17:14:49 -07:00

44 lines
1.2 KiB
Zig

const c = @import("c.zig");
const errors = @import("errors.zig");
pub fn clearColor(r: f32, g: f32, b: f32, a: f32) void {
c.glClearColor(r, g, b, a);
}
pub fn clear(mask: c.GLbitfield) void {
c.glClear(mask);
}
pub fn drawArrays(mode: c.GLenum, first: c.GLint, count: c.GLsizei) !void {
c.glDrawArrays(mode, first, count);
try errors.getError();
}
pub fn drawElements(mode: c.GLenum, count: c.GLsizei, typ: c.GLenum, offset: usize) !void {
const offsetPtr = if (offset == 0) null else @intToPtr(*const anyopaque, offset);
c.glDrawElements(mode, count, typ, offsetPtr);
try errors.getError();
}
pub fn drawElementsInstanced(
mode: c.GLenum,
count: c.GLsizei,
typ: c.GLenum,
primcount: usize,
) !void {
c.glDrawElementsInstanced(mode, count, typ, null, @intCast(c.GLsizei, primcount));
try errors.getError();
}
pub fn viewport(x: c.GLint, y: c.GLint, width: c.GLsizei, height: c.GLsizei) !void {
c.glViewport(x, y, width, height);
}
pub fn pixelStore(mode: c.GLenum, value: anytype) !void {
switch (@typeInfo(@TypeOf(value))) {
.ComptimeInt, .Int => c.glPixelStorei(mode, value),
else => unreachable,
}
try errors.getError();
}