diff --git a/CMakeLists.txt b/CMakeLists.txt index 0aadf9a..f6f7b77 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,8 +14,8 @@ endif() add_subdirectory(third_party/tracy) add_subdirectory(lib lib) -add_subdirectory(mym mym) -add_subdirectory(mygl mygl) +add_subdirectory(linalg linalg) +add_subdirectory(gl_render gl_render) # imgui set(IMGUI_PATH "${CMAKE_SOURCE_DIR}/third_party/imgui") @@ -34,8 +34,8 @@ target_link_libraries(ImGui PRIVATE SDL3::SDL3) add_executable(native index.cpp events.cpp) target_link_libraries(native PRIVATE - mym - mygl + linalg + gl_render lib SDL3::SDL3 ${OPENGL_LIBRARIES} @@ -70,7 +70,7 @@ add_executable(tests ) target_link_libraries(tests PRIVATE - mym + linalg lib ) diff --git a/events.cpp b/events.cpp index 3701748..dc67c55 100644 --- a/events.cpp +++ b/events.cpp @@ -11,7 +11,7 @@ #include "backends/imgui_impl_sdl3.h" -using namespace mym; +using namespace linalg; void processEvents(WindowState& window, Camera& camera, InputState& input, Scene& scene, Arena& frame_arena) { diff --git a/mygl/CMakeLists.txt b/gl_render/CMakeLists.txt similarity index 65% rename from mygl/CMakeLists.txt rename to gl_render/CMakeLists.txt index 8d43a3c..33eaafb 100644 --- a/mygl/CMakeLists.txt +++ b/gl_render/CMakeLists.txt @@ -1,19 +1,19 @@ include_guard(GLOBAL) cmake_minimum_required(VERSION 3.24) -project(MyGl) +project(GlRenderer) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) find_package(OpenGL REQUIRED) add_subdirectory(../lib lib) -add_library(mygl SHARED +add_library(gl_render SHARED basic_color_render_program.cpp gl_renderer.cpp render_program.cpp texture_render_program.cpp ) -target_include_directories(mygl PUBLIC include) -target_link_libraries(mygl PUBLIC lib) +target_include_directories(gl_render PUBLIC include) +target_link_libraries(gl_render PUBLIC lib) diff --git a/mygl/basic_color_render_program.cpp b/gl_render/basic_color_render_program.cpp similarity index 100% rename from mygl/basic_color_render_program.cpp rename to gl_render/basic_color_render_program.cpp diff --git a/mygl/gl_renderer.cpp b/gl_render/gl_renderer.cpp similarity index 99% rename from mygl/gl_renderer.cpp rename to gl_render/gl_renderer.cpp index 8681ee4..07138fe 100644 --- a/mygl/gl_renderer.cpp +++ b/gl_render/gl_renderer.cpp @@ -1,6 +1,6 @@ #include "gl_renderer.h" -using namespace mym; +using namespace linalg; WindowState initWindow(const char* title) { diff --git a/mygl/include/gl_renderer.h b/gl_render/include/gl_renderer.h similarity index 100% rename from mygl/include/gl_renderer.h rename to gl_render/include/gl_renderer.h diff --git a/mygl/include/render_program.h b/gl_render/include/render_program.h similarity index 100% rename from mygl/include/render_program.h rename to gl_render/include/render_program.h diff --git a/mygl/include/sdl_state.h b/gl_render/include/sdl_state.h similarity index 100% rename from mygl/include/sdl_state.h rename to gl_render/include/sdl_state.h diff --git a/mygl/render_program.cpp b/gl_render/render_program.cpp similarity index 100% rename from mygl/render_program.cpp rename to gl_render/render_program.cpp diff --git a/mygl/texture_render_program.cpp b/gl_render/texture_render_program.cpp similarity index 100% rename from mygl/texture_render_program.cpp rename to gl_render/texture_render_program.cpp diff --git a/include/events.h b/include/events.h index b73075f..f5f8462 100644 --- a/include/events.h +++ b/include/events.h @@ -12,7 +12,7 @@ struct Entity { typedef struct InputState { bool pointer_down; - mym::Vec2 pointer_position; + linalg::Vec2 pointer_position; std::optional selected_entity; } InputState; diff --git a/index.cpp b/index.cpp index cfdd3a6..556672d 100644 --- a/index.cpp +++ b/index.cpp @@ -15,7 +15,7 @@ #include #include -using namespace mym; +using namespace linalg; #define UPDATE_INTERVAL 10 float dt = 1.0f/UPDATE_INTERVAL; diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 29ecfdb..c1f761a 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -18,7 +18,7 @@ set(ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT OFF) set(ASSIMP_BUILD_GLTF_IMPORTER ON) add_subdirectory(../third_party/assimp assimp) -add_subdirectory(../mym mym) +add_subdirectory(../linalg linalg) # lib (include is for templates) add_library(lib SHARED @@ -33,7 +33,7 @@ add_library(lib SHARED target_include_directories(lib PUBLIC include) target_link_libraries(lib - mym + linalg SDL3::SDL3 assimp::assimp ${OPENGL_LIBRARIES}) diff --git a/lib/camera.cpp b/lib/camera.cpp index b64cd8c..9415a1d 100644 --- a/lib/camera.cpp +++ b/lib/camera.cpp @@ -1,6 +1,6 @@ #include "camera.h" -using namespace mym; +using namespace linalg; Mat4 getProjectionMatrix(Camera camera) { return perspective(camera.field_of_view_radians, camera.aspect, camera.near, camera.far); diff --git a/lib/include/camera.h b/lib/include/camera.h index 5f31ba3..4cf4277 100644 --- a/lib/include/camera.h +++ b/lib/include/camera.h @@ -4,7 +4,7 @@ #include "vec.h" #include "mat4.h" -using namespace mym; +using namespace linalg; typedef struct Orbit { float azimuth; diff --git a/lib/include/light.h b/lib/include/light.h index 931cf0f..8befabd 100644 --- a/lib/include/light.h +++ b/lib/include/light.h @@ -3,7 +3,7 @@ #include "vec.h" -using namespace mym; +using namespace linalg; typedef struct PointLight { Vec3 color; diff --git a/lib/include/material.h b/lib/include/material.h index 70cae5e..18eb789 100644 --- a/lib/include/material.h +++ b/lib/include/material.h @@ -25,8 +25,8 @@ struct TextureData { }; struct BasicColorMaterial { - mym::Vec3 color; - mym::Vec3 specular_color; + linalg::Vec3 color; + linalg::Vec3 specular_color; float shininess; }; diff --git a/mym/CMakeLists.txt b/linalg/CMakeLists.txt similarity index 61% rename from mym/CMakeLists.txt rename to linalg/CMakeLists.txt index be621b4..2f5a4ed 100644 --- a/mym/CMakeLists.txt +++ b/linalg/CMakeLists.txt @@ -1,16 +1,16 @@ include_guard(GLOBAL) cmake_minimum_required(VERSION 3.24) -project(MyMaths) +project(Linalg) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -add_library(mym SHARED +add_library(linalg SHARED vec.cpp mat4.cpp math_utils.cpp ) -target_include_directories(mym PUBLIC include) +target_include_directories(linalg PUBLIC include) diff --git a/mym/include/mat4.h b/linalg/include/mat4.h similarity index 97% rename from mym/include/mat4.h rename to linalg/include/mat4.h index f846547..16e2a3d 100644 --- a/mym/include/mat4.h +++ b/linalg/include/mat4.h @@ -1,10 +1,9 @@ #ifndef MAT_4_H #define MAT_4_H -#include "math_utils.h" #include "vec.h" -namespace mym { +namespace linalg { typedef union Mat4 { struct { diff --git a/mym/include/math_utils.h b/linalg/include/math_utils.h similarity index 100% rename from mym/include/math_utils.h rename to linalg/include/math_utils.h diff --git a/mym/include/vec.h b/linalg/include/vec.h similarity index 97% rename from mym/include/vec.h rename to linalg/include/vec.h index 7bb3f87..b53e323 100644 --- a/mym/include/vec.h +++ b/linalg/include/vec.h @@ -3,7 +3,7 @@ #include #include -namespace mym { +namespace linalg { typedef union Vec2 { struct { diff --git a/mym/mat4.cpp b/linalg/mat4.cpp similarity index 99% rename from mym/mat4.cpp rename to linalg/mat4.cpp index 342a505..c803296 100644 --- a/mym/mat4.cpp +++ b/linalg/mat4.cpp @@ -1,7 +1,8 @@ #include "vec.h" #include "mat4.h" +#include "math_utils.h" -namespace mym { +namespace linalg { Mat4 lookAt(const Vec3 camera_position, const Vec3 target, const Vec3 up) { const Vec3 z_axis = normalize( diff --git a/mym/math_utils.cpp b/linalg/math_utils.cpp similarity index 100% rename from mym/math_utils.cpp rename to linalg/math_utils.cpp diff --git a/mym/vec.cpp b/linalg/vec.cpp similarity index 98% rename from mym/vec.cpp rename to linalg/vec.cpp index e9dbdef..66f3e27 100644 --- a/mym/vec.cpp +++ b/linalg/vec.cpp @@ -3,7 +3,7 @@ #include "math_utils.h" #include -namespace mym { +namespace linalg { Vec3 scaleVector(const Vec3 vec, const float scalar) { return (Vec3){ diff --git a/tests/include/test_helpers.h b/tests/include/test_helpers.h index 7cea497..0996066 100644 --- a/tests/include/test_helpers.h +++ b/tests/include/test_helpers.h @@ -10,7 +10,7 @@ struct TestResult { }; bool floatsAreClose(float a, float b); -bool vec3sAreEqual(mym::Vec3 a, mym::Vec3 b); +bool vec3sAreEqual(linalg::Vec3 a, linalg::Vec3 b); std::vector runTriangleTests(); std::vector runVerticesTests(); diff --git a/tests/raycast_scene_tests.cpp b/tests/raycast_scene_tests.cpp index e0b9b07..4979bbd 100644 --- a/tests/raycast_scene_tests.cpp +++ b/tests/raycast_scene_tests.cpp @@ -4,8 +4,9 @@ #include "scene.h" #include "test_helpers.h" #include "raycast.h" +#include "math_utils.h" -using namespace mym; +using namespace linalg; Vertices setupVertices() { diff --git a/tests/test_helpers.cpp b/tests/test_helpers.cpp index 364327b..62a274d 100644 --- a/tests/test_helpers.cpp +++ b/tests/test_helpers.cpp @@ -5,7 +5,7 @@ bool floatsAreClose(float a, float b) { return fabs(a - b) < 0.00001f; } -bool vec3sAreEqual(mym::Vec3 a, mym::Vec3 b) { +bool vec3sAreEqual(linalg::Vec3 a, linalg::Vec3 b) { return (floatsAreClose(a.x, b.x) && floatsAreClose(a.y, b.y) && floatsAreClose(a.z, b.z));