diff --git a/src/rendering/helpers.jai b/src/rendering/helpers.jai index c50083a..4dae188 100644 --- a/src/rendering/helpers.jai +++ b/src/rendering/helpers.jai @@ -54,3 +54,18 @@ get_render_size :: () -> (s32, s32) { // wl, hl := get_low_res(w,h, 360); 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; + } +} diff --git a/src/rendering/pipelines.jai b/src/rendering/pipelines.jai index 17135a9..fc1e4a2 100644 --- a/src/rendering/pipelines.jai +++ b/src/rendering/pipelines.jai @@ -544,10 +544,10 @@ create_postprocess_pipeline :: () { gPipelines.postprocess.pipeline = sg_make_pipeline(*pipeline); quad_vertices : [16]float = .[ - -1.0, 1.0, 0.0, 1.0, // top-let - -1.0, -1.0, 0.0, 0.0, // bottom-let - 1.0, -1.0, 1.0, 0.0, // bottom-right - 1.0, 1.0, 1.0, 1.0, // top-right + -1.0, 1.0, 0.0, flip_if_plat(1.0), // top-let + -1.0, -1.0, 0.0, flip_if_plat(0.0), // bottom-let + 1.0, -1.0, 1.0, flip_if_plat(0.0), // bottom-right + 1.0, 1.0, 1.0, flip_if_plat(1.0), // top-right ]; quad_indices : [6]u16 = .[ 0, 1, 2, 0, 2, 3 diff --git a/src/ui/ui.jai b/src/ui/ui.jai index a0f0c57..412f9a1 100644 --- a/src/ui/ui.jai +++ b/src/ui/ui.jai @@ -253,9 +253,9 @@ immediate_triangle :: (p0: Vector3, p1: Vector3, p2: Vector3, c0 := Vector4.{1,1 tri.uv[1] = nullUV; tri.uv[2] = nullUV; } else { - tri.uv[0] = uv0; - tri.uv[1] = uv1; - tri.uv[2] = uv2; + tri.uv[0] = flip_y_if_plat(uv0); + tri.uv[1] = flip_y_if_plat(uv1); + tri.uv[2] = flip_y_if_plat(uv2); } arb_tri_add(tri); diff --git a/src/world.jai b/src/world.jai index 71b347e..853e6a2 100644 --- a/src/world.jai +++ b/src/world.jai @@ -8,7 +8,7 @@ current_world : struct { 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"); success, worlds := Jaison.json_parse_string(s, [..]World,, temp); for worlds { - set_trile(sprint("%",it.name), trile_from_serialize_form(it)); - print("Loaded %\n", it.name); + // set_trile(sprint("%",it.name), trile_from_serialize_form(it)); + // print("Loaded %\n", it.name); } } @Command @@ -81,9 +81,9 @@ TrilePositions :: struct { } Ground_Tile :: enum { - WATER = 0; - GRASS = 1; - SAND = 2; + WATER; + GRASS; + SAND; } World :: struct {