4 Commits
Author SHA1 Message Date
tobid7 892f8ce0c4 Update License Header Text 2026-01-25 21:12:16 +01:00
tobid7 c373b15bab remove drivers pd_p_api header 2026-01-25 21:00:50 +01:00
tobid7 fb46f4d36a Let's just use 1 PD_API header 2026-01-25 20:57:14 +01:00
tobid7 337c016824 Unfiy all sub projects back into 1 libpalladium 2026-01-25 20:44:52 +01:00
127 changed files with 4019 additions and 4017 deletions
+71 -14
View File
@@ -8,29 +8,86 @@ set(PD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
include(cmake/palladium.cmake)
option(PD_BUILD_TESTS "Sets if TestApp and TestBench get build" OFF)
option(PD_BUILD_SHARED "Build Shared Libraries" OFF)
option(PD_BUILD_SHARED "Build Shared Library" OFF)
option(PD_BUILD_TOOLS "Build Palladium Tools" OFF)
if(${PD_BUILD_TOOLS})
add_subdirectory(tools)
endif()
## Include Library Source
# # Include Library Source
set(PD_SOURCES
add_subdirectory(pd/drivers)
add_subdirectory(pd/core)
add_subdirectory(pd/image)
add_subdirectory(pd/external)
add_subdirectory(pd/lithium)
add_subdirectory(pd/ui7)
# Core
source/core/bit_util.cpp
source/core/color.cpp
source/core/io.cpp
source/core/mat.cpp
source/core/strings.cpp
source/core/timer.cpp
source/core/timetrace.cpp
add_library(palladium INTERFACE)
target_link_libraries(palladium INTERFACE
pd-core pd-image pd-external pd-lithium pd-ui7 #pd-net
# Drivers
source/drivers/gfx.cpp
source/drivers/hid.cpp
source/drivers/os.cpp
# External
source/external/stb.cpp
# Image
source/image/image.cpp
source/image/img_blur.cpp
source/image/img_convert.cpp
# Lithium
source/lithium/command.cpp
source/lithium/drawlist.cpp
source/lithium/font.cpp
source/lithium/fonts.cpp
source/lithium/renderer.cpp
# UI7
source/ui7/container/button.cpp
source/ui7/container/checkbox.cpp
source/ui7/container/coloredit.cpp
source/ui7/container/container.cpp
source/ui7/container/dragdata.cpp
source/ui7/container/dynobj.cpp
source/ui7/container/image.cpp
source/ui7/container/label.cpp
source/ui7/container/slider.cpp
source/ui7/io.cpp
source/ui7/layout.cpp
source/ui7/menu.cpp
source/ui7/theme.cpp
source/ui7/ui7.cpp
)
add_dependencies(palladium
pd-drivers pd-core pd-image pd-external pd-lithium pd-ui7 #pd-net
)
if(${PD_BUILD_SHARED})
add_library(palladium SHARED ${PD_SOURCES})
target_compile_definitions(palladium PRIVATE -DPD_BUILD_SHARED)
else()
add_library(palladium STATIC ${PD_SOURCES})
endif()
target_include_directories(palladium PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
install(DIRECTORY include DESTINATION ".")
install(TARGETS palladium)
find_program(CLANG_FORMAT clang-format)
file(GLOB_RECURSE PD_FMTFILES CONFIGURE_DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/include/pd/core/*.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/pd/drivers/*.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/pd/image/*.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/pd/lithium/*.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/pd/ui7/*.hpp
)
add_custom_target(pd-clang-format
COMMAND ${CLANG_FORMAT} --style=file -i ${PD_FMTFILES}
COMMENT "Formatting Project Sources"
)
+1 -2
View File
@@ -2,8 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 -2
View File
@@ -2,8 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 -2
View File
@@ -2,8 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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,28 @@
#pragma once
/*
MIT License
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 <3ds.h>
#include <pd/core/common.hpp>
+1 -2
View File
@@ -1,7 +1,6 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 -2
View File
@@ -1,7 +1,6 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 -2
View File
@@ -1,7 +1,6 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 -2
View File
@@ -2,8 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -2,8 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -2,8 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 -2
View File
@@ -1,7 +1,6 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 -2
View File
@@ -1,7 +1,6 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 -2
View File
@@ -1,7 +1,6 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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
View File
@@ -1,5 +1,28 @@
#pragma once
/*
MIT License
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 <pd/core/core.hpp>
#include <pd/drivers/drivers.hpp>
#include <pd/external/json.hpp>
+3 -4
View File
@@ -2,8 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -36,12 +35,12 @@ namespace BitUtil {
* @param v 32 bit unsigned int
* @return true if its a single bit number
*/
PD_CORE_API bool IsSingleBit(u32 v);
PD_API bool IsSingleBit(u32 v);
/**
* Get the Next Power of two Number
* @param v Current Number
* @return Next Number thats a Pow of 2
*/
PD_CORE_API u32 GetPow2(u32 v);
PD_API u32 GetPow2(u32 v);
} // namespace BitUtil
} // namespace PD
+2 -2
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -27,7 +27,7 @@ SOFTWARE.
#include <pd/core/strings.hpp>
namespace PD {
class PD_CORE_API Color {
class PD_API Color {
public:
/**
* Default Constructor (all variables are set to 0)
+2 -2
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -42,7 +42,7 @@ SOFTWARE.
#include <vector>
/** Dynamic Lib loading */
#include <pd/core/pd_p_api.hpp>
#include <pd/pd_p_api.hpp>
/** Memory Management */
+1 -1
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 -1
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 -1
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+6 -6
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -35,28 +35,28 @@ namespace IO {
* @param path Path to the File
* @return 8Bit FileBuffer
*/
PD_CORE_API std::vector<u8> LoadFile2Mem(const std::string& path);
PD_API std::vector<u8> LoadFile2Mem(const std::string& path);
/**
* Load a File into a std::string
* @param path Path to the File
* @return std::string file content
*/
PD_CORE_API std::string LoadFile2Str(const std::string& path);
PD_API std::string LoadFile2Str(const std::string& path);
/**
* Hash a 8Bit Memory Buffer
* @param data 8Bit input Buffer
* @return 32Bit Hash
*/
PD_CORE_API u32 HashMemory(const std::vector<u8>& data);
PD_API u32 HashMemory(const std::vector<u8>& data);
/**
* Function to decrompress RLE buffer
* @param data Data buffer to decompress
*/
PD_CORE_API void DecompressRLE(std::vector<u8>& data);
PD_API void DecompressRLE(std::vector<u8>& data);
/**
* Function to compress data with RLE Algorithm
* @param data Data buf
*/
PD_CORE_API void CompressRLE(std::vector<u8>& data);
PD_API void CompressRLE(std::vector<u8>& data);
} // namespace IO
} // namespace PD
+2 -3
View File
@@ -2,8 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -41,7 +40,7 @@ constexpr float Radians(float v) { return v * (Numbers::Tau / 360.0f); }
* @note That this is not a full Matrix Library
*/
struct PD_CORE_API Mat4 {
struct PD_API Mat4 {
std::array<float, 16> m;
constexpr Mat4() : m{} {}
constexpr static Mat4 Diagonal(float x, float y, float z, float w) {
-51
View File
@@ -1,51 +0,0 @@
#pragma once
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
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.
*/
/** Generated with ppam */
#ifdef _WIN32 // Windows (MSVC Tested)
#ifdef PD_CORE_BUILD_SHARED
#define PD_CORE_API __declspec(dllexport)
#else
#define PD_CORE_API __declspec(dllimport)
#endif
#elif defined(__APPLE__) // macOS (untested yet)
#ifdef PD_CORE_BUILD_SHARED
#define PD_CORE_API __attribute__((visibility("default")))
#else
#define PD_CORE_API
#endif
#elif defined(__linux__) // Linux (untested yet)
#ifdef PD_CORE_BUILD_SHARED
#define PD_CORE_API __attribute__((visibility("default")))
#else
#define PD_CORE_API
#endif
#elif defined(__3DS__) // 3ds Specific
// Only Static supported
#define PD_CORE_API
#else
#define PD_CORE_API
#endif
Executable → Regular
+10 -10
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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,7 +43,7 @@ constexpr int HexChar2Int(char c) {
* @param exts List of Extensions to check for
* @return true if one of the extensions is found in the String
*/
PD_CORE_API bool StringEndsWith(const std::string& str,
PD_API bool StringEndsWith(const std::string& str,
const std::vector<std::string>& exts);
/**
* Function to Create a wstring of a string
@@ -51,39 +51,39 @@ PD_CORE_API bool StringEndsWith(const std::string& str,
* @return Result wstring
* @note Returns Empty if it has an error
*/
PD_CORE_API std::wstring MakeWstring(const std::string& s);
PD_API std::wstring MakeWstring(const std::string& s);
/**
* Generate a Formatted String by an Nanoseconds Input
* @param nanos Nanoseconds Input
* @return Result String
*/
PD_CORE_API const std::string FormatNanos(unsigned long long nanos);
PD_API const std::string FormatNanos(unsigned long long nanos);
/**
* Generate a Formatted String by an Milliseconds Input
* @param millis Milliseconds Input
* @return Result String
*/
PD_CORE_API const std::string FormatMillis(unsigned long long millis);
PD_API const std::string FormatMillis(unsigned long long millis);
/**
* Create a formatted String by an input bytes value
* @param bytes value in bytes
* @result Formatted String for example `2.5MB`
*/
PD_CORE_API const std::string FormatBytes(unsigned long long bytes);
PD_API const std::string FormatBytes(unsigned long long bytes);
/**
* Extract the Filename out of a Path
* @param path Path to extract from
* @param saperators Path Split Chars
* @return extracted filename
*/
PD_CORE_API const std::string GetFileName(
const std::string& path, const std::string& saperators = "/\\");
PD_API const std::string GetFileName(const std::string& path,
const std::string& saperators = "/\\");
/**
* Remove Extension from a Path / Filename
* @param path Input Path
* @return Path without Extension
*/
PD_CORE_API const std::string PathRemoveExtension(const std::string& path);
PD_API const std::string PathRemoveExtension(const std::string& path);
/**
* Function to Convert a Type to a hex value
* @tparam T Type
@@ -101,7 +101,7 @@ inline const std::string ToHex(const T& v) {
* @param s String to hash
* @return 32Bit Hash
*/
PD_CORE_API u32 FastHash(const std::string& s);
PD_API u32 FastHash(const std::string& s);
/**
* Function to Generate a Compiler Name and Version String
* Based on their Macros
+2 -2
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -29,7 +29,7 @@ namespace PD {
/**
* Timer class
*/
class PD_CORE_API Timer {
class PD_API Timer {
public:
/**
* Constructor
Executable → Regular
+7 -7
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -102,12 +102,12 @@ class TimeStats {
* Get Data Buffer
* @return data bufer (not edidable)
*/
const std::vector<u64> &GetData() { return val; }
const std::vector<u64>& GetData() { return val; }
/**
* Access an element in the list [not edidable]
* @return value to access
*/
const u64 &operator[](int i) { return val[smart_idx(i)]; }
const u64& operator[](int i) { return val[smart_idx(i)]; }
/**
* Get List Lengh
* @return Lengh
@@ -160,7 +160,7 @@ class Res {
* Setter for the ID (Name)
* @param v ID of the Trace
*/
void SetID(const std::string &v) { id = v; }
void SetID(const std::string& v) { id = v; }
/**
* Getter for the traces ID
* @return Trace ID
@@ -218,12 +218,12 @@ class Res {
* Begin a Trace
* @param id Name of the Trace
*/
PD_CORE_API void Beg(const std::string &id);
PD_API void Beg(const std::string& id);
/**
* End a Trace
* @param id Name of the Trace
*/
PD_CORE_API void End(const std::string &id);
PD_API void End(const std::string& id);
/**
* Collect Start end end of the trace by tracking
* when the Scope object goes out of scope
@@ -245,7 +245,7 @@ class Scope {
* Constructor requiring a Name for the Trace
* @param id Name of the Trace
*/
Scope(const std::string &id) {
Scope(const std::string& id) {
this->ID = id;
Beg(id);
}
+1 -1
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 -2
View File
@@ -2,8 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 -1
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 -1
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 -1
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 -1
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 -1
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 -1
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 -1
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 -1
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+3 -4
View File
@@ -2,8 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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,10 +24,10 @@ SOFTWARE.
*/
#include <pd/core/core.hpp>
#include <pd/image/pd_p_api.hpp>
#include <pd/pd_p_api.hpp>
namespace PD {
class PD_IMAGE_API Image {
class PD_API Image {
public:
enum Format {
RGBA, // bpp == 4
Executable → Regular
+7 -8
View File
@@ -2,8 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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,7 +24,7 @@ SOFTWARE.
*/
#include <pd/core/core.hpp>
#include <pd/image/pd_p_api.hpp>
#include <pd/pd_p_api.hpp>
namespace PD {
/**
@@ -38,7 +37,7 @@ namespace ImgBlur {
* @param si sigma value to use
* @return list of kernel values
*/
PD_IMAGE_API std::vector<float> GaussianKernel(int radius, float si);
PD_API std::vector<float> GaussianKernel(int radius, float si);
/**
* Gaussian Blur for basic Image Buffer
* @param buf Image Buffer (unsigned char)
@@ -48,8 +47,8 @@ PD_IMAGE_API std::vector<float> GaussianKernel(int radius, float si);
* @param si Blur sigma
* @param idxfn Indexing function
*/
PD_IMAGE_API void GaussianBlur(
std::vector<u8> &buf, int w, int h, float radius, float si,
PD_API void GaussianBlur(
std::vector<u8>& buf, int w, int h, float radius, float si,
std::function<int(int, int, int)> idxfn = [](int x, int y, int w) -> int {
return y * w + x;
});
@@ -63,8 +62,8 @@ PD_IMAGE_API void GaussianBlur(
* @param si Blur sigma
* @param idxfn Indexing function
*/
PD_IMAGE_API void GaussianBlur(
void *buf, int w, int h, int bpp, float radius, float si,
PD_API void GaussianBlur(
void* buf, int w, int h, int bpp, float radius, float si,
std::function<int(int, int, int)> idxfn = [](int x, int y, int w) -> int {
return y * w + x;
});
Executable → Regular
+10 -11
View File
@@ -2,8 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 +25,7 @@ SOFTWARE.
#include <pd/core/core.hpp>
#include <pd/image/image.hpp>
#include <pd/image/pd_p_api.hpp>
#include <pd/pd_p_api.hpp>
namespace PD {
/**
@@ -41,19 +40,19 @@ namespace ImgConvert {
* @param w width of the image
* @param h height of the image
*/
PD_IMAGE_API
void RGB24toRGBA32(std::vector<PD::u8> &out, const std::vector<u8> &in,
const int &w, const int &h);
PD_IMAGE_API
void RGB32toRGBA24(std::vector<u8> &out, const std::vector<u8> &in,
const int &w, const int &h);
PD_API
void RGB24toRGBA32(std::vector<PD::u8>& out, const std::vector<u8>& in,
const int& w, const int& h);
PD_API
void RGB32toRGBA24(std::vector<u8>& out, const std::vector<u8>& in,
const int& w, const int& h);
/**
* Reverse 32 (RGBA -> ABGR || ABGR -> RGBA)
* @param buf Buffer to convert
* @param w width
* @param h height
*/
PD_IMAGE_API void Reverse32(std::vector<u8> &buf, const int &w, const int &h);
PD_IMAGE_API void ReverseBuf(std::vector<u8> &buf, size_t bpp, int w, int h);
PD_API void Reverse32(std::vector<u8>& buf, const int& w, const int& h);
PD_API void ReverseBuf(std::vector<u8>& buf, size_t bpp, int w, int h);
} // namespace ImgConvert
} // namespace PD
-51
View File
@@ -1,51 +0,0 @@
#pragma once
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
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.
*/
/** Generated with ppam */
#ifdef _WIN32 // Windows (MSVC Tested)
#ifdef PD_IMAGE_BUILD_SHARED
#define PD_IMAGE_API __declspec(dllexport)
#else
#define PD_IMAGE_API __declspec(dllimport)
#endif
#elif defined(__APPLE__) // macOS (untested yet)
#ifdef PD_IMAGE_BUILD_SHARED
#define PD_IMAGE_API __attribute__((visibility("default")))
#else
#define PD_IMAGE_API
#endif
#elif defined(__linux__) // Linux (untested yet)
#ifdef PD_IMAGE_BUILD_SHARED
#define PD_IMAGE_API __attribute__((visibility("default")))
#else
#define PD_IMAGE_API
#endif
#elif defined(__3DS__) // 3ds Specific
// Only Static supported
#define PD_IMAGE_API
#else
#define PD_IMAGE_API
#endif
Executable → Regular
+3 -3
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -24,9 +24,9 @@ SOFTWARE.
*/
#include <pd/core/core.hpp>
#include <pd/lithium/pd_p_api.hpp>
#include <pd/lithium/texture.hpp>
#include <pd/lithium/vertex.hpp>
#include <pd/pd_p_api.hpp>
namespace PD {
namespace Li {
@@ -72,7 +72,7 @@ class Command {
TexAddress Tex;
};
class PD_LITHIUM_API CmdPool {
class PD_API CmdPool {
public:
CmdPool() {}
~CmdPool() {}
+3 -4
View File
@@ -2,8 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 +25,7 @@ SOFTWARE.
#include <pd/lithium/command.hpp>
#include <pd/lithium/font.hpp>
#include <pd/lithium/pd_p_api.hpp>
#include <pd/pd_p_api.hpp>
/** Path Rect Flags */
using LiPathRectFlags = PD::u32;
@@ -46,7 +45,7 @@ enum LiPathRectFlags_ : PD::u32 {
namespace PD {
namespace Li {
class PD_LITHIUM_API DrawList {
class PD_API DrawList {
public:
DrawList(int initial_size = 64);
~DrawList();
Executable → Regular
+3 -4
View File
@@ -2,8 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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,9 +25,9 @@ SOFTWARE.
#include <pd/core/core.hpp>
#include <pd/lithium/command.hpp>
#include <pd/lithium/pd_p_api.hpp>
#include <pd/lithium/rect.hpp>
#include <pd/lithium/texture.hpp>
#include <pd/pd_p_api.hpp>
using LiTextFlags = PD::u32;
enum LiTextFlags_ {
@@ -44,7 +43,7 @@ enum LiTextFlags_ {
namespace PD {
namespace Li {
class PD_LITHIUM_API Font {
class PD_API Font {
public:
/** Codepoint Data holder */
struct Codepoint {
+1 -1
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 -2
View File
@@ -2,8 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
-51
View File
@@ -1,51 +0,0 @@
#pragma once
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
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.
*/
/** Generated with ppam */
#ifdef _WIN32 // Windows (MSVC Tested)
#ifdef PD_LITHIUM_BUILD_SHARED
#define PD_LITHIUM_API __declspec(dllexport)
#else
#define PD_LITHIUM_API __declspec(dllimport)
#endif
#elif defined(__APPLE__) // macOS (untested yet)
#ifdef PD_LITHIUM_BUILD_SHARED
#define PD_LITHIUM_API __attribute__((visibility("default")))
#else
#define PD_LITHIUM_API
#endif
#elif defined(__linux__) // Linux (untested yet)
#ifdef PD_LITHIUM_BUILD_SHARED
#define PD_LITHIUM_API __attribute__((visibility("default")))
#else
#define PD_LITHIUM_API
#endif
#elif defined(__3DS__) // 3ds Specific
// Only Static supported
#define PD_LITHIUM_API
#else
#define PD_LITHIUM_API
#endif
+1 -1
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Executable → Regular
+3 -4
View File
@@ -2,8 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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,15 +24,15 @@ SOFTWARE.
*/
#include <pd/drivers/drivers.hpp>
#include <pd/lithium/pd_p_api.hpp>
#include <pd/lithium/rect.hpp>
#include <pd/pd_p_api.hpp>
namespace PD {
namespace Li {
/**
* Static Class Render Setup Functions
*/
class PD_LITHIUM_API Renderer {
class PD_API Renderer {
public:
Renderer() = default;
~Renderer() = default;
+1 -1
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 -1
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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,26 +26,26 @@ SOFTWARE.
/** Generated with ppam */
#ifdef _WIN32 // Windows (MSVC Tested)
#ifdef PD_UI7_BUILD_SHARED
#define PD_UI7_API __declspec(dllexport)
#ifdef PD_BUILD_SHARED
#define PD_API __declspec(dllexport)
#else
#define PD_UI7_API __declspec(dllimport)
#define PD_API __declspec(dllimport)
#endif
#elif defined(__APPLE__) // macOS (untested yet)
#ifdef PD_UI7_BUILD_SHARED
#define PD_UI7_API __attribute__((visibility("default")))
#ifdef PD_BUILD_SHARED
#define PD_API __attribute__((visibility("default")))
#else
#define PD_UI7_API
#define PD_API
#endif
#elif defined(__linux__) // Linux (untested yet)
#ifdef PD_UI7_BUILD_SHARED
#define PD_UI7_API __attribute__((visibility("default")))
#ifdef PD_BUILD_SHARED
#define PD_API __attribute__((visibility("default")))
#else
#define PD_UI7_API
#define PD_API
#endif
#elif defined(__3DS__) // 3ds Specific
// Only Static supported
#define PD_UI7_API
#define PD_API
#else
#define PD_UI7_API
#define PD_API
#endif
+2 -2
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -35,7 +35,7 @@ namespace UI7 {
* This only means that InPressed is responding the info in
* the next frame
*/
class PD_UI7_API Button : public Container {
class PD_API Button : public Container {
public:
/**
* Button Object constructor
+2 -2
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -33,7 +33,7 @@ namespace UI7 {
* Context::Update while the visual update is done
* during the Update
*/
class PD_UI7_API Checkbox : public Container {
class PD_API Checkbox : public Container {
public:
/**
* Constructor for Checkbox Object
+2 -2
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -32,7 +32,7 @@ namespace UI7 {
/**
* Color Editor (Creating a PopUP when clicking)
*/
class PD_UI7_API ColorEdit : public Container {
class PD_API ColorEdit : public Container {
public:
/**
* Constructor
+3 -3
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -24,8 +24,8 @@ SOFTWARE.
*/
#include <pd/core/core.hpp>
#include <pd/pd_p_api.hpp>
#include <pd/ui7/io.hpp>
#include <pd/ui7/pd_p_api.hpp>
namespace PD {
namespace UI7 {
@@ -33,7 +33,7 @@ namespace UI7 {
* Container base class all Objects are based on
* @note this class can be used to create custom Objects as well
*/
class PD_UI7_API Container {
class PD_API Container {
public:
Container() = default;
/**
+2 -2
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -33,7 +33,7 @@ namespace UI7 {
* and modifys these by moving left or right when dragging
*/
template <typename T>
class PD_UI7_API DragData : public Container {
class PD_API DragData : public Container {
public:
/**
* Constructor
+2 -3
View File
@@ -2,8 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -36,7 +35,7 @@ namespace UI7 {
* This only means that InPressed is responding the info in
* the next frame
*/
class PD_UI7_API DynObj : public Container {
class PD_API DynObj : public Container {
public:
/**
* Button Object constructor
+2 -2
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -30,7 +30,7 @@ namespace UI7 {
/**
* Image Object
*/
class PD_UI7_API Image : public Container {
class PD_API Image : public Container {
public:
/**
* Constructor for the Image Object
+2 -2
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -30,7 +30,7 @@ namespace UI7 {
/**
* Label [Text] Object
*/
class PD_UI7_API Label : public Container {
class PD_API Label : public Container {
public:
/**
* Constructor for Label Object
+2 -2
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -33,7 +33,7 @@ namespace UI7 {
* and modifys these by moving left or right when dragging
*/
template <typename T>
class PD_UI7_API Slider : public Container {
class PD_API Slider : public Container {
public:
/**
* Constructor
+1 -1
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 -1
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 -1
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Executable → Regular
+2 -3
View File
@@ -2,8 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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,8 +25,8 @@ SOFTWARE.
#include <pd/core/core.hpp>
#include <pd/lithium/lithium.hpp>
#include <pd/pd_p_api.hpp>
#include <pd/ui7/id.hpp>
#include <pd/ui7/pd_p_api.hpp>
namespace PD {
namespace UI7 {
Executable → Regular
+3 -4
View File
@@ -2,8 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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,14 +24,14 @@ SOFTWARE.
*/
#include <pd/core/core.hpp>
#include <pd/pd_p_api.hpp>
#include <pd/ui7/input_api.hpp>
#include <pd/ui7/pd_p_api.hpp>
#include <pd/ui7/theme.hpp>
#include <pd/ui7/viewport.hpp>
namespace PD {
namespace UI7 {
class PD_UI7_API IO {
class PD_API IO {
public:
IO() {
Time = Timer::New();
Executable → Regular
+17 -18
View File
@@ -2,8 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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,19 +24,19 @@ SOFTWARE.
*/
#include <pd/core/core.hpp>
#include <pd/pd_p_api.hpp>
#include <pd/ui7/container/container.hpp>
#include <pd/ui7/container/dragdata.hpp>
#include <pd/ui7/container/slider.hpp>
#include <pd/ui7/flags.hpp>
#include <pd/ui7/input_api.hpp>
#include <pd/ui7/pd_p_api.hpp>
#include <pd/ui7/theme.hpp>
namespace PD {
namespace UI7 {
class PD_UI7_API Layout {
class PD_API Layout {
public:
Layout(const ID &id, IO::Ref io) : ID(id) {
Layout(const ID& id, IO::Ref io) : ID(id) {
this->IO = io;
DrawList = Li::DrawList::New();
DrawList->SetFont(IO->Font);
@@ -58,9 +57,9 @@ class PD_UI7_API Layout {
* Render a Simple Label
* @param label The text to draw
*/
void Label(const std::string &label);
void Label(const std::string& label);
template <typename... Args>
void Label(std::format_string<Args...> s, Args &&...args) {
void Label(std::format_string<Args...> s, Args&&... args) {
Label(std::format(s, std::forward<Args>(args)...));
}
/**
@@ -68,13 +67,13 @@ class PD_UI7_API Layout {
* @param label The buttons text
* @return if the button was pressed
*/
bool Button(const std::string &label);
bool Button(const std::string& label);
/**
* Render a Checkbox
* @param label Label of the Checkbox
* @param v A value to update
*/
void Checkbox(const std::string &label, bool &v);
void Checkbox(const std::string& label, bool& v);
/**
* Render an Image
* @param img Texture reference of the image
@@ -90,7 +89,7 @@ class PD_UI7_API Layout {
* @param precission Difine the Format string len for float/double
*/
template <typename T>
void DragData(const std::string &label, T *data, size_t num_elms = 1,
void DragData(const std::string& label, T* data, size_t num_elms = 1,
T min = std::numeric_limits<T>::min(),
T max = std::numeric_limits<T>::max(), T step = 1,
int precision = 1) {
@@ -104,7 +103,7 @@ class PD_UI7_API Layout {
AddObject(r);
}
template <typename T>
void Slider(const std::string &label, T *data,
void Slider(const std::string& label, T* data,
T min = std::numeric_limits<T>::min(),
T max = std::numeric_limits<T>::max(), int precision = 1) {
u32 id = Strings::FastHash("drd" + label + std::to_string((uintptr_t)data));
@@ -119,20 +118,20 @@ class PD_UI7_API Layout {
/** SECTION OTHERSTUFF */
const std::string GetName() const { return ID.GetName(); }
const UI7::ID &GetID() const { return this->ID; }
const UI7::ID& GetID() const { return this->ID; }
const fvec2 &GetPosition() const { return Pos; }
void SetPosition(const fvec2 &v) { Pos = v; }
const fvec2 &GetSize() const { return Size; }
void SetSize(const fvec2 &v) { Size = v; }
const fvec2& GetPosition() const { return Pos; }
void SetPosition(const fvec2& v) { Pos = v; }
const fvec2& GetSize() const { return Size; }
void SetSize(const fvec2& v) { Size = v; }
Li::DrawList::Ref GetDrawList() { return DrawList; }
void CursorInit();
void SameLine();
void CursorMove(const fvec2 &size);
void CursorMove(const fvec2& size);
bool ObjectWorkPos(fvec2 &movpos);
bool ObjectWorkPos(fvec2& movpos);
/**
* Extended Object Add Func to Add Object in Front or disable
Executable → Regular
+14 -15
View File
@@ -2,8 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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,18 +24,18 @@ SOFTWARE.
*/
#include <pd/core/core.hpp>
#include <pd/pd_p_api.hpp>
#include <pd/ui7/containers.hpp>
#include <pd/ui7/io.hpp>
#include <pd/ui7/layout.hpp>
#include <pd/ui7/pd_p_api.hpp>
#include "pd/ui7/container/dragdata.hpp"
namespace PD {
namespace UI7 {
class PD_UI7_API Menu {
class PD_API Menu {
public:
Menu(const UI7::ID &id, UI7::IO::Ref pIO);
Menu(const UI7::ID& id, UI7::IO::Ref pIO);
~Menu() {}
PD_SHARED(Menu);
@@ -45,9 +44,9 @@ class PD_UI7_API Menu {
* Render a Simple Label
* @param label The text to draw
*/
void Label(const std::string &label);
void Label(const std::string& label);
template <typename... Args>
void Label(std::format_string<Args...> s, Args &&...args) {
void Label(std::format_string<Args...> s, Args&&... args) {
Label(std::format(s, std::forward<Args>(args)...));
}
/**
@@ -55,13 +54,13 @@ class PD_UI7_API Menu {
* @param label The buttons text
* @return if the button was pressed
*/
bool Button(const std::string &label);
bool Button(const std::string& label);
/**
* Render a Checkbox
* @param label Label of the Checkbox
* @param v A value to update
*/
void Checkbox(const std::string &label, bool &v);
void Checkbox(const std::string& label, bool& v);
/**
* Render an Image
* @param img Texture reference of the image
@@ -77,7 +76,7 @@ class PD_UI7_API Menu {
* @param precission Difine the Format string len for float/double
*/
template <typename T>
void DragData(const std::string &label, T *data, size_t num_elms = 1,
void DragData(const std::string& label, T* data, size_t num_elms = 1,
T min = std::numeric_limits<T>::min(),
T max = std::numeric_limits<T>::max(), T step = 1,
int precision = 1) {
@@ -94,7 +93,7 @@ class PD_UI7_API Menu {
pLayout->AddObject(r);
}
template <typename T>
void Slider(const std::string &label, T *data,
void Slider(const std::string& label, T* data,
T min = std::numeric_limits<T>::min(),
T max = std::numeric_limits<T>::max(), int precision = 1) {
u32 id = Strings::FastHash("drd" + label + std::to_string((uintptr_t)data));
@@ -105,11 +104,11 @@ class PD_UI7_API Menu {
}
pLayout->AddObject(r);
}
void ColorEdit(const std::string &label, u32 &clr);
void ColorEdit(const std::string& label, u32& clr);
void SameLine() { pLayout->SameLine(); }
void Separator();
void SeparatorText(const std::string &label);
bool BeginTreeNode(const ID &id);
void SeparatorText(const std::string& label);
bool BeginTreeNode(const ID& id);
void EndTreeNode();
void HandleFocus();
@@ -131,7 +130,7 @@ class PD_UI7_API Menu {
Layout::Ref pLayout;
IO::Ref pIO;
ID pID;
bool *pIsShown = nullptr;
bool* pIsShown = nullptr;
bool pIsOpen = true;
std::unordered_map<u32, bool> pTreeNodes;
fvec2 TempScrollXY;
+3 -3
View File
@@ -2,7 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -24,7 +24,7 @@ SOFTWARE.
*/
#include <pd/core/core.hpp>
#include <pd/ui7/pd_p_api.hpp>
#include <pd/pd_p_api.hpp>
/**
* Using this to support 32bit color values as well as
@@ -55,7 +55,7 @@ enum UI7Color_ {
namespace PD {
namespace UI7 {
class PD_UI7_API Theme {
class PD_API Theme {
public:
/**
* Default Constructor Setting up the Default theme
Executable → Regular
+4 -5
View File
@@ -2,8 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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,9 +24,9 @@ SOFTWARE.
*/
#include <pd/core/core.hpp>
#include <pd/pd_p_api.hpp>
#include <pd/ui7/io.hpp>
#include <pd/ui7/menu.hpp>
#include <pd/ui7/pd_p_api.hpp>
#include "pd/ui7/flags.hpp"
@@ -46,9 +45,9 @@ namespace UI7 {
* @param show_build Show build num (mostly unused)
* @return Version String (1.0.0-1 for example)
*/
PD_UI7_API std::string GetVersion(bool show_build = false);
PD_API std::string GetVersion(bool show_build = false);
/** Base Context for UI7 */
class PD_UI7_API Context {
class PD_API Context {
public:
Context() { pIO = IO::New(); }
~Context() = default;
+1 -2
View File
@@ -2,8 +2,7 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
-21
View File
@@ -1,21 +0,0 @@
cmake_minimum_required(VERSION 3.22)
project(pd-core LANGUAGES CXX VERSION 0.6.0)
set(SRC
source/bit_util.cpp
source/color.cpp
source/io.cpp
source/mat.cpp
source/strings.cpp
source/timer.cpp
source/timetrace.cpp
)
if(PD_BUILD_SHARED)
pd_add_lib(pd-core BUILD_SHARED TRUE SRC_FILES ${SRC})
else()
pd_add_lib(pd-core SRC_FILES ${SRC})
endif()
target_link_libraries(pd-core PUBLIC pd-drivers)
-13
View File
@@ -1,13 +0,0 @@
cmake_minimum_required(VERSION 3.22)
## The Core Core Library
project(pd-drivers LANGUAGES CXX VERSION 0.6.0)
set(SRC
source/hid.cpp
source/os.cpp
source/gfx.cpp
)
# Only Static Supported
pd_add_lib(pd-drivers SRC_FILES ${SRC})
-39
View File
@@ -1,39 +0,0 @@
#include <pd/drivers/hid.hpp>
#include <pd/drivers/pd_p_api.hpp>
namespace PD {
PD_DEF_EXP(HidDriver::Ref, Hid::pHid);
bool HidDriver::IsEvent(Event e, Key keys) { return KeyEvents[0][e] & keys; }
bool HidDriver::IsEvent(Event e, KbKey keys) {
return KbKeyEvents[0][e].Has(keys);
}
void HidDriver::SwapTab() {
auto tkd = KeyEvents[1][Event_Down];
auto tkh = KeyEvents[1][Event_Held];
auto tku = KeyEvents[1][Event_Up];
KeyEvents[1][Event_Down] = KeyEvents[0][Event_Down];
KeyEvents[1][Event_Held] = KeyEvents[0][Event_Held];
KeyEvents[1][Event_Up] = KeyEvents[0][Event_Up];
KeyEvents[0][Event_Down] = tkd;
KeyEvents[0][Event_Held] = tkh;
KeyEvents[0][Event_Up] = tku;
}
/**
* If this func has no verride, still clear the stats
* cause if they are empty this leads to a crash
*/
void HidDriver::Update() {
// Clear States
for (int i = 0; i < 2; i++) {
KeyEvents[i][Event_Down] = 0;
KeyEvents[i][Event_Held] = 0;
KeyEvents[i][Event_Up] = 0;
for (auto& it : KbKeyEvents[i]) {
it.second = Event_Null;
}
}
}
} // namespace PD
-9
View File
@@ -1,9 +0,0 @@
cmake_minimum_required(VERSION 3.22)
project(pd-external LANGUAGES CXX VERSION 0.5.0)
set(SRC
source/stb.cpp
)
pd_add_lib(pd-external SRC_FILES ${SRC})
-4
View File
@@ -1,4 +0,0 @@
#define STB_IMAGE_IMPLEMENTATION
#include <pd/external/stb_image.h>
#define STB_TRUETYPE_IMPLEMENTATION
#include <pd/external/stb_truetype.h>
-15
View File
@@ -1,15 +0,0 @@
cmake_minimum_required(VERSION 3.22)
project(pd-image LANGUAGES CXX VERSION 0.5.0)
set(SRC
source/image.cpp
source/img_blur.cpp
source/img_convert.cpp
)
if(PD_BUILD_SHARED)
pd_add_lib(pd-image BUILD_SHARED TRUE SRC_FILES ${SRC})
else()
pd_add_lib(pd-image SRC_FILES ${SRC})
endif()
-27
View File
@@ -1,27 +0,0 @@
cmake_minimum_required(VERSION 3.22)
project(pd-lithium LANGUAGES CXX VERSION 0.6.0)
option(PD_LI_INCLUDE_FONTS "Include Fonts" OFF)
set(SRC
source/command.cpp
source/drawlist.cpp
source/font.cpp
source/fonts.cpp
source/renderer.cpp
)
if(PD_BUILD_SHARED)
pd_add_lib(pd-lithium BUILD_SHARED TRUE SRC_FILES ${SRC})
else()
pd_add_lib(pd-lithium SRC_FILES ${SRC})
endif()
if(${PD_LI_INCLUDE_FONTS})
target_compile_definitions(pd-lithium PUBLIC
-DPD_LI_INCLUDE_FONTS=1
)
endif()
target_link_libraries(pd-lithium PUBLIC pd-core)
-81
View File
@@ -1,81 +0,0 @@
#include <pd/lithium/command.hpp>
PD_LITHIUM_API PD::Li::Command::Ref PD::Li::CmdPool::NewCmd() {
if (pPoolIdx >= pPool.size()) {
Resize(pPool.size() + 128);
}
Command::Ref nu = pPool[pPoolIdx++];
nu->Layer = Layer;
nu->Index = pPoolIdx - 1;
return nu;
}
PD_LITHIUM_API void PD::Li::CmdPool::Init(size_t initial_size) {
Resize(initial_size);
}
PD_LITHIUM_API void PD::Li::CmdPool::Deinit() {
for (auto it : pPool) {
Command::Delete(it);
}
pPool.clear();
}
PD_LITHIUM_API void PD::Li::CmdPool::Resize(size_t nulen) {
if (nulen <= pPool.size()) {
return; // no idea yet
}
size_t oldlen = pPool.size();
pPool.resize(nulen);
for (size_t i = oldlen; i < pPool.size(); i++) {
pPool[i] = Command::New();
}
}
PD_LITHIUM_API void PD::Li::CmdPool::Reset() {
for (u32 i = 0; i < pPoolIdx; i++) {
pPool[i]->Clear();
}
pPoolIdx = 0;
}
PD::Li::Command::Ref PD::Li::CmdPool::GetCmd(size_t idx) const {
return pPool[idx];
}
PD::Li::Command::Ref PD::Li::CmdPool::GetCmd(size_t idx) { return pPool[idx]; }
size_t PD::Li::CmdPool::Size() const { return pPoolIdx; }
size_t PD::Li::CmdPool::Cap() const { return pPool.size(); }
PD_LITHIUM_API void PD::Li::CmdPool::Merge(CmdPool& p) {
Copy(p);
p.Reset();
}
PD_LITHIUM_API void PD::Li::CmdPool::Copy(CmdPool& p) {
if (pPoolIdx + p.Size() > pPool.size()) {
Resize(pPoolIdx + p.Size());
}
for (size_t i = 0; i < p.Size(); i++) {
size_t idx = pPoolIdx++;
*pPool[idx] = *p.GetCmd(i);
pPool[idx]->Index = idx;
pPool[idx]->Layer += Layer;
}
}
PD_LITHIUM_API void PD::Li::CmdPool::Sort() {
if (pPoolIdx < 2) return;
std::sort(begin(), end(), pTheOrder);
}
PD_LITHIUM_API bool PD::Li::CmdPool::pTheOrder(const Command::Ref& a,
const Command::Ref& b) {
if (a->Layer == b->Layer) {
if (a->Tex == b->Tex) {
return a->Index < b->Index;
}
return a->Tex < b->Tex;
}
return a->Layer < b->Layer;
}
-29
View File
@@ -1,29 +0,0 @@
cmake_minimum_required(VERSION 3.22)
project(pd-ui7 LANGUAGES CXX VERSION 0.6.0)
set(SRC
source/theme.cpp
source/ui7.cpp
source/io.cpp
source/layout.cpp
source/menu.cpp
source/container/button.cpp
source/container/checkbox.cpp
source/container/coloredit.cpp
source/container/container.cpp
source/container/dragdata.cpp
source/container/dynobj.cpp
source/container/image.cpp
source/container/label.cpp
source/container/slider.cpp
)
if(PD_BUILD_SHARED)
pd_add_lib(pd-ui7 BUILD_SHARED TRUE SRC_FILES ${SRC})
else()
pd_add_lib(pd-ui7 SRC_FILES ${SRC})
endif()
target_link_libraries(pd-ui7 PUBLIC pd-lithium pd-core)
@@ -1,6 +1,6 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -24,8 +24,8 @@ SOFTWARE.
#include <pd/core/bit_util.hpp>
namespace PD::BitUtil {
PD_CORE_API bool IsSingleBit(u32 v) { return v && !(v & (v - 1)); }
PD_CORE_API u32 GetPow2(u32 v) {
PD_API bool IsSingleBit(u32 v) { return v && !(v & (v - 1)); }
PD_API u32 GetPow2(u32 v) {
v--;
v |= v >> 1;
v |= v >> 2;
@@ -1,7 +1,6 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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,7 +24,7 @@ SOFTWARE.
#include <pd/core/color.hpp>
namespace PD {
PD_CORE_API std::string Color::Hex(bool rgba) const {
PD_API std::string Color::Hex(bool rgba) const {
/** Need to int cast (so it is used as num and not char...) */
std::stringstream s;
s << "#";
+6 -6
View File
@@ -1,6 +1,6 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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,7 +25,7 @@ SOFTWARE.
namespace PD {
namespace IO {
PD_CORE_API std::vector<u8> LoadFile2Mem(const std::string& path) {
PD_API std::vector<u8> LoadFile2Mem(const std::string& path) {
std::ifstream iff(path, std::ios::binary);
if (!iff) {
return std::vector<u8>();
@@ -39,7 +39,7 @@ PD_CORE_API std::vector<u8> LoadFile2Mem(const std::string& path) {
return res;
}
PD_CORE_API std::string LoadFile2Str(const std::string& path) {
PD_API std::string LoadFile2Str(const std::string& path) {
std::ifstream iff(path, std::ios::binary);
if (!iff) {
return "";
@@ -53,7 +53,7 @@ PD_CORE_API std::string LoadFile2Str(const std::string& path) {
return ret;
}
PD_CORE_API u32 HashMemory(const std::vector<u8>& data) {
PD_API u32 HashMemory(const std::vector<u8>& data) {
u32 hash = 4477;
for (auto& it : data) {
hash = (hash * 33) + it;
@@ -61,7 +61,7 @@ PD_CORE_API u32 HashMemory(const std::vector<u8>& data) {
return hash;
}
PD_CORE_API void DecompressRLE(std::vector<u8>& data) {
PD_API void DecompressRLE(std::vector<u8>& data) {
if ((data.size() % 2) != 0) {
return;
}
@@ -72,7 +72,7 @@ PD_CORE_API void DecompressRLE(std::vector<u8>& data) {
}
}
PD_CORE_API void CompressRLE(std::vector<u8>& data) {
PD_API void CompressRLE(std::vector<u8>& data) {
if (data.empty()) {
/** No exceptions enabled :( */
return;
+7 -8
View File
@@ -1,7 +1,6 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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,7 +24,7 @@ SOFTWARE.
#include <pd/core/mat.hpp>
namespace PD {
PD_CORE_API Mat4 Mat4::RotateX(float a) {
PD_API Mat4 Mat4::RotateX(float a) {
float c = std::cos(a);
float s = std::sin(a);
Mat4 ret = Identity();
@@ -36,7 +35,7 @@ PD_CORE_API Mat4 Mat4::RotateX(float a) {
return ret;
}
PD_CORE_API Mat4 Mat4::RotateY(float a) {
PD_API Mat4 Mat4::RotateY(float a) {
float c = std::cos(a);
float s = std::sin(a);
Mat4 ret = Identity();
@@ -47,7 +46,7 @@ PD_CORE_API Mat4 Mat4::RotateY(float a) {
return ret;
}
PD_CORE_API Mat4 Mat4::RotateZ(float a) {
PD_API Mat4 Mat4::RotateZ(float a) {
float c = std::cos(a);
float s = std::sin(a);
Mat4 ret = Identity();
@@ -58,7 +57,7 @@ PD_CORE_API Mat4 Mat4::RotateZ(float a) {
return ret;
}
PD_CORE_API Mat4 Mat4::Rotate(fvec3 axis, float a) {
PD_API Mat4 Mat4::Rotate(fvec3 axis, float a) {
float s = std::sin(a);
float c = std::cos(a);
float t = 1.f - c;
@@ -81,7 +80,7 @@ PD_CORE_API Mat4 Mat4::Rotate(fvec3 axis, float a) {
return ret;
}
PD_CORE_API Mat4 Mat4::Perspective(float fov, float aspect, float n, float f) {
PD_API Mat4 Mat4::Perspective(float fov, float aspect, float n, float f) {
float _fov = std::tan(fov / 2.f);
Mat4 ret;
ret(0, 0) = 1.f / (aspect * _fov);
@@ -98,7 +97,7 @@ PD_CORE_API Mat4 Mat4::Perspective(float fov, float aspect, float n, float f) {
return ret;
}
PD_CORE_API Mat4 Mat4::LookAt(const fvec3& pos, const fvec3& center,
PD_API Mat4 Mat4::LookAt(const fvec3& pos, const fvec3& center,
const fvec3& up) {
auto f = fvec3(center - pos).Normalize();
auto s = f.Cross(up).Normalize();
+9 -9
View File
@@ -1,6 +1,6 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -24,7 +24,7 @@ SOFTWARE.
#include <pd/core/strings.hpp>
namespace PD::Strings {
PD_CORE_API bool StringEndsWith(const std::string& str,
PD_API bool StringEndsWith(const std::string& str,
const std::vector<std::string>& exts) {
// Changed order to not do an substr on empty string
if (str.empty()) {
@@ -44,7 +44,7 @@ PD_CORE_API bool StringEndsWith(const std::string& str,
return false;
}
PD_CORE_API std::wstring MakeWstring(const std::string& s) {
PD_API std::wstring MakeWstring(const std::string& s) {
// Manually convert to wstring as they removed wstring_convert :(
std::wstring result;
size_t i = 0;
@@ -85,7 +85,7 @@ PD_CORE_API std::wstring MakeWstring(const std::string& s) {
return result;
}
PD_CORE_API const std::string FormatNanos(unsigned long long nanos) {
PD_API const std::string FormatNanos(unsigned long long nanos) {
// Based on some code of my minecraft plugins
if (nanos < 1000) {
return std::format("{}ns", nanos);
@@ -106,7 +106,7 @@ PD_CORE_API const std::string FormatNanos(unsigned long long nanos) {
return "";
}
PD_CORE_API const std::string FormatMillis(unsigned long long millis) {
PD_API const std::string FormatMillis(unsigned long long millis) {
// Original Code can be found in some of my mv plugins
if (millis < 1000) {
return std::format("{}ms", millis);
@@ -121,7 +121,7 @@ PD_CORE_API const std::string FormatMillis(unsigned long long millis) {
return "";
}
PD_CORE_API const std::string FormatBytes(unsigned long long bytes) {
PD_API const std::string FormatBytes(unsigned long long bytes) {
static const std::vector<std::string> endings = {
"B", "KB", "MB", "GB", "TB", "Unk",
};
@@ -137,7 +137,7 @@ PD_CORE_API const std::string FormatBytes(unsigned long long bytes) {
return std::format("{:.1f} {}", b, endings[i]);
}
PD_CORE_API const std::string GetFileName(const std::string& path,
PD_API const std::string GetFileName(const std::string& path,
const std::string& saperators) {
auto pos = path.find_last_of(saperators);
if (pos != path.npos) {
@@ -147,7 +147,7 @@ PD_CORE_API const std::string GetFileName(const std::string& path,
return path;
}
PD_CORE_API const std::string PathRemoveExtension(const std::string& path) {
PD_API const std::string PathRemoveExtension(const std::string& path) {
auto pos = path.find_last_of('.');
if (pos != path.npos) {
return path.substr(0, pos);
@@ -156,7 +156,7 @@ PD_CORE_API const std::string PathRemoveExtension(const std::string& path) {
return path;
}
PD_CORE_API u32 FastHash(const std::string& s) {
PD_API u32 FastHash(const std::string& s) {
u32 hash = 5381;
for (auto& it : s) {
hash = (hash * 33) + static_cast<u8>(it);
@@ -1,7 +1,6 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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,25 +25,25 @@ SOFTWARE.
#include <pd/drivers/drivers.hpp>
namespace PD {
PD_CORE_API Timer::Timer(bool autostart) {
PD_API Timer::Timer(bool autostart) {
pIsRunning = autostart;
Reset();
}
PD_CORE_API void Timer::Reset() {
PD_API void Timer::Reset() {
pStart = OS::GetTime();
pNow = pStart;
}
PD_CORE_API void Timer::Update() {
PD_API void Timer::Update() {
if (pIsRunning) {
pNow = OS::GetTime();
}
}
PD_CORE_API void Timer::Pause() { pIsRunning = false; }
PD_CORE_API void Timer::Rseume() { pIsRunning = true; }
PD_CORE_API bool Timer::IsRunning() const { return pIsRunning; }
PD_CORE_API u64 Timer::Get() { return pNow - pStart; }
PD_CORE_API double Timer::GetSeconds() { return (double)Get() / 1000.0; }
PD_API void Timer::Pause() { pIsRunning = false; }
PD_API void Timer::Rseume() { pIsRunning = true; }
PD_API bool Timer::IsRunning() const { return pIsRunning; }
PD_API u64 Timer::Get() { return pNow - pStart; }
PD_API double Timer::GetSeconds() { return (double)Get() / 1000.0; }
} // namespace PD
@@ -1,6 +1,6 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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,12 +25,12 @@ SOFTWARE.
#include <pd/drivers/drivers.hpp>
namespace PD::TT {
PD_CORE_API void Beg(const std::string& id) {
PD_API void Beg(const std::string& id) {
auto trace = OS::GetTraceRef(id);
trace->SetStart(PD::OS::GetNanoTime());
}
PD_CORE_API void End(const std::string& id) {
PD_API void End(const std::string& id) {
auto trace = OS::GetTraceRef(id);
trace->SetEnd(PD::OS::GetNanoTime());
}
@@ -1,7 +1,6 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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,10 +22,9 @@ SOFTWARE.
*/
#include <pd/drivers/gfx.hpp>
#include <pd/drivers/pd_p_api.hpp>
namespace PD {
PD_DEF_EXP(GfxDriver::Ref, Gfx::pGfx);
GfxDriver::Ref Gfx::pGfx = nullptr;
void Gfx::Init(GfxDriver::Ref d) {
if (!d) {
+61
View File
@@ -0,0 +1,61 @@
/*
MIT License
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 <pd/drivers/hid.hpp>
namespace PD {
HidDriver::Ref Hid::pHid = nullptr;
bool HidDriver::IsEvent(Event e, Key keys) { return KeyEvents[0][e] & keys; }
bool HidDriver::IsEvent(Event e, KbKey keys) {
return KbKeyEvents[0][e].Has(keys);
}
void HidDriver::SwapTab() {
auto tkd = KeyEvents[1][Event_Down];
auto tkh = KeyEvents[1][Event_Held];
auto tku = KeyEvents[1][Event_Up];
KeyEvents[1][Event_Down] = KeyEvents[0][Event_Down];
KeyEvents[1][Event_Held] = KeyEvents[0][Event_Held];
KeyEvents[1][Event_Up] = KeyEvents[0][Event_Up];
KeyEvents[0][Event_Down] = tkd;
KeyEvents[0][Event_Held] = tkh;
KeyEvents[0][Event_Up] = tku;
}
/**
* If this func has no verride, still clear the stats
* cause if they are empty this leads to a crash
*/
void HidDriver::Update() {
// Clear States
for (int i = 0; i < 2; i++) {
KeyEvents[i][Event_Down] = 0;
KeyEvents[i][Event_Held] = 0;
KeyEvents[i][Event_Up] = 0;
for (auto& it : KbKeyEvents[i]) {
it.second = Event_Null;
}
}
}
} // namespace PD
@@ -1,6 +1,6 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -22,10 +22,9 @@ SOFTWARE.
*/
#include <pd/drivers/os.hpp>
#include <pd/drivers/pd_p_api.hpp>
namespace PD {
PD_DEF_EXP(OsDriver::Ref, OS::pOs);
OsDriver::Ref OS::pOs = nullptr;
TT::Res::Ref& OsDriver::GetTraceRef(const std::string& id) {
if (!pTraces.count(id)) {
@@ -1,8 +1,6 @@
#pragma once
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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,4 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#define PD_DEF_EXP(x, y) x y = nullptr
#define PD_IMAGE_IMPLEMENTATION
#include <pd/external/stb_image.hpp>
#define PD_TRUETYPE_IMPLEMENTATION
#include <pd/external/stb_truetype.hpp>
+21 -24
View File
@@ -1,7 +1,6 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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,49 +22,47 @@ SOFTWARE.
*/
#ifdef PD_IMAGE_BUILD_SHARED
#define STB_IMAGE_IMPLEMENTATION
#define PD_IMAGE_IMPLEMENTATION
#endif
#include <pd/external/stb_image.h>
#include <cstring>
#include <memory>
#include <pd/external/stb_image.hpp>
#include <pd/image/image.hpp>
#include <pd/image/img_convert.hpp>
namespace PD {
PD_IMAGE_API void Image::Load(const std::string& path) {
u8* img = stbi_load(path.c_str(), &pWidth, &pHeight, &fmt, 4);
PD_API void Image::Load(const std::string& path) {
u8* img = pdi_load(path.c_str(), &pWidth, &pHeight, &fmt, 4);
if (fmt == 3) {
stbi_image_free(img);
img = stbi_load(path.c_str(), &pWidth, &pHeight, &fmt, 3);
pdi_image_free(img);
img = pdi_load(path.c_str(), &pWidth, &pHeight, &fmt, 3);
pBuffer = std::vector<PD::u8>(img, img + (pWidth * pHeight * 3));
pFmt = RGB;
stbi_image_free(img);
pdi_image_free(img);
} else if (fmt == 4) {
pBuffer = std::vector<PD::u8>(img, img + (pWidth * pHeight * 4));
pFmt = RGBA;
stbi_image_free(img);
pdi_image_free(img);
}
}
PD_IMAGE_API void Image::Load(const std::vector<u8>& buf) {
PD_API void Image::Load(const std::vector<u8>& buf) {
u8* img =
stbi_load_from_memory(buf.data(), buf.size(), &pWidth, &pHeight, &fmt, 4);
pdi_load_from_memory(buf.data(), buf.size(), &pWidth, &pHeight, &fmt, 4);
if (fmt == 3) {
stbi_image_free(img);
img = stbi_load_from_memory(buf.data(), buf.size(), &pWidth, &pHeight, &fmt,
pdi_image_free(img);
img = pdi_load_from_memory(buf.data(), buf.size(), &pWidth, &pHeight, &fmt,
3);
pBuffer = std::vector<PD::u8>(img, img + (pWidth * pHeight * 3));
pFmt = RGB;
stbi_image_free(img);
pdi_image_free(img);
} else if (fmt == 4) {
pBuffer = std::vector<PD::u8>(img, img + (pWidth * pHeight * 4));
stbi_image_free(img);
pdi_image_free(img);
pFmt = RGBA;
}
}
PD_IMAGE_API void Image::Copy(const std::vector<u8>& buf, int w, int h,
int bpp) {
PD_API void Image::Copy(const std::vector<u8>& buf, int w, int h, int bpp) {
this->fmt = bpp;
if (buf.size() != (size_t)w * h * bpp) {
// Size Error
@@ -77,7 +74,7 @@ PD_IMAGE_API void Image::Copy(const std::vector<u8>& buf, int w, int h,
}
}
PD_IMAGE_API void Image::FlipHorizontal() {
PD_API void Image::FlipHorizontal() {
/**
* Dont know if i am brain dead but i think this code
* should Horizpntal flip an image
@@ -97,7 +94,7 @@ PD_IMAGE_API void Image::FlipHorizontal() {
}
}
PD_IMAGE_API void Image::FlipVertical() {
PD_API void Image::FlipVertical() {
/**
* Dont know if i am brain dead but i think this code
* should Vertical flip an image
@@ -117,7 +114,7 @@ PD_IMAGE_API void Image::FlipVertical() {
}
}
PD_IMAGE_API void Image::Convert(Image::Ref img, Image::Format dst) {
PD_API void Image::Convert(Image::Ref img, Image::Format dst) {
if (img->pFmt == dst) {
return;
} else if (img->pFmt == Image::RGB && dst == Image::BGR) {
@@ -164,7 +161,7 @@ PD_IMAGE_API void Image::Convert(Image::Ref img, Image::Format dst) {
}
}
PD_IMAGE_API int Image::Fmt2Bpp(Format fmt) {
PD_API int Image::Fmt2Bpp(Format fmt) {
switch (fmt) {
case RGBA:
case ABGR:
@@ -184,7 +181,7 @@ PD_IMAGE_API int Image::Fmt2Bpp(Format fmt) {
}
}
PD_IMAGE_API void Image::ReTile(Image::Ref img,
PD_API void Image::ReTile(Image::Ref img,
std::function<u32(int x, int y, int w)> src,
std::function<u32(int x, int y, int w)> dst) {
std::vector<PD::u8> cpy = img->pBuffer;
+10 -13
View File
@@ -1,7 +1,6 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -29,7 +28,7 @@ SOFTWARE.
namespace PD {
namespace ImgBlur {
PD_IMAGE_API std::vector<float> GaussianKernel(int r, float si) {
PD_API std::vector<float> GaussianKernel(int r, float si) {
/// Define radius as r to be shorter
int size = 2 * r + 1;
std::vector<float> kernel(size);
@@ -45,22 +44,20 @@ PD_IMAGE_API std::vector<float> GaussianKernel(int r, float si) {
}
return kernel;
}
PD_IMAGE_API void GaussianBlur(std::vector<u8> &buf, int w, int h, float radius,
float si,
std::function<int(int, int, int)> idxfn) {
PD_API void GaussianBlur(std::vector<u8>& buf, int w, int h, float radius,
float si, std::function<int(int, int, int)> idxfn) {
GaussianBlur(buf.data(), w, h, 4, radius, si, idxfn);
}
PD_IMAGE_API void GaussianBlur(void *buf, int w, int h, int bpp, float radius,
float si,
std::function<int(int, int, int)> idxfn) {
PD_API void GaussianBlur(void* buf, int w, int h, int bpp, float radius,
float si, std::function<int(int, int, int)> idxfn) {
if (bpp != 4 && bpp != 3) {
return;
}
std::vector<float> kernel = GaussianKernel(radius, si);
int hks = kernel.size() / 2;
int end = w * h * bpp;
std::vector<unsigned char> res((u8 *)buf, ((u8 *)buf) + end);
std::vector<unsigned char> res((u8*)buf, ((u8*)buf) + end);
ImgConvert::Reverse32(res, w, h);
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
@@ -72,9 +69,9 @@ PD_IMAGE_API void GaussianBlur(void *buf, int w, int h, int bpp, float radius,
int idx = idxfn(xoff, yoff, w) * 4;
float weight = kernel[ky + hks] * kernel[kx + hks];
r += ((u8 *)buf)[idx] * weight;
g += ((u8 *)buf)[idx + 1] * weight;
b += ((u8 *)buf)[idx + 2] * weight;
r += ((u8*)buf)[idx] * weight;
g += ((u8*)buf)[idx + 1] * weight;
b += ((u8*)buf)[idx + 2] * weight;
}
}
int idx = idxfn(x, y, w) * bpp;
+7 -7
View File
@@ -1,6 +1,6 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 @@ SOFTWARE.
namespace PD::ImgConvert {
PD_IMAGE_API void RGB24toRGBA32(std::vector<u8> &out, const std::vector<u8> &in,
const int &w, const int &h) {
PD_API void RGB24toRGBA32(std::vector<u8>& out, const std::vector<u8>& in,
const int& w, const int& h) {
// Converts RGB24 to RGBA32
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
@@ -40,8 +40,8 @@ PD_IMAGE_API void RGB24toRGBA32(std::vector<u8> &out, const std::vector<u8> &in,
}
}
PD_IMAGE_API void RGB32toRGBA24(std::vector<u8> &out, const std::vector<u8> &in,
const int &w, const int &h) {
PD_API void RGB32toRGBA24(std::vector<u8>& out, const std::vector<u8>& in,
const int& w, const int& h) {
// Converts RGB24 to RGBA32
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
@@ -54,7 +54,7 @@ PD_IMAGE_API void RGB32toRGBA24(std::vector<u8> &out, const std::vector<u8> &in,
}
}
PD_IMAGE_API void Reverse32(std::vector<u8> &buf, const int &w, const int &h) {
PD_API void Reverse32(std::vector<u8>& buf, const int& w, const int& h) {
for (int x = 0; x < w; x++) {
for (int y = 0; y < h; y++) {
int i = y * w + x;
@@ -68,7 +68,7 @@ PD_IMAGE_API void Reverse32(std::vector<u8> &buf, const int &w, const int &h) {
}
}
PD_IMAGE_API void ReverseBuf(std::vector<u8> &buf, size_t bpp, int w, int h) {
PD_API void ReverseBuf(std::vector<u8>& buf, size_t bpp, int w, int h) {
std::vector<u8> cpy = buf;
for (int x = 0; x < w; x++) {
for (int y = 0; y < h; y++) {
+102
View File
@@ -0,0 +1,102 @@
/*
MIT License
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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 <pd/lithium/command.hpp>
PD_API PD::Li::Command::Ref PD::Li::CmdPool::NewCmd() {
if (pPoolIdx >= pPool.size()) {
Resize(pPool.size() + 128);
}
Command::Ref nu = pPool[pPoolIdx++];
nu->Layer = Layer;
nu->Index = pPoolIdx - 1;
return nu;
}
PD_API void PD::Li::CmdPool::Init(size_t initial_size) { Resize(initial_size); }
PD_API void PD::Li::CmdPool::Deinit() {
for (auto it : pPool) {
Command::Delete(it);
}
pPool.clear();
}
PD_API void PD::Li::CmdPool::Resize(size_t nulen) {
if (nulen <= pPool.size()) {
return; // no idea yet
}
size_t oldlen = pPool.size();
pPool.resize(nulen);
for (size_t i = oldlen; i < pPool.size(); i++) {
pPool[i] = Command::New();
}
}
PD_API void PD::Li::CmdPool::Reset() {
for (u32 i = 0; i < pPoolIdx; i++) {
pPool[i]->Clear();
}
pPoolIdx = 0;
}
PD::Li::Command::Ref PD::Li::CmdPool::GetCmd(size_t idx) const {
return pPool[idx];
}
PD::Li::Command::Ref PD::Li::CmdPool::GetCmd(size_t idx) { return pPool[idx]; }
size_t PD::Li::CmdPool::Size() const { return pPoolIdx; }
size_t PD::Li::CmdPool::Cap() const { return pPool.size(); }
PD_API void PD::Li::CmdPool::Merge(CmdPool& p) {
Copy(p);
p.Reset();
}
PD_API void PD::Li::CmdPool::Copy(CmdPool& p) {
if (pPoolIdx + p.Size() > pPool.size()) {
Resize(pPoolIdx + p.Size());
}
for (size_t i = 0; i < p.Size(); i++) {
size_t idx = pPoolIdx++;
*pPool[idx] = *p.GetCmd(i);
pPool[idx]->Index = idx;
pPool[idx]->Layer += Layer;
}
}
PD_API void PD::Li::CmdPool::Sort() {
if (pPoolIdx < 2) return;
std::sort(begin(), end(), pTheOrder);
}
PD_API bool PD::Li::CmdPool::pTheOrder(const Command::Ref& a,
const Command::Ref& b) {
if (a->Layer == b->Layer) {
if (a->Tex == b->Tex) {
return a->Index < b->Index;
}
return a->Tex < b->Tex;
}
return a->Layer < b->Layer;
}
+35 -42
View File
@@ -1,7 +1,6 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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,19 +30,19 @@ SOFTWARE.
namespace PD {
namespace Li {
PD_LITHIUM_API DrawList::DrawList(int initial_size) {
PD_API DrawList::DrawList(int initial_size) {
DrawSolid();
pPool.Init(initial_size);
}
PD_LITHIUM_API DrawList::~DrawList() {
PD_API DrawList::~DrawList() {
Clear();
pPool.Deinit();
}
PD_LITHIUM_API void DrawList::DrawSolid() { CurrentTex = Gfx::GetSolidTex(); }
PD_API void DrawList::DrawSolid() { CurrentTex = Gfx::GetSolidTex(); }
PD_LITHIUM_API void DrawList::Clear() {
PD_API void DrawList::Clear() {
pNumIndices = 0;
pNumVertices = 0;
pPool.Reset();
@@ -56,7 +55,7 @@ PD_LITHIUM_API void DrawList::Clear() {
}
}
PD_LITHIUM_API void DrawList::Merge(DrawList::Ref list) {
PD_API void DrawList::Merge(DrawList::Ref list) {
pPool.Merge(list->pPool);
/*for (size_t i = 0; i < list->pDrawList.size(); i++) {
pNumIndices += list->pDrawList[i]->IndexBuffer.size();
@@ -68,11 +67,9 @@ PD_LITHIUM_API void DrawList::Merge(DrawList::Ref list) {
list->Clear();
}
PD_LITHIUM_API void DrawList::Copy(DrawList::Ref list) {
pPool.Copy(list->pPool);
}
PD_API void DrawList::Copy(DrawList::Ref list) { pPool.Copy(list->pPool); }
PD_LITHIUM_API void DrawList::Optimize() {
PD_API void DrawList::Optimize() {
#ifndef NDEBUG
PD::TT::Scope s("Optimize");
#endif
@@ -88,7 +85,7 @@ PD_LITHIUM_API void DrawList::Optimize() {
});*/
}
PD_LITHIUM_API Command::Ref DrawList::GetNewCmd() {
PD_API Command::Ref DrawList::GetNewCmd() {
Command::Ref cmd = pPool.NewCmd();
cmd->Index = pPool.Size() - 1;
cmd->Tex = CurrentTex->Address;
@@ -96,16 +93,15 @@ PD_LITHIUM_API Command::Ref DrawList::GetNewCmd() {
return cmd;
}
PD_LITHIUM_API void DrawList::pClipCmd(Command::Ref cmd) {
PD_API void DrawList::pClipCmd(Command::Ref cmd) {
if (!pClipRects.empty()) {
cmd->ScissorOn = true;
cmd->ScissorRect = ivec4(pClipRects.top());
}
}
PD_LITHIUM_API void DrawList::PathArcToN(const fvec2& c, float radius,
float a_min, float a_max,
int segments) {
PD_API void DrawList::PathArcToN(const fvec2& c, float radius, float a_min,
float a_max, int segments) {
// Path.push_back(c);
PathReserve(segments + 1);
for (int i = 0; i < segments; i++) {
@@ -114,8 +110,8 @@ PD_LITHIUM_API void DrawList::PathArcToN(const fvec2& c, float radius,
}
}
PD_LITHIUM_API void DrawList::PathFastArcToN(const fvec2& c, float r,
float amin, float amax, int s) {
PD_API void DrawList::PathFastArcToN(const fvec2& c, float r, float amin,
float amax, int s) {
/**
* Funcion with less division overhead
* Usefull for stuff where a lot of calculations are required
@@ -128,7 +124,7 @@ PD_LITHIUM_API void DrawList::PathFastArcToN(const fvec2& c, float r,
}
}
PD_LITHIUM_API void DrawList::PathRect(fvec2 a, fvec2 b, float rounding) {
PD_API void DrawList::PathRect(fvec2 a, fvec2 b, float rounding) {
if (rounding == 0.f) {
PathAdd(a);
PathAdd(vec2(b.x, a.y));
@@ -160,8 +156,7 @@ PD_LITHIUM_API void DrawList::PathRect(fvec2 a, fvec2 b, float rounding) {
}
}
PD_LITHIUM_API void DrawList::PathRectEx(fvec2 a, fvec2 b, float rounding,
u32 flags) {
PD_API void DrawList::PathRectEx(fvec2 a, fvec2 b, float rounding, u32 flags) {
if (rounding == 0.f) {
PathAdd(a);
PathAdd(vec2(b.x, a.y));
@@ -210,8 +205,8 @@ PD_LITHIUM_API void DrawList::PathRectEx(fvec2 a, fvec2 b, float rounding,
}
}
PD_LITHIUM_API void DrawList::DrawRect(const fvec2& pos, const fvec2& size,
u32 color, int thickness) {
PD_API void DrawList::DrawRect(const fvec2& pos, const fvec2& size, u32 color,
int thickness) {
PathRect(pos, pos + size);
// Flags is currently hardcoded (1 = close)
PathStroke(color, thickness, 1);
@@ -221,16 +216,15 @@ void DrawList::DrawRectFilled(const fvec2& pos, const fvec2& size, u32 color) {
PathFill(color);
}
PD_LITHIUM_API void DrawList::DrawTriangle(const fvec2& a, const fvec2& b,
const fvec2& c, u32 color,
int thickness) {
PD_API void DrawList::DrawTriangle(const fvec2& a, const fvec2& b,
const fvec2& c, u32 color, int thickness) {
PathAdd(a);
PathAdd(b);
PathAdd(c);
PathStroke(color, thickness, 1);
}
PD_LITHIUM_API void DrawList::DrawTriangleFilled(const fvec2& a, const fvec2& b,
PD_API void DrawList::DrawTriangleFilled(const fvec2& a, const fvec2& b,
const fvec2& c, u32 color) {
PathAdd(a);
PathAdd(b);
@@ -238,9 +232,8 @@ PD_LITHIUM_API void DrawList::DrawTriangleFilled(const fvec2& a, const fvec2& b,
PathFill(color);
}
PD_LITHIUM_API void DrawList::DrawCircle(const fvec2& center, float rad,
u32 color, int num_segments,
int thickness) {
PD_API void DrawList::DrawCircle(const fvec2& center, float rad, u32 color,
int num_segments, int thickness) {
if (num_segments <= 0) {
// Auto Segment
} else {
@@ -251,7 +244,7 @@ PD_LITHIUM_API void DrawList::DrawCircle(const fvec2& center, float rad,
PathStroke(color, thickness, (1 << 0));
}
PD_LITHIUM_API void DrawList::DrawCircleFilled(const fvec2& center, float rad,
PD_API void DrawList::DrawCircleFilled(const fvec2& center, float rad,
u32 color, int num_segments) {
if (num_segments <= 0) {
// Auto Segment
@@ -263,8 +256,8 @@ PD_LITHIUM_API void DrawList::DrawCircleFilled(const fvec2& center, float rad,
}
// TODO: Don't render OOS
PD_LITHIUM_API void DrawList::DrawPolyLine(const std::vector<fvec2>& points,
u32 clr, u32 flags, int thickness) {
PD_API void DrawList::DrawPolyLine(const std::vector<fvec2>& points, u32 clr,
u32 flags, int thickness) {
if (points.size() < 2) {
return;
}
@@ -284,8 +277,8 @@ PD_LITHIUM_API void DrawList::DrawPolyLine(const std::vector<fvec2>& points,
}
}
PD_LITHIUM_API void DrawList::DrawConvexPolyFilled(
const std::vector<fvec2>& points, u32 clr) {
PD_API void DrawList::DrawConvexPolyFilled(const std::vector<fvec2>& points,
u32 clr) {
if (points.size() < 3) {
return; // Need at least three points
}
@@ -293,25 +286,25 @@ PD_LITHIUM_API void DrawList::DrawConvexPolyFilled(
Renderer::CmdConvexPolyFilled(cmd, points, clr, CurrentTex);
}
PD_LITHIUM_API void DrawList::DrawText(const fvec2& pos,
const std::string& text, u32 color) {
PD_API void DrawList::DrawText(const fvec2& pos, const std::string& text,
u32 color) {
if (!pCurrentFont) {
return;
}
pCurrentFont->CmdTextEx(pPool, pos, color, pFontScale, text);
}
PD_LITHIUM_API void DrawList::DrawTextEx(const fvec2& p,
const std::string& text, u32 color,
LiTextFlags flags, const fvec2& box) {
PD_API void DrawList::DrawTextEx(const fvec2& p, const std::string& text,
u32 color, LiTextFlags flags,
const fvec2& box) {
if (!pCurrentFont) {
return;
}
pCurrentFont->CmdTextEx(pPool, p, color, pFontScale, text, flags, box);
}
PD_LITHIUM_API void DrawList::DrawLine(const fvec2& a, const fvec2& b,
u32 color, int t) {
PD_API void DrawList::DrawLine(const fvec2& a, const fvec2& b, u32 color,
int t) {
PathAdd(a);
PathAdd(b);
PathStroke(color, t);
+23 -27
View File
@@ -1,7 +1,6 @@
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Copyright (c) 2024 - 2026 René Amthor (tobid7)
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,10 +25,9 @@ SOFTWARE.
/** Due to Limitations of Shared Lib Stuff */
#ifdef PD_LITHIUM_BUILD_SHARED
#define STB_TRUETYPE_IMPLEMENTATION
#define PD_TRUETYPE_IMPLEMENTATION
#endif
#include <pd/external/stb_truetype.h>
#include <pd/external/stb_truetype.hpp>
#include <pd/lithium/renderer.hpp>
#ifdef PD_LI_INCLUDE_FONTS
@@ -38,7 +36,7 @@ SOFTWARE.
namespace PD {
namespace Li {
PD_LITHIUM_API void Font::LoadDefaultFont(int id, int pixel_height) {
PD_API void Font::LoadDefaultFont(int id, int pixel_height) {
#ifdef PD_LI_INCLUDE_FONTS
if (id < pNumFonts) {
auto font = pFontData[id];
@@ -49,7 +47,7 @@ PD_LITHIUM_API void Font::LoadDefaultFont(int id, int pixel_height) {
#endif
}
PD_LITHIUM_API void Font::LoadTTF(const std::string& path, int height) {
PD_API void Font::LoadTTF(const std::string& path, int height) {
/**
* Just use LoadFile2Mem which looks way cleaner
* and helps not having the font loading code twice
@@ -60,15 +58,15 @@ PD_LITHIUM_API void Font::LoadTTF(const std::string& path, int height) {
LoadTTF(font, height);
}
PD_LITHIUM_API void Font::pMakeAtlas(bool final, std::vector<u8>& font_tex,
int texszs, PD::Li::Texture::Ref tex) {
PD_API void Font::pMakeAtlas(bool final, std::vector<u8>& font_tex, int texszs,
PD::Li::Texture::Ref tex) {
auto t =
Gfx::LoadTex(font_tex, texszs, texszs, Texture::RGBA32, Texture::LINEAR);
tex->CopyFrom(t);
Textures.push_back(tex);
}
PD_LITHIUM_API void Font::LoadTTF(const std::vector<u8>& data, int height) {
PD_API void Font::LoadTTF(const std::vector<u8>& data, int height) {
/**
* Some additional Info:
* Removed the stbtt get bitmapbox as we dont need to place
@@ -81,15 +79,15 @@ PD_LITHIUM_API void Font::LoadTTF(const std::vector<u8>& data, int height) {
texszs = 1024; // Max size
}
stbtt_fontinfo inf;
if (!stbtt_InitFont(&inf, data.data(), 0)) {
pdtt_fontinfo inf;
if (!pdtt_InitFont(&inf, data.data(), 0)) {
return;
}
float scale = stbtt_ScaleForPixelHeight(&inf, PixelHeight);
float scale = pdtt_ScaleForPixelHeight(&inf, PixelHeight);
int ascent, descent, lineGap;
stbtt_GetFontVMetrics(&inf, &ascent, &descent, &lineGap);
pdtt_GetFontVMetrics(&inf, &ascent, &descent, &lineGap);
int baseline = static_cast<int>(ascent * scale);
// Cache to not render same codepoint tex twice
@@ -102,13 +100,13 @@ PD_LITHIUM_API void Font::LoadTTF(const std::vector<u8>& data, int height) {
bool empty = true;
for (u32 ii = 0x0000; ii <= 0xFFFF; ii++) {
int gi = stbtt_FindGlyphIndex(&inf, ii);
int gi = pdtt_FindGlyphIndex(&inf, ii);
if (gi == 0) continue;
if (stbtt_IsGlyphEmpty(&inf, gi)) continue;
if (pdtt_IsGlyphEmpty(&inf, gi)) continue;
int w = 0, h = 0, xo = 0, yo = 0;
unsigned char* bitmap =
stbtt_GetCodepointBitmap(&inf, scale, scale, ii, &w, &h, &xo, &yo);
pdtt_GetCodepointBitmap(&inf, scale, scale, ii, &w, &h, &xo, &yo);
if (!bitmap || w <= 0 || h <= 0) {
if (bitmap) free(bitmap);
continue;
@@ -184,7 +182,7 @@ PD_LITHIUM_API void Font::LoadTTF(const std::vector<u8>& data, int height) {
}
}
PD_LITHIUM_API Font::Codepoint& Font::GetCodepoint(u32 cp) {
PD_API Font::Codepoint& Font::GetCodepoint(u32 cp) {
// Check if codepoijt exist or return a static invalid one
auto res = CodeMap.find(cp);
if (res == CodeMap.end()) {
@@ -195,7 +193,7 @@ PD_LITHIUM_API Font::Codepoint& Font::GetCodepoint(u32 cp) {
return res->second;
}
PD_LITHIUM_API fvec2 Font::GetTextBounds(const std::string& text, float scale) {
PD_API fvec2 Font::GetTextBounds(const std::string& text, float scale) {
u32 id = PD::FNV1A32(text);
if (pTMS.find(id) != pTMS.end()) {
pTMS[id].TimeStamp = PD::OS::GetTime();
@@ -248,7 +246,7 @@ PD_LITHIUM_API fvec2 Font::GetTextBounds(const std::string& text, float scale) {
return res;
}
PD_LITHIUM_API void Font::CmdTextEx(CmdPool& cmds, const fvec2& pos, u32 color,
PD_API void Font::CmdTextEx(CmdPool& cmds, const fvec2& pos, u32 color,
float scale, const std::string& text,
LiTextFlags flags, const fvec2& box) {
fvec2 off;
@@ -337,9 +335,8 @@ PD_LITHIUM_API void Font::CmdTextEx(CmdPool& cmds, const fvec2& pos, u32 color,
}
}
PD_LITHIUM_API std::string Font::pWrapText(const std::string& txt, float scale,
const PD::fvec2& max,
PD::fvec2& dim) {
PD_API std::string Font::pWrapText(const std::string& txt, float scale,
const PD::fvec2& max, PD::fvec2& dim) {
u32 id = PD::FNV1A32(txt);
if (pTMS.find(id) != pTMS.end()) {
if (pTMS[id].Text.size()) {
@@ -374,9 +371,8 @@ PD_LITHIUM_API std::string Font::pWrapText(const std::string& txt, float scale,
return ret;
}
PD_LITHIUM_API std::string Font::pShortText(const std::string& txt, float scale,
const PD::fvec2& max,
PD::fvec2& dim) {
PD_API std::string Font::pShortText(const std::string& txt, float scale,
const PD::fvec2& max, PD::fvec2& dim) {
u32 id = PD::FNV1A32(txt);
if (pTMS.find(id) != pTMS.end()) {
if (pTMS[id].Text.size()) {
@@ -418,7 +414,7 @@ PD_LITHIUM_API std::string Font::pShortText(const std::string& txt, float scale,
return ret;
}
PD_LITHIUM_API void Font::CleanupTMS() {
PD_API void Font::CleanupTMS() {
u64 t = PD::OS::GetTime();
for (auto it = pTMS.begin(); it != pTMS.end();) {
if (t - it->second.TimeStamp > 1000) {
@@ -1,6 +1,6 @@
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Copyright (c) 2024 - 2026 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

Some files were not shown because too many files have changed in this diff Show More