forked from Hartmut/paradiso
- update copyright
- add instructions for cross-compilation - add utility function for Windows and Linux executable path
This commit is contained in:
parent
a4f6803c35
commit
317cde6fa1
30 changed files with 243 additions and 102 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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};
|
||||
}
|
||||
|
|
|
@ -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_;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
38
src/lib/include/paradiso/utils.hpp
Normal file
38
src/lib/include/paradiso/utils.hpp
Normal 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
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
46
src/lib/src/utils.cpp
Normal 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
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue