various fixes for macos

This commit is contained in:
Mitchell Hashimoto
2022-04-24 10:14:25 -07:00
parent 747ebfb628
commit 724b2aedfa
3 changed files with 9 additions and 7 deletions

View File

@ -14,7 +14,7 @@ flat in vec2 screen_cell_pos;
layout(origin_upper_left) in vec4 gl_FragCoord; layout(origin_upper_left) in vec4 gl_FragCoord;
// Must declare this output for some versions of OpenGL. // Must declare this output for some versions of OpenGL.
layout(location = 0) out vec4 FragColor; layout(location = 0) out vec4 out_FragColor;
// Font texture // Font texture
uniform sampler2D text; uniform sampler2D text;
@ -31,16 +31,16 @@ const uint MODE_CURSOR_RECT_HOLLOW = 4u;
void main() { void main() {
switch (mode) { switch (mode) {
case MODE_BG: case MODE_BG:
FragColor = color; out_FragColor = color;
break; break;
case MODE_FG: case MODE_FG:
float a = texture(text, glyph_tex_coords).r; float a = texture(text, glyph_tex_coords).r;
FragColor = vec4(color.rgb, color.a*a); out_FragColor = vec4(color.rgb, color.a*a);
break; break;
case MODE_CURSOR_RECT: case MODE_CURSOR_RECT:
FragColor = color; out_FragColor = color;
break; break;
case MODE_CURSOR_RECT_HOLLOW: case MODE_CURSOR_RECT_HOLLOW:
@ -49,7 +49,7 @@ void main() {
// rectangle so we take the slowdown for that one. // rectangle so we take the slowdown for that one.
// Default to no color. // Default to no color.
FragColor = vec4(0., 0., 0., 0.); out_FragColor = vec4(0., 0., 0., 0.);
// We subtracted one from cell size because our coordinates start at 0. // We subtracted one from cell size because our coordinates start at 0.
// So a width of 50 means max pixel of 49. // So a width of 50 means max pixel of 49.
@ -73,7 +73,7 @@ void main() {
abs(cell_frag_coord.x - cell_size_coords.x) < eps || abs(cell_frag_coord.x - cell_size_coords.x) < eps ||
abs(cell_frag_coord.y) < eps || abs(cell_frag_coord.y) < eps ||
abs(cell_frag_coord.y - cell_size_coords.y) < eps) { abs(cell_frag_coord.y - cell_size_coords.y) < eps) {
FragColor = color; out_FragColor = color;
} }
} }

View File

@ -6,6 +6,7 @@
const Window = @This(); const Window = @This();
const std = @import("std"); const std = @import("std");
const builtin = @import("builtin");
const assert = std.debug.assert; const assert = std.debug.assert;
const Allocator = std.mem.Allocator; const Allocator = std.mem.Allocator;
const Grid = @import("Grid.zig"); const Grid = @import("Grid.zig");
@ -55,6 +56,7 @@ pub fn create(alloc: Allocator, loop: libuv.Loop) !*Window {
.context_version_minor = 3, .context_version_minor = 3,
.opengl_profile = .opengl_core_profile, .opengl_profile = .opengl_core_profile,
.opengl_forward_compat = true, .opengl_forward_compat = true,
.cocoa_graphics_switching = builtin.os.tag == .macos,
}); });
errdefer window.destroy(); errdefer window.destroy();

View File

@ -105,7 +105,7 @@ fn threadMain(self: *Embed) void {
.macos, .dragonfly, .freebsd, .openbsd, .netbsd => { .macos, .dragonfly, .freebsd, .openbsd, .netbsd => {
var ts: std.os.timespec = .{ var ts: std.os.timespec = .{
.tv_sec = @divTrunc(timeout, 1000), .tv_sec = @divTrunc(timeout, 1000),
.tv_nsec = @mod(timeout, 1000) * 1000, .tv_nsec = @mod(timeout, 1000) * 1000000,
}; };
var ev: [0]std.os.Kevent = undefined; var ev: [0]std.os.Kevent = undefined;