diff --git a/.gitignore b/.gitignore index 3499fc3..a42757e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -build +build* .vscode /.vs .cache diff --git a/docs/COMPILATION.md b/docs/COMPILATION.md new file mode 100644 index 0000000..3634afb --- /dev/null +++ b/docs/COMPILATION.md @@ -0,0 +1,31 @@ +# Cross Compiling with MinGW 64 + + +As I do not own any Windows machine, builds on Windows rely on [MinGW](https://www.mingw-w64.org) which is install with the ArchLinux package group `mingw-64-toolchain` (contains [MinGW64 Crosscompilation parts](https://archlinux.org/packages/?q=mingw-w64)) + +## Install MinGW + +```bash +pacman -S mingw-w64-toolchain +``` + +## Create Build + +The root folder adds a `.gitignore` rule to leave out everything `build*` + +```bash +mkdir -p build_w64 +cd build_w64 +``` + +## Configure + +```bash +cmake . -DCMAKE_TOOLCHAIN_FILE=../etc/cmake/mingw64-toolchain.cmake +``` + +## Build + +```bash +cmake --build . +``` diff --git a/etc/cmake/mingw64-toolchain.cmake b/etc/cmake/mingw64-toolchain.cmake new file mode 100644 index 0000000..86ac70b --- /dev/null +++ b/etc/cmake/mingw64-toolchain.cmake @@ -0,0 +1,17 @@ +# toolchain-mingw64.cmake +set(CMAKE_SYSTEM_NAME Windows) +set(CMAKE_SYSTEM_PROCESSOR x86_64) + +# specify the cross compiler +set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) +set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) +set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) + +# where is the target environment +set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32) + +# search for programs in the build host directories +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +# for libraries and headers in the target directories +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/examples/pong/pong.cpp b/examples/pong/pong.cpp index 2b979f7..031c62e 100644 --- a/examples/pong/pong.cpp +++ b/examples/pong/pong.cpp @@ -1,7 +1,7 @@ /** * paradiso - Paradigmen der Softwareentwicklung * - * (c) Copyright 2023-2024 Hartmut Seichter + * (c) Copyright 2023-2025 Hartmut Seichter and Contributors * */ @@ -45,13 +45,10 @@ struct PongStage { // sprite paradiso::Sprite sprite{ - .bitmap = paradiso::Bitmap::from_data(paradiso::Size{1, 1}, - paradiso::RGBA::from_rgb(0x80,0xFF,0xFF)) - }; + .bitmap = paradiso::Bitmap::from_data( + paradiso::Size{1, 1}, paradiso::RGBA::from_rgb(0x80, 0xFF, 0xFF))}; - void draw(const paradiso::Shader& shader) { - renderer.draw(sprite, shader); - } + void draw(const paradiso::Shader& shader) { renderer.draw(sprite, shader); } paradiso::Renderer renderer{}; }; @@ -166,8 +163,9 @@ struct PongBall { constexpr void push(const auto& impulse) noexcept { velocity += impulse; } - constexpr void whoop(const auto& whoopiness) noexcept { velocity *= whoopiness; } - + constexpr void whoop(const auto& whoopiness) noexcept { + velocity *= whoopiness; + } }; auto main() -> int { @@ -233,19 +231,19 @@ auto main() -> int { if (!w.keyboard_input().empty()) { if (w.keyboard_input().top().key == 'R') { - ball.sprite.pivot.x() = 0.0f; - ball.sprite.pivot.y() = 0.9f; + ball.sprite.pivot.x() = 0.0f; + ball.sprite.pivot.y() = 0.9f; } // speed adjust if (w.keyboard_input().top().key == 'N') { std::cout << "Speed Up!\n"; - ball.push(paradiso::Vector2::make(0.f,0.01f)); + ball.push(paradiso::Vector2::make(0.f, 0.01f)); } else if (w.keyboard_input().top().key == 'M') { - ball.push(paradiso::Vector2::make(0.f,-0.01f)); + ball.push(paradiso::Vector2::make(0.f, -0.01f)); std::cout << "Speed Lower!\n"; } diff --git a/examples/quickwings/CMakeLists.txt b/examples/quickwings/CMakeLists.txt index 0b5ffe2..5ac3667 100644 --- a/examples/quickwings/CMakeLists.txt +++ b/examples/quickwings/CMakeLists.txt @@ -14,7 +14,10 @@ add_executable(quickwings ${quickwings_srcs} ${quickwings_assets}) target_link_libraries(quickwings paradiso_core) +# +# copy files to bin/../assets folder +# add_custom_command(TARGET quickwings POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory - ${CMAKE_CURRENT_SOURCE_DIR}/assets/ $/assets) - \ No newline at end of file + ${CMAKE_CURRENT_SOURCE_DIR}/assets/ + $/assets) diff --git a/examples/quickwings/quickwings.cpp b/examples/quickwings/quickwings.cpp index 9df112b..2259737 100644 --- a/examples/quickwings/quickwings.cpp +++ b/examples/quickwings/quickwings.cpp @@ -1,7 +1,8 @@ /** * paradiso - Paradigmen der Softwareentwicklung * - * (c) Copyright 2023-2024 Hartmut Seichter, Robin Rottstädt, brxxh (Hannes Brothuhn) + * (c) Copyright 2023-2025 Hartmut Seichter and Contributors, Robin Rottstädt, + * brxxh (Hannes Brothuhn) * */ @@ -77,8 +78,8 @@ struct Background { }; struct Pipe { - paradiso::Sprite pipe_top; - paradiso::Sprite pipe_bottom; + paradiso::Sprite pipe_top{}; + paradiso::Sprite pipe_bottom{}; paradiso::Renderer renderer1{}; paradiso::Renderer renderer2{}; @@ -95,16 +96,21 @@ struct Pipe { pipe_top = paradiso::Sprite{ .bitmap = pipe_image, - .pivot = {paradiso::Vector2::make(1.4f, pipe_spawn_rand + 1.0f)}, - .scale = {paradiso::Vector2::make(((500.0f - (500.0f - 52.0f)) / 500.0f) * 2.25f, ((700.0f - (700.0f - 320.0f)) / 700.0f) * 2.25f)}, + .pivot = {paradiso::Vector2::make(1.4f, + pipe_spawn_rand + 1.0f)}, + .scale = {paradiso::Vector2::make( + ((500.0f - (500.0f - 52.0f)) / 500.0f) * 2.25f, + ((700.0f - (700.0f - 320.0f)) / 700.0f) * 2.25f)}, .rotation = 3.1415926f}; pipe_bottom = paradiso::Sprite{ .bitmap = pipe_image, - .pivot = {paradiso::Vector2::make(1.4f, pipe_spawn_rand - 1.5f)}, - .scale = {paradiso::Vector2::make(((500.0f - (500.0f - 52.0f)) / 500.0f) * 2.25f, ((700.0f - (700.0f - 320.0f)) / 700.0f) * 2.25f)}}; + .pivot = {paradiso::Vector2::make(1.4f, + pipe_spawn_rand - 1.5f)}, + .scale = {paradiso::Vector2::make( + ((500.0f - (500.0f - 52.0f)) / 500.0f) * 2.25f, + ((700.0f - (700.0f - 320.0f)) / 700.0f) * 2.25f)}}; paused = true; - } void update() { @@ -115,8 +121,7 @@ struct Pipe { if (paused == true) { return; - } - else { + } else { pipe_spawn_rand_int = rand() % 80 + 15; pipe_spawn_rand = float(pipe_spawn_rand_int) / 100; @@ -124,7 +129,8 @@ struct Pipe { pipe_bottom.pivot.x() -= 0.02f; risky_pos_x = pipe_top.pivot.x(); - risky_pos_max_x = pipe_top.pivot.x() + ((500.0f - (500.0f - 52.0f)) / 500.0f) * 2.25f; + risky_pos_max_x = pipe_top.pivot.x() + + ((500.0f - (500.0f - 52.0f)) / 500.0f) * 2.25f; risky_pos_top_y = pipe_top.pivot.y(); risky_pos_top_max_y = pipe_top.pivot.y() + 10.0f; @@ -173,11 +179,15 @@ struct Grass { grassLeft = paradiso::Sprite{ .bitmap = grassImage, .pivot = {paradiso::Vector2::make(0.0f, -0.9f)}, - .scale = {paradiso::Vector2::make(((500.0f - (500.0f - 504.0f)) / 500.0f) * 2.25f, ((700.0f - (700.0f - 112.0f)) / 700.0f) * 2.25f)}}; + .scale = {paradiso::Vector2::make( + ((500.0f - (500.0f - 504.0f)) / 500.0f) * 2.25f, + ((700.0f - (700.0f - 112.0f)) / 700.0f) * 2.25f)}}; grassRight = paradiso::Sprite{ .bitmap = grassImage, .pivot = {paradiso::Vector2::make(1.002f, -0.9f)}, - .scale = {paradiso::Vector2::make(((500.0f - (500.0f - 504.0f)) / 500.0f) * 2.25f, ((700.0f - (700.0f - 112.0f)) / 700.0f) * 2.25f)}}; + .scale = {paradiso::Vector2::make( + ((500.0f - (500.0f - 504.0f)) / 500.0f) * 2.25f, + ((700.0f - (700.0f - 112.0f)) / 700.0f) * 2.25f)}}; } void draw(const paradiso::Shader& shader) { @@ -206,7 +216,6 @@ struct Grass { } }; - struct QuickWings { paradiso::Renderer renderer1{}; paradiso::Renderer renderer2{}; @@ -295,13 +304,12 @@ struct QuickWings { // Stop game if (paused) { return; - } - else { - // Apply gravity - velocity += gravity; + } else { + // Apply gravity + velocity += gravity; - if (move_up) - velocity += move_up_velocity - gravity; + if (move_up) + velocity += move_up_velocity - gravity; // Cap velocity if (velocity > max_velocity) @@ -333,11 +341,11 @@ struct QuickWings { if (pos >= final_risky_pos_top_y && pos <= risky_pos_top_max_y) { game_over = true; } - if (pos <= final_risky_pos_bottom_y && pos >= risky_pos_bottom_max_y) { + if (pos <= final_risky_pos_bottom_y && + pos >= risky_pos_bottom_max_y) { if (collision_counter == 0) { collision_counter++; - } - else { + } else { collision_counter = 2; } @@ -354,15 +362,15 @@ struct QuickWings { paused = false; if (paused == false) { - bool pressed_up = input.top().key == ' ' || input.top().key == 'W'; + bool pressed_up = + input.top().key == ' ' || input.top().key == 'W'; if (input.top().action == 1 && pressed_up) { move_up = true; } else if (input.top().action == 0 && pressed_up) { move_up = false; } - } - else { + } else { return; } } @@ -377,11 +385,10 @@ struct Message { Message() { auto messageImage = paradiso::BitmapIO::get().load("message.png"); - messageSprite = paradiso::Sprite{ + messageSprite = paradiso::Sprite{ .bitmap = messageImage, .pivot = {paradiso::Vector2::make(0.0f, 0.0f)}, - .scale = {paradiso::Vector2::make(0.8f, 0.8f)} - }; + .scale = {paradiso::Vector2::make(0.8f, 0.8f)}}; }; void draw(const paradiso::Shader& shader) { @@ -409,11 +416,12 @@ struct GameOverMessage { GameOverMessage() { auto messageImage = paradiso::BitmapIO::get().load("gameover.png"); - messageSprite = paradiso::Sprite{ + messageSprite = paradiso::Sprite{ .bitmap = messageImage, .pivot = {paradiso::Vector2::make(0.0f, 0.4f)}, - .scale = {paradiso::Vector2::make(((500.0f - (500.0f - 192.0f)) / 500.0f) * 2.25f, ((700.0f - (700.0f - 42.0f)) / 700.0f) * 2.25f)} - }; + .scale = {paradiso::Vector2::make( + ((500.0f - (500.0f - 192.0f)) / 500.0f) * 2.25f, + ((700.0f - (700.0f - 42.0f)) / 700.0f) * 2.25f)}}; }; void draw(const paradiso::Shader& shader) { @@ -438,9 +446,10 @@ auto main() -> int { */ window - .set_size(size) // ... Grösse - .set_position(paradiso::Point{.x = 1920 / 2 - 500 / 2, .y = 1080 / 2 - 700 / 2}) // ... Position - .set_title("PardiSO.FlappyBird") // ... Titel + .set_size(size) // ... Grösse + .set_position(paradiso::Point{.x = 1920 / 2 - 500 / 2, + .y = 1080 / 2 - 700 / 2}) // ... Position + .set_title("PardiSO.FlappyBird") // ... Titel .set_visible(true); // ... und jetzt anzeigen! // der Fenster Kontext @@ -461,7 +470,6 @@ auto main() -> int { // nothing beats a classic look ctx.set_clearcolor(paradiso::RGBA::from_rgb(0x00, 0x00, 0x00)); - // Asset loader bekommt den Pfad paradiso::BitmapIO::get().set_path("assets"); @@ -474,7 +482,6 @@ auto main() -> int { auto message = Message{}; auto gameover = GameOverMessage{}; - // timer // das update führt den hier mitgegebnen Ausdruck innerhalb der internen @@ -522,7 +529,7 @@ auto main() -> int { // Quit return !(w.keyboard_input().size() && w.keyboard_input().top().key == 'Q'); - })) { + })) { }; return 0; diff --git a/examples/simple/simple.cpp b/examples/simple/simple.cpp index 09db5f1..84ae90e 100644 --- a/examples/simple/simple.cpp +++ b/examples/simple/simple.cpp @@ -5,12 +5,14 @@ * */ +#include #include #include #include #include #include #include +#include #include #include @@ -18,6 +20,9 @@ auto main() -> int { + // + std::cout << "running: " << paradiso::get_executable_path() << '\n'; + // Ausgabefenster ... sieht aus als wäre es auf dem Stack auto window = paradiso::Window(); @@ -122,4 +127,4 @@ auto main() -> int { }; return 0; -} \ No newline at end of file +} diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 63e2fdd..d5921f1 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -14,6 +14,7 @@ set(paradiso_srcs src/renderer.cpp src/context.cpp src/shader_sprite.hpp + src/utils.cpp ) set(paradiso_incs @@ -26,6 +27,7 @@ set(paradiso_incs include/paradiso/window.hpp include/paradiso/renderer.hpp include/paradiso/context.hpp + include/paradiso/utils.hpp ) add_library(paradiso_core diff --git a/src/lib/include/paradiso/aabb.hpp b/src/lib/include/paradiso/aabb.hpp index cad123f..a7f49ae 100644 --- a/src/lib/include/paradiso/aabb.hpp +++ b/src/lib/include/paradiso/aabb.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 Hartmut Seichter + * Copyright 2023-2025 Hartmut Seichter and Contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/src/lib/include/paradiso/bitmap.hpp b/src/lib/include/paradiso/bitmap.hpp index d6971f5..7b7ac34 100644 --- a/src/lib/include/paradiso/bitmap.hpp +++ b/src/lib/include/paradiso/bitmap.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 Hartmut Seichter + * Copyright 2023-2025 Hartmut Seichter and Contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -60,7 +60,8 @@ struct Bitmap final { * @param[in] data vector of RGBA values * @return bitmap with data from this call */ - static constexpr Bitmap from_data(Size size, std::vector data) noexcept { + static constexpr Bitmap from_data(Size size, + std::vector data) noexcept { assert(data.size() == size.height * size.width); return {.size = size, .data = data}; } diff --git a/src/lib/include/paradiso/bitmap_io.hpp b/src/lib/include/paradiso/bitmap_io.hpp index af0c529..1700bc1 100644 --- a/src/lib/include/paradiso/bitmap_io.hpp +++ b/src/lib/include/paradiso/bitmap_io.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 Hartmut Seichter + * Copyright 2023-2025 Hartmut Seichter and Contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -25,8 +25,8 @@ #include -#include #include +#include namespace paradiso { @@ -41,7 +41,6 @@ struct BitmapIO { std::string path() const; private: - struct Impl; std::unique_ptr impl_; diff --git a/src/lib/include/paradiso/context.hpp b/src/lib/include/paradiso/context.hpp index 31a9ac1..08e1053 100644 --- a/src/lib/include/paradiso/context.hpp +++ b/src/lib/include/paradiso/context.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 Hartmut Seichter + * Copyright 2023-2025 Hartmut Seichter and Contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/src/lib/include/paradiso/geometry.hpp b/src/lib/include/paradiso/geometry.hpp index acd018a..42adf1c 100644 --- a/src/lib/include/paradiso/geometry.hpp +++ b/src/lib/include/paradiso/geometry.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 Hartmut Seichter + * Copyright 2023-2025 Hartmut Seichter and Contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/src/lib/include/paradiso/globals.hpp b/src/lib/include/paradiso/globals.hpp index 440bc7d..5cd4ead 100644 --- a/src/lib/include/paradiso/globals.hpp +++ b/src/lib/include/paradiso/globals.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 Hartmut Seichter + * Copyright 2023-2025 Hartmut Seichter and Contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,22 +23,20 @@ #ifndef PARADISO_GLOBALS_HPP #define PARADISO_GLOBALS_HPP -#include #include #include +#include -#include #include -#include #include +#include #include #include +#include #include -#include #include - - +#include #endif diff --git a/src/lib/include/paradiso/matrix.hpp b/src/lib/include/paradiso/matrix.hpp index c359a87..7de0113 100644 --- a/src/lib/include/paradiso/matrix.hpp +++ b/src/lib/include/paradiso/matrix.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 Hartmut Seichter + * Copyright 2023-2025 Hartmut Seichter and Contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -26,7 +26,6 @@ #include #include - namespace paradiso { template diff --git a/src/lib/include/paradiso/matrixbase.hpp b/src/lib/include/paradiso/matrixbase.hpp index b20a8d4..3fb4227 100644 --- a/src/lib/include/paradiso/matrixbase.hpp +++ b/src/lib/include/paradiso/matrixbase.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 Hartmut Seichter + * Copyright 2023-2025 Hartmut Seichter and Contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -43,9 +43,13 @@ template struct MatrixBase { constexpr iterator begin() noexcept { return this->data(); } constexpr iterator end() noexcept { return this->data() + size(); } constexpr const_iterator begin() const noexcept { return this->data(); } - constexpr const_iterator end() const noexcept { return this->data() + size(); } + constexpr const_iterator end() const noexcept { + return this->data() + size(); + } constexpr const_iterator cbegin() const noexcept { return this->data(); } - constexpr const_iterator cend() const noexcept { return this->data() + size(); } + constexpr const_iterator cend() const noexcept { + return this->data() + size(); + } constexpr Scalar& operator[](std::size_t i) { return this->data()[i]; } constexpr const Scalar& operator[](std::size_t i) const { @@ -111,10 +115,12 @@ template struct MatrixBase { } constexpr void operator+=(const Derived& b) { - std::transform((*this).begin(),(*this).end(),b.begin(),(*this).begin(),std::plus<>()); + std::transform((*this).begin(), (*this).end(), b.begin(), + (*this).begin(), std::plus<>()); } constexpr void operator-=(const Derived& b) { - std::transform((*this).begin(),(*this).end(),b.begin(),(*this).begin(),std::minus<>()); + std::transform((*this).begin(), (*this).end(), b.begin(), + (*this).begin(), std::minus<>()); } constexpr const Derived operator*(const Scalar& b) const { diff --git a/src/lib/include/paradiso/renderer.hpp b/src/lib/include/paradiso/renderer.hpp index b52a908..824eeeb 100644 --- a/src/lib/include/paradiso/renderer.hpp +++ b/src/lib/include/paradiso/renderer.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 Hartmut Seichter + * Copyright 2023-2025 Hartmut Seichter and Contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/src/lib/include/paradiso/rgba.hpp b/src/lib/include/paradiso/rgba.hpp index d7745e2..fc039e2 100644 --- a/src/lib/include/paradiso/rgba.hpp +++ b/src/lib/include/paradiso/rgba.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 Hartmut Seichter + * Copyright 2023-2025 Hartmut Seichter and Contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/src/lib/include/paradiso/shader.hpp b/src/lib/include/paradiso/shader.hpp index d51f6cf..cdc96c8 100644 --- a/src/lib/include/paradiso/shader.hpp +++ b/src/lib/include/paradiso/shader.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 Hartmut Seichter + * Copyright 2023-2025 Hartmut Seichter and Contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/src/lib/include/paradiso/sprite.hpp b/src/lib/include/paradiso/sprite.hpp index a518e51..cf4652c 100644 --- a/src/lib/include/paradiso/sprite.hpp +++ b/src/lib/include/paradiso/sprite.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 Hartmut Seichter + * Copyright 2023-2025 Hartmut Seichter and Contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/src/lib/include/paradiso/utils.hpp b/src/lib/include/paradiso/utils.hpp new file mode 100644 index 0000000..64b53a5 --- /dev/null +++ b/src/lib/include/paradiso/utils.hpp @@ -0,0 +1,38 @@ +/* + * Copyright 2023-2025 Hartmut Seichter and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ +#ifndef PARADISO_UTILS_HPP +#define PARADISO_UTILS_HPP + +#include + +namespace paradiso { + +using path = std::filesystem::path; + +/** + * @return executable path + */ +path get_executable_path(); +} // namespace paradiso + +#endif diff --git a/src/lib/include/paradiso/vector.hpp b/src/lib/include/paradiso/vector.hpp index 2012ef5..5ac40f2 100644 --- a/src/lib/include/paradiso/vector.hpp +++ b/src/lib/include/paradiso/vector.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 Hartmut Seichter + * Copyright 2023-2025 Hartmut Seichter and Contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/src/lib/include/paradiso/window.hpp b/src/lib/include/paradiso/window.hpp index 91337ac..b55124d 100644 --- a/src/lib/include/paradiso/window.hpp +++ b/src/lib/include/paradiso/window.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 Hartmut Seichter + * Copyright 2023-2025 Hartmut Seichter and Contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,8 +23,8 @@ #ifndef PARADISO_WINDOW_HPP #define PARADISO_WINDOW_HPP -#include #include +#include #include #include @@ -72,7 +72,6 @@ struct Window final { void set_resizecallback(on_resizecallback_t f) { on_resize_ = f; } - bool visible() const; Window& set_visible(bool is_visible); @@ -83,8 +82,6 @@ struct Window final { std::unique_ptr impl_; on_resizecallback_t on_resize_; - - }; } // namespace paradiso diff --git a/src/lib/src/bitmap_io.cpp b/src/lib/src/bitmap_io.cpp index 3490669..b279244 100644 --- a/src/lib/src/bitmap_io.cpp +++ b/src/lib/src/bitmap_io.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 Hartmut Seichter + * Copyright 2023-2025 Hartmut Seichter and Contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -127,15 +127,10 @@ Bitmap BitmapIO::load(std::string_view filename, bool ignore_cache) const { return impl_->load(filename); } -void BitmapIO::set_path(std::string_view path) -{ - impl_->asset_path_ = path; -} +void BitmapIO::set_path(std::string_view path) { impl_->asset_path_ = path; } -std::string BitmapIO::path() const -{ +std::string BitmapIO::path() const { return impl_->asset_path_.generic_string(); } - } // namespace paradiso diff --git a/src/lib/src/context.cpp b/src/lib/src/context.cpp index 6ef465c..6d16a33 100644 --- a/src/lib/src/context.cpp +++ b/src/lib/src/context.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 Hartmut Seichter + * Copyright 2023-2025 Hartmut Seichter and Contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/src/lib/src/renderer.cpp b/src/lib/src/renderer.cpp index ab03c23..ff4b7ed 100644 --- a/src/lib/src/renderer.cpp +++ b/src/lib/src/renderer.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 Hartmut Seichter + * Copyright 2023-2025 Hartmut Seichter and Contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,8 +31,8 @@ #include #include #include -#include #include +#include #if defined(_WIN32) #undef max diff --git a/src/lib/src/shader.cpp b/src/lib/src/shader.cpp index e3d6b73..12b7719 100644 --- a/src/lib/src/shader.cpp +++ b/src/lib/src/shader.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 Hartmut Seichter + * Copyright 2023-2025 Hartmut Seichter and Contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/src/lib/src/shader_sprite.hpp b/src/lib/src/shader_sprite.hpp index 1f546c9..bc374ef 100644 --- a/src/lib/src/shader_sprite.hpp +++ b/src/lib/src/shader_sprite.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 Hartmut Seichter + * Copyright 2023-2025 Hartmut Seichter and Contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -65,7 +65,6 @@ void main() { } )"; - static constexpr auto sprite_unlit_fragment = R"( #version 400 core diff --git a/src/lib/src/utils.cpp b/src/lib/src/utils.cpp new file mode 100644 index 0000000..bfd05d9 --- /dev/null +++ b/src/lib/src/utils.cpp @@ -0,0 +1,46 @@ +/* + * Copyright 2023-2025 Hartmut Seichter and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ +#include "paradiso/utils.hpp" + +#include +#include +#include + +#if defined(_WIN32) || defined(_WIN64) || defined(_WIN32_WCE) +#define WIN32_LEAN_AND_MEAN +#include +#endif + +namespace paradiso { + +path get_executable_path() { +#if defined(_WIN32) + std::array lpFname{}; + DWORD ret = GetModuleFileName(NULL, lpFname.data(), lpFname.size()); + return {std::string{std::from_range, lpFname}}; +#elif defined(__linux) + return std::filesystem::canonical(u8"/proc/self/exe"); +#endif +} + +} // namespace paradiso diff --git a/src/lib/src/window.cpp b/src/lib/src/window.cpp index 253d338..c417836 100644 --- a/src/lib/src/window.cpp +++ b/src/lib/src/window.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 Hartmut Seichter + * Copyright 2023-2025 Hartmut Seichter and Contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal