fix textures being drawn upside down on macos

This commit is contained in:
Tuomas Katajisto 2025-10-10 23:03:07 +03:00
parent 543b088341
commit e58a4fd20c
4 changed files with 28 additions and 13 deletions

View File

@ -54,3 +54,18 @@ get_render_size :: () -> (s32, s32) {
// wl, hl := get_low_res(w,h, 360); // wl, hl := get_low_res(w,h, 360);
return w, h; return w, h;
} }
flip_y_if_plat :: inline (v: Vector2) -> Vector2 {
return .{v.x, flip_if_plat(v.y)};
}
// Some platforms draw UVs in weird reverse way
// so this function here does the flip on those platforms
// so we don't need to do the platform check in many places.
flip_if_plat :: inline (n: float) -> float {
#if OS == .MACOS {
return 1 - n;
} else {
return n;
}
}

View File

@ -544,10 +544,10 @@ create_postprocess_pipeline :: () {
gPipelines.postprocess.pipeline = sg_make_pipeline(*pipeline); gPipelines.postprocess.pipeline = sg_make_pipeline(*pipeline);
quad_vertices : [16]float = .[ quad_vertices : [16]float = .[
-1.0, 1.0, 0.0, 1.0, // top-let -1.0, 1.0, 0.0, flip_if_plat(1.0), // top-let
-1.0, -1.0, 0.0, 0.0, // bottom-let -1.0, -1.0, 0.0, flip_if_plat(0.0), // bottom-let
1.0, -1.0, 1.0, 0.0, // bottom-right 1.0, -1.0, 1.0, flip_if_plat(0.0), // bottom-right
1.0, 1.0, 1.0, 1.0, // top-right 1.0, 1.0, 1.0, flip_if_plat(1.0), // top-right
]; ];
quad_indices : [6]u16 = .[ quad_indices : [6]u16 = .[
0, 1, 2, 0, 2, 3 0, 1, 2, 0, 2, 3

View File

@ -253,9 +253,9 @@ immediate_triangle :: (p0: Vector3, p1: Vector3, p2: Vector3, c0 := Vector4.{1,1
tri.uv[1] = nullUV; tri.uv[1] = nullUV;
tri.uv[2] = nullUV; tri.uv[2] = nullUV;
} else { } else {
tri.uv[0] = uv0; tri.uv[0] = flip_y_if_plat(uv0);
tri.uv[1] = uv1; tri.uv[1] = flip_y_if_plat(uv1);
tri.uv[2] = uv2; tri.uv[2] = flip_y_if_plat(uv2);
} }
arb_tri_add(tri); arb_tri_add(tri);

View File

@ -8,7 +8,7 @@ current_world : struct {
valid : bool = false; valid : bool = false;
}; };
world_table :: Table(string, World); world_table : Table(string, World);
@ -33,8 +33,8 @@ lworlds :: () {
s := load_string_from_pack("./game/resources/worlds.json"); s := load_string_from_pack("./game/resources/worlds.json");
success, worlds := Jaison.json_parse_string(s, [..]World,, temp); success, worlds := Jaison.json_parse_string(s, [..]World,, temp);
for worlds { for worlds {
set_trile(sprint("%",it.name), trile_from_serialize_form(it)); // set_trile(sprint("%",it.name), trile_from_serialize_form(it));
print("Loaded %\n", it.name); // print("Loaded %\n", it.name);
} }
} @Command } @Command
@ -81,9 +81,9 @@ TrilePositions :: struct {
} }
Ground_Tile :: enum { Ground_Tile :: enum {
WATER = 0; WATER;
GRASS = 1; GRASS;
SAND = 2; SAND;
} }
World :: struct { World :: struct {