opengl: adding pixelStorei

This commit is contained in:
Mitchell Hashimoto
2022-04-04 12:44:28 -07:00
parent c8a73d60a9
commit 8734dac2ad
2 changed files with 9 additions and 10 deletions

View File

@ -42,7 +42,7 @@ pub fn init(alloc: std.mem.Allocator) !TextRenderer {
_ = ftc.FT_Set_Pixel_Sizes(face, 0, 48); _ = ftc.FT_Set_Pixel_Sizes(face, 0, 48);
// disable byte-alignment restriction // disable byte-alignment restriction
gl.c.glPixelStorei(gl.c.GL_UNPACK_ALIGNMENT, 1); try gl.pixelStore(gl.c.GL_UNPACK_ALIGNMENT, 1);
// Pre-render all the ASCII characters // Pre-render all the ASCII characters
var chars = try CharList.initCapacity(alloc, 128); var chars = try CharList.initCapacity(alloc, 128);
@ -160,7 +160,6 @@ pub fn render(
try gl.Texture.active(gl.c.GL_TEXTURE0); try gl.Texture.active(gl.c.GL_TEXTURE0);
try self.vao.bind(); try self.vao.bind();
std.log.info("---", .{});
var curx: f32 = x; var curx: f32 = x;
for (text) |c| { for (text) |c| {
const char = self.chars.items[c]; const char = self.chars.items[c];
@ -170,14 +169,6 @@ pub fn render(
const w = char.size[0] * scale; const w = char.size[0] * scale;
const h = char.size[1] * scale; const h = char.size[1] * scale;
std.log.info("CHARACTER INFO ch={} xpos={} ypos={} w={} h={}", .{
c,
xpos,
ypos,
w,
h,
});
const vert = [6][4]f32{ const vert = [6][4]f32{
.{ xpos, ypos + h, 0.0, 0.0 }, .{ xpos, ypos + h, 0.0, 0.0 },
.{ xpos, ypos, 0.0, 1.0 }, .{ xpos, ypos, 0.0, 1.0 },

View File

@ -17,3 +17,11 @@ pub fn drawArrays(mode: c.GLenum, first: c.GLint, count: c.GLsizei) !void {
pub fn viewport(x: c.GLint, y: c.GLint, width: c.GLsizei, height: c.GLsizei) !void { pub fn viewport(x: c.GLint, y: c.GLint, width: c.GLsizei, height: c.GLsizei) !void {
c.glViewport(x, y, width, height); 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();
}