From 418b3bc31e2cfa668e3e9593e6ff4378e58e6801 Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 20 Dec 2023 14:51:29 +0100 Subject: [PATCH] Flip TileMap's uvs. --- compile_linux.sh | 12 +++++++----- sfw/application/tile_map.cpp | 13 ++++++------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/compile_linux.sh b/compile_linux.sh index b1acb63..30b36a4 100755 --- a/compile_linux.sh +++ b/compile_linux.sh @@ -63,11 +63,13 @@ ccache g++ -Wall -D_REENTRANT -g -Isfw -Isfw/core -Isfw/application -c game_scen ccache g++ -Wall -D_REENTRANT -g -Isfw -Isfw/core -Isfw/application -c main.cpp -o main.o -ccache g++ -Wall -lm -ldl -lpthread -lX11 -D_REENTRANT -g sfw/aabb.o sfw/basis.o sfw/color.o sfw/face3.o sfw/logger.o sfw/math_funcs.o \ - sfw/memory.o sfw/pcg.o sfw/plane.o sfw/projection.o sfw/quaternion.o sfw/random_pcg.o \ - sfw/rect2.o sfw/rect2i.o sfw/safe_refcount.o sfw/transform_2d.o sfw/transform.o \ - sfw/ustring.o sfw/vector2.o sfw/vector2i.o sfw/vector3.o sfw/vector3i.o sfw/vector4.o sfw/vector4i.o \ - sfw/pool_vector.o sfw/pool_allocator.o sfw/mutex.o sfw/stime.o \ +ccache g++ -Wall -lm -ldl -lpthread -lX11 -D_REENTRANT -g sfw/core/aabb.o sfw/core/basis.o sfw/core/color.o \ + sfw/core/face3.o sfw/core/logger.o sfw/core/math_funcs.o \ + sfw/core/memory.o sfw/core/pcg.o sfw/core/plane.o sfw/core/projection.o sfw/core/quaternion.o sfw/core/random_pcg.o \ + sfw/core/rect2.o sfw/core/rect2i.o sfw/core/safe_refcount.o sfw/core/transform_2d.o sfw/core/transform.o \ + sfw/core/ustring.o sfw/core/vector2.o sfw/core/vector2i.o sfw/core/vector3.o \ + sfw/core/vector3i.o sfw/core/vector4.o sfw/core/vector4i.o \ + sfw/core/pool_vector.o sfw/core/pool_allocator.o sfw/core/mutex.o sfw/core/stime.o \ sfw/application/application.o sfw/application/scene.o sfw/application/window.o \ sfw/application/shader.o sfw/application/material.o sfw/application/mesh.o \ sfw/application/camera_3d.o sfw/application/object_3d.o sfw/application/mesh_instance_3d.o \ diff --git a/sfw/application/tile_map.cpp b/sfw/application/tile_map.cpp index 9ae2d40..f05864d 100644 --- a/sfw/application/tile_map.cpp +++ b/sfw/application/tile_map.cpp @@ -71,17 +71,17 @@ void TileMap::allocate_data() { void TileMap::add_rect(const int x, const int y, const float uv_x, const float uv_y, const float uv_size_x, const float uv_size_y) { int vc = static_cast(mesh->vertices.size() / mesh->vertex_dimesions); - mesh->add_uv(uv_x, uv_y); mesh->add_vertex2(x, y + 1); - - mesh->add_uv(uv_x + uv_size_x, uv_y + uv_size_y); - mesh->add_vertex2(x + 1, y); - mesh->add_uv(uv_x, uv_y + uv_size_y); - mesh->add_vertex2(x, y); + mesh->add_vertex2(x + 1, y); mesh->add_uv(uv_x + uv_size_x, uv_y); + + mesh->add_vertex2(x, y); + mesh->add_uv(uv_x, uv_y); + mesh->add_vertex2(x + 1, y + 1); + mesh->add_uv(uv_x + uv_size_x, uv_y + uv_size_y); mesh->add_triangle(vc + 1, vc + 0, vc + 2); mesh->add_triangle(vc + 0, vc + 1, vc + 3); @@ -116,7 +116,6 @@ void TileMap::render() { TileMap::TileMap() : Object2D() { - data = nullptr; size_x = 16; size_y = 16;