less dumb

This commit is contained in:
Mitchell Hashimoto
2022-04-04 11:53:09 -07:00
parent 6f2be8e44b
commit c8a73d60a9
3 changed files with 3 additions and 14 deletions

View File

@ -67,7 +67,7 @@ pub fn run(self: App) !void {
gl.clearColor(0.2, 0.3, 0.3, 1.0); gl.clearColor(0.2, 0.3, 0.3, 1.0);
gl.clear(gl.c.GL_COLOR_BUFFER_BIT); gl.clear(gl.c.GL_COLOR_BUFFER_BIT);
try self.text.render("hello", 25.0, 25.0, 1.0, .{ 0.5, 0.8, 0.2 }); try self.text.render("sh $ /bin/bash -c \"echo hello\"", 25.0, 25.0, 1.0, .{ 0.5, 0.8, 0.2 });
try self.window.swapBuffers(); try self.window.swapBuffers();
try glfw.waitEvents(); try glfw.waitEvents();

View File

@ -53,17 +53,6 @@ pub fn init(alloc: std.mem.Allocator) !TextRenderer {
return error.GlyphLoadFailed; return error.GlyphLoadFailed;
} }
if (face.*.glyph.*.bitmap.buffer == null) {
// Unrenderable characters
chars.appendAssumeCapacity(.{
.tex = undefined,
.size = undefined,
.bearing = undefined,
.advance = undefined,
});
continue;
}
// Generate the texture // Generate the texture
const tex = try gl.Texture.create(); const tex = try gl.Texture.create();
var binding = try tex.bind(gl.c.GL_TEXTURE_2D); var binding = try tex.bind(gl.c.GL_TEXTURE_2D);
@ -177,7 +166,7 @@ pub fn render(
const char = self.chars.items[c]; const char = self.chars.items[c];
const xpos = curx + (char.bearing[0] * scale); const xpos = curx + (char.bearing[0] * scale);
const ypos = y + (char.bearing[1] * scale); const ypos = y - ((char.size[1] - char.bearing[1]) * scale);
const w = char.size[0] * scale; const w = char.size[0] * scale;
const h = char.size[1] * scale; const h = char.size[1] * scale;

View File

@ -38,7 +38,7 @@ pub const Binding = struct {
border: c.GLint, border: c.GLint,
format: c.GLenum, format: c.GLenum,
typ: c.GLenum, typ: c.GLenum,
data: *const anyopaque, data: ?*const anyopaque,
) !void { ) !void {
c.glTexImage2D( c.glTexImage2D(
b.target, b.target,