Unfiy all sub projects back into 1 libpalladium

This commit is contained in:
2026-01-25 20:44:52 +01:00
parent d2806b2061
commit 337c016824
49 changed files with 3263 additions and 3321 deletions

View File

@@ -8,7 +8,7 @@ set(PD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
include(cmake/palladium.cmake) include(cmake/palladium.cmake)
option(PD_BUILD_TESTS "Sets if TestApp and TestBench get build" OFF) 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) option(PD_BUILD_TOOLS "Build Palladium Tools" OFF)
if(${PD_BUILD_TOOLS}) if(${PD_BUILD_TOOLS})
@@ -16,21 +16,79 @@ if(${PD_BUILD_TOOLS})
endif() endif()
# # Include Library Source # # Include Library Source
set(PD_SOURCES
add_subdirectory(pd/drivers) # Core
add_subdirectory(pd/core) source/core/bit_util.cpp
add_subdirectory(pd/image) source/core/color.cpp
add_subdirectory(pd/external) source/core/io.cpp
add_subdirectory(pd/lithium) source/core/mat.cpp
add_subdirectory(pd/ui7) source/core/strings.cpp
source/core/timer.cpp
source/core/timetrace.cpp
add_library(palladium INTERFACE) # Drivers
target_link_libraries(palladium INTERFACE source/drivers/gfx.cpp
pd-core pd-image pd-external pd-lithium pd-ui7 #pd-net 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 if(${PD_BUILD_SHARED})
pd-drivers pd-core pd-image pd-external pd-lithium pd-ui7 #pd-net add_library(palladium SHARED ${PD_SOURCES})
) else()
add_library(palladium STATIC ${PD_SOURCES})
endif()
target_include_directories(palladium PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
install(DIRECTORY include DESTINATION ".") 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
)
message(STATUS "Files to format: ${PD_FMTFILES}")
add_custom_target(pd-clang-format
COMMAND ${CLANG_FORMAT} --style=file -i ${PD_FMTFILES}
COMMENT "Formatting Project Sources"
)

0
include/pd/core/timetrace.hpp Executable file → Normal file
View File

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

0
include/pd/image/img_blur.hpp Executable file → Normal file
View File

0
include/pd/image/img_convert.hpp Executable file → Normal file
View File

0
include/pd/ui7/layout.hpp Executable file → Normal file
View File

0
include/pd/ui7/menu.hpp Executable file → Normal file
View File

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)

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

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

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>

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

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)

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)

4
source/external/stb.cpp vendored Executable file
View File

@@ -0,0 +1,4 @@
#define PD_IMAGE_IMPLEMENTATION
#include <pd/external/stb_image.hpp>
#define PD_TRUETYPE_IMPLEMENTATION
#include <pd/external/stb_truetype.hpp>

25
pd/image/source/image.cpp → source/image/image.cpp Executable file → Normal file
View File

@@ -23,44 +23,43 @@ SOFTWARE.
*/ */
#ifdef PD_IMAGE_BUILD_SHARED #ifdef PD_IMAGE_BUILD_SHARED
#define STB_IMAGE_IMPLEMENTATION #define PD_IMAGE_IMPLEMENTATION
#endif #endif
#include <pd/external/stb_image.h>
#include <cstring> #include <cstring>
#include <memory> #include <memory>
#include <pd/external/stb_image.hpp>
#include <pd/image/image.hpp> #include <pd/image/image.hpp>
#include <pd/image/img_convert.hpp> #include <pd/image/img_convert.hpp>
namespace PD { namespace PD {
PD_IMAGE_API void Image::Load(const std::string& path) { PD_IMAGE_API void Image::Load(const std::string& path) {
u8* img = stbi_load(path.c_str(), &pWidth, &pHeight, &fmt, 4); u8* img = pdi_load(path.c_str(), &pWidth, &pHeight, &fmt, 4);
if (fmt == 3) { if (fmt == 3) {
stbi_image_free(img); pdi_image_free(img);
img = stbi_load(path.c_str(), &pWidth, &pHeight, &fmt, 3); img = pdi_load(path.c_str(), &pWidth, &pHeight, &fmt, 3);
pBuffer = std::vector<PD::u8>(img, img + (pWidth * pHeight * 3)); pBuffer = std::vector<PD::u8>(img, img + (pWidth * pHeight * 3));
pFmt = RGB; pFmt = RGB;
stbi_image_free(img); pdi_image_free(img);
} else if (fmt == 4) { } else if (fmt == 4) {
pBuffer = std::vector<PD::u8>(img, img + (pWidth * pHeight * 4)); pBuffer = std::vector<PD::u8>(img, img + (pWidth * pHeight * 4));
pFmt = RGBA; pFmt = RGBA;
stbi_image_free(img); pdi_image_free(img);
} }
} }
PD_IMAGE_API void Image::Load(const std::vector<u8>& buf) { PD_IMAGE_API void Image::Load(const std::vector<u8>& buf) {
u8* img = 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) { if (fmt == 3) {
stbi_image_free(img); pdi_image_free(img);
img = stbi_load_from_memory(buf.data(), buf.size(), &pWidth, &pHeight, &fmt, img = pdi_load_from_memory(buf.data(), buf.size(), &pWidth, &pHeight, &fmt,
3); 3);
pBuffer = std::vector<PD::u8>(img, img + (pWidth * pHeight * 3)); pBuffer = std::vector<PD::u8>(img, img + (pWidth * pHeight * 3));
pFmt = RGB; pFmt = RGB;
stbi_image_free(img); pdi_image_free(img);
} else if (fmt == 4) { } else if (fmt == 4) {
pBuffer = std::vector<PD::u8>(img, img + (pWidth * pHeight * 4)); pBuffer = std::vector<PD::u8>(img, img + (pWidth * pHeight * 4));
stbi_image_free(img); pdi_image_free(img);
pFmt = RGBA; pFmt = RGBA;
} }
} }

View File

View File

19
pd/lithium/source/font.cpp → source/lithium/font.cpp Executable file → Normal file
View File

@@ -26,10 +26,9 @@ SOFTWARE.
/** Due to Limitations of Shared Lib Stuff */ /** Due to Limitations of Shared Lib Stuff */
#ifdef PD_LITHIUM_BUILD_SHARED #ifdef PD_LITHIUM_BUILD_SHARED
#define STB_TRUETYPE_IMPLEMENTATION #define PD_TRUETYPE_IMPLEMENTATION
#endif #endif
#include <pd/external/stb_truetype.h> #include <pd/external/stb_truetype.hpp>
#include <pd/lithium/renderer.hpp> #include <pd/lithium/renderer.hpp>
#ifdef PD_LI_INCLUDE_FONTS #ifdef PD_LI_INCLUDE_FONTS
@@ -81,15 +80,15 @@ PD_LITHIUM_API void Font::LoadTTF(const std::vector<u8>& data, int height) {
texszs = 1024; // Max size texszs = 1024; // Max size
} }
stbtt_fontinfo inf; pdtt_fontinfo inf;
if (!stbtt_InitFont(&inf, data.data(), 0)) { if (!pdtt_InitFont(&inf, data.data(), 0)) {
return; return;
} }
float scale = stbtt_ScaleForPixelHeight(&inf, PixelHeight); float scale = pdtt_ScaleForPixelHeight(&inf, PixelHeight);
int ascent, descent, lineGap; int ascent, descent, lineGap;
stbtt_GetFontVMetrics(&inf, &ascent, &descent, &lineGap); pdtt_GetFontVMetrics(&inf, &ascent, &descent, &lineGap);
int baseline = static_cast<int>(ascent * scale); int baseline = static_cast<int>(ascent * scale);
// Cache to not render same codepoint tex twice // Cache to not render same codepoint tex twice
@@ -102,13 +101,13 @@ PD_LITHIUM_API void Font::LoadTTF(const std::vector<u8>& data, int height) {
bool empty = true; bool empty = true;
for (u32 ii = 0x0000; ii <= 0xFFFF; ii++) { for (u32 ii = 0x0000; ii <= 0xFFFF; ii++) {
int gi = stbtt_FindGlyphIndex(&inf, ii); int gi = pdtt_FindGlyphIndex(&inf, ii);
if (gi == 0) continue; 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; int w = 0, h = 0, xo = 0, yo = 0;
unsigned char* bitmap = 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 || w <= 0 || h <= 0) {
if (bitmap) free(bitmap); if (bitmap) free(bitmap);
continue; continue;

0
pd/ui7/source/ui7.cpp → source/ui7/ui7.cpp Executable file → Normal file
View File