- update copyright

- add instructions for cross-compilation
- add utility function for Windows and Linux executable path
This commit is contained in:
Hartmut Seichter 2025-05-25 12:31:16 +02:00
parent a4f6803c35
commit 317cde6fa1
30 changed files with 243 additions and 102 deletions

2
.gitignore vendored
View file

@ -1,4 +1,4 @@
build
build*
.vscode
/.vs
.cache

31
docs/COMPILATION.md Normal file
View file

@ -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 .
```

View file

@ -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)

View file

@ -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<float>::make(0.f,0.01f));
ball.push(paradiso::Vector2<float>::make(0.f, 0.01f));
} else if (w.keyboard_input().top().key == 'M') {
ball.push(paradiso::Vector2<float>::make(0.f,-0.01f));
ball.push(paradiso::Vector2<float>::make(0.f, -0.01f));
std::cout << "Speed Lower!\n";
}

View file

@ -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/ $<TARGET_FILE_DIR:quickwings>/assets)
${CMAKE_CURRENT_SOURCE_DIR}/assets/
$<TARGET_FILE_DIR:quickwings>/assets)

View file

@ -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<float>::make(1.4f, pipe_spawn_rand + 1.0f)},
.scale = {paradiso::Vector2<float>::make(((500.0f - (500.0f - 52.0f)) / 500.0f) * 2.25f, ((700.0f - (700.0f - 320.0f)) / 700.0f) * 2.25f)},
.pivot = {paradiso::Vector2<float>::make(1.4f,
pipe_spawn_rand + 1.0f)},
.scale = {paradiso::Vector2<float>::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<float>::make(1.4f, pipe_spawn_rand - 1.5f)},
.scale = {paradiso::Vector2<float>::make(((500.0f - (500.0f - 52.0f)) / 500.0f) * 2.25f, ((700.0f - (700.0f - 320.0f)) / 700.0f) * 2.25f)}};
.pivot = {paradiso::Vector2<float>::make(1.4f,
pipe_spawn_rand - 1.5f)},
.scale = {paradiso::Vector2<float>::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<float>::make(0.0f, -0.9f)},
.scale = {paradiso::Vector2<float>::make(((500.0f - (500.0f - 504.0f)) / 500.0f) * 2.25f, ((700.0f - (700.0f - 112.0f)) / 700.0f) * 2.25f)}};
.scale = {paradiso::Vector2<float>::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<float>::make(1.002f, -0.9f)},
.scale = {paradiso::Vector2<float>::make(((500.0f - (500.0f - 504.0f)) / 500.0f) * 2.25f, ((700.0f - (700.0f - 112.0f)) / 700.0f) * 2.25f)}};
.scale = {paradiso::Vector2<float>::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<float>::make(0.0f, 0.0f)},
.scale = {paradiso::Vector2<float>::make(0.8f, 0.8f)}
};
.scale = {paradiso::Vector2<float>::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<float>::make(0.0f, 0.4f)},
.scale = {paradiso::Vector2<float>::make(((500.0f - (500.0f - 192.0f)) / 500.0f) * 2.25f, ((700.0f - (700.0f - 42.0f)) / 700.0f) * 2.25f)}
};
.scale = {paradiso::Vector2<float>::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;

View file

@ -5,12 +5,14 @@
*
*/
#include <istream>
#include <paradiso/bitmap.hpp>
#include <paradiso/context.hpp>
#include <paradiso/geometry.hpp>
#include <paradiso/renderer.hpp>
#include <paradiso/shader.hpp>
#include <paradiso/sprite.hpp>
#include <paradiso/utils.hpp>
#include <paradiso/window.hpp>
#include <iomanip>
@ -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;
}
}

View file

@ -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

View file

@ -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

View file

@ -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<RGBA> data) noexcept {
static constexpr Bitmap from_data(Size size,
std::vector<RGBA> data) noexcept {
assert(data.size() == size.height * size.width);
return {.size = size, .data = data};
}

View file

@ -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 <paradiso/bitmap.hpp>
#include <string_view>
#include <memory>
#include <string_view>
namespace paradiso {
@ -41,7 +41,6 @@ struct BitmapIO {
std::string path() const;
private:
struct Impl;
std::unique_ptr<Impl> impl_;

View file

@ -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

View file

@ -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

View file

@ -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 <cstdint>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <memory>
#include <array>
#include <vector>
#include <map>
#include <memory>
#include <string>
#include <tuple>
#include <vector>
#include <type_traits>
#include <numeric>
#include <algorithm>
#include <numeric>
#endif

View file

@ -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 <paradiso/globals.hpp>
#include <paradiso/matrixbase.hpp>
namespace paradiso {
template <std::size_t R, std::size_t C, typename Scalar, bool RowMajor = false>

View file

@ -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 <typename Scalar, typename Derived> 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 <typename Scalar, typename Derived> 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 {

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 <filesystem>
namespace paradiso {
using path = std::filesystem::path;
/**
* @return executable path
*/
path get_executable_path();
} // namespace paradiso
#endif

View file

@ -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

View file

@ -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 <paradiso/globals.hpp>
#include <paradiso/geometry.hpp>
#include <paradiso/globals.hpp>
#include <functional>
#include <stack>
@ -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> impl_;
on_resizecallback_t on_resize_;
};
} // namespace paradiso

View file

@ -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

View file

@ -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

View file

@ -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 <array>
#include <iomanip>
#include <iostream>
#include <vector>
#include <limits>
#include <vector>
#if defined(_WIN32)
#undef max

View file

@ -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

View file

@ -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

46
src/lib/src/utils.cpp Normal file
View file

@ -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 <filesystem>
#include <ranges>
#include <string>
#if defined(_WIN32) || defined(_WIN64) || defined(_WIN32_WCE)
#define WIN32_LEAN_AND_MEAN
#include <libloaderapi.h>
#endif
namespace paradiso {
path get_executable_path() {
#if defined(_WIN32)
std::array<TCHAR, MAX_PATH> 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

View file

@ -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