# split pd-maths into pd-core and pd-image (0.2.3)

This commit is contained in:
tobid7 2025-02-28 21:14:20 +01:00
parent debedf59c6
commit af3d3e0b5b
32 changed files with 81 additions and 113 deletions

View File

@ -42,7 +42,7 @@ execute_process(
)
# Set Project
project(palladium LANGUAGES C CXX VERSION 0.2.2)
project(palladium LANGUAGES C CXX VERSION 0.2.3)
option(PD_BUILD_TESTS "Sets if TestApp and TestBench get build" OFF)
@ -57,32 +57,31 @@ set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-psabi -O2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS} -fno-rtti -fno-exceptions")
## Core Source Code
set(CORE_SRC
source/core/common.cpp
source/core/bit_util.cpp
source/core/color.cpp
source/core/io.cpp
source/core/strings.cpp
source/core/sys.cpp
source/core/timer.cpp
source/core/timetrace.cpp)
add_pd_lib(pd-core SRC_FILES ${CORE_SRC})
set(MATHS_SRC
source/maths/bit_util.cpp
source/maths/color.cpp
source/maths/img_blur.cpp
source/maths/img_convert.cpp)
add_pd_lib(pd-maths SRC_FILES ${MATHS_SRC} DEPENDS pd-core)
## Image Source Code
set(IMAGE_SRC
source/image/img_blur.cpp
source/image/img_convert.cpp)
## External Source Code
set(EXTERNAL_SRC
source/external/stb.cpp)
add_pd_lib(pd-external SRC_FILES ${EXTERNAL_SRC})
## Drivers Source Code
set(DRVS_SRC
source/drivers/hid.cpp)
add_pd_lib(pd-drivers SRC_FILES ${DRVS_SRC} DEPENDS pd-maths)
## Lib3ds Source Code
set(L3DS_SRC
source/lib3ds/gamepad_icons.cpp
source/lib3ds/result_decoder.cpp
@ -90,8 +89,7 @@ source/lib3ds/drv_hid.cpp
source/lib3ds/hwinfo.cpp
source/lib3ds/os.cpp)
add_pd_lib(pd-lib3ds SRC_FILES ${L3DS_SRC} DEPENDS pd-drivers)
## Lithium Source Code
set(LI_SRC
source/lithium/li7_shader.cpp
source/lithium/spritesheet.cpp
@ -100,13 +98,11 @@ source/lithium/font.cpp
source/lithium/objects.cpp
source/lithium/renderer.cpp)
add_pd_lib(pd-lithium SRC_FILES ${LI_SRC} DEPENDS pd-maths pd-external citro3d)
## Sounbd Source Code
set(SOUND_SRC
source/sound/mp3.cpp)
add_pd_lib(pd-sound SRC_FILES ${SOUND_SRC} DEPENDS pd-core mpg123)
## Overlay source Code
set(OVL_SRC
source/overlays/keyboard.cpp
source/overlays/message_mgr.cpp
@ -114,15 +110,13 @@ source/overlays/overlay_mgr.cpp
source/overlays/performance.cpp
source/overlays/settings.cpp)
add_pd_lib(pd-overlays SRC_FILES ${OVL_SRC} DEPENDS pd-lithium)
## App Source Code
set(APP_SRC
source/app/app.cpp
source/app/lang.cpp
source/app/error.cpp)
add_pd_lib(pd-app SRC_FILES ${APP_SRC} DEPENDS pd-overlays pd-drivers pd-lib3ds)
## UI7 Source Code
set(UI7_SRC
source/ui7/drawlist.cpp
source/ui7/menu.cpp
@ -134,27 +128,37 @@ source/ui7/container/checkbox.cpp
source/ui7/container/image.cpp
source/ui7/container/label.cpp)
#### Creating the Libraries (if activated) ####
add_pd_lib(pd-core SRC_FILES ${CORE_SRC})
add_pd_lib(pd-image SRC_FILES ${IMAGE_SRC} DEPENDS pd-core)
add_pd_lib(pd-external SRC_FILES ${EXTERNAL_SRC})
add_pd_lib(pd-drivers SRC_FILES ${DRVS_SRC} DEPENDS pd-core)
add_pd_lib(pd-lib3ds SRC_FILES ${L3DS_SRC} DEPENDS pd-drivers)
add_pd_lib(pd-lithium SRC_FILES ${LI_SRC} DEPENDS pd-core pd-image pd-external citro3d)
add_pd_lib(pd-sound SRC_FILES ${SOUND_SRC} DEPENDS pd-core mpg123)
add_pd_lib(pd-overlays SRC_FILES ${OVL_SRC} DEPENDS pd-lithium)
add_pd_lib(pd-app SRC_FILES ${APP_SRC} DEPENDS pd-overlays pd-drivers pd-lib3ds)
add_pd_lib(pd-ui7 SRC_FILES ${UI7_SRC} DEPENDS pd-drivers pd-lithium)
add_library(palladium INTERFACE)
target_link_libraries(palladium INTERFACE
pd-core pd-maths pd-external pd-drivers pd-lib3ds
pd-core pd-image pd-external pd-drivers pd-lib3ds
pd-lithium pd-overlays pd-app pd-ui7
)
add_dependencies(palladium
pd-core pd-maths pd-external pd-drivers
pd-core pd-image pd-external pd-drivers
pd-lib3ds pd-lithium pd-overlays pd-app pd-ui7
)
add_library(palladium-lite INTERFACE)
target_link_libraries(palladium-lite INTERFACE
pd-core pd-maths pd-external pd-drivers pd-lib3ds
pd-core pd-image pd-external pd-drivers pd-lib3ds
pd-lithium
)
add_dependencies(palladium-lite
pd-core pd-maths pd-external pd-drivers
pd-core pd-image pd-external pd-drivers
pd-lib3ds pd-lithium
)

View File

@ -27,17 +27,17 @@ make install
| Name | Last Updated | Platform | Depends |
|---|---|---|---|
| pd-core | 0.2.2 | multi | none |
| pd-maths | 0.2.0 | multi | pd-core |
| pd-core | 0.2.3 | multi | none |
| pd-external | 0.1.0 | multi | none |
| pd-drivers | 0.2.1 | multi | pd-core, pd-maths |
| pd-lib3ds | 0.2.2 | 3ds | pd-core, pd-maths, pd-drivers |
| pd-image | 0.2.3 | multi | pd-core |
| pd-drivers | 0.2.1 | multi | pd-core |
| pd-lib3ds | 0.2.2 | 3ds | pd-core, pd-drivers |
| pd-net | 0.2.2 | 3ds | pd-core, pd-lib3ds |
| pd-lithium | 0.2.1 | 3ds | pd-core, pd-maths pd-lib3ds, citro3d |
| pd-lithium | 0.2.1 | 3ds | pd-core, pd-image pd-lib3ds, citro3d |
| pd-sound | 0.2.2 | 3ds | pd-core, mpg123 |
| pd-overlays | 0.2.1 | 3ds | pd-core, pd-maths, pd-lib3ds, pd-lithium, pd-ui7 |
| pd-ui7 | 0.2.2 | 3ds | pd-core, pd-maths, pd-lib3ds, pd-lithium |
| pd-app | 0.2.2 | 3ds | pd-core, pd-maths, pd-lib3ds, pd-lithium |
| pd-overlays | 0.2.1 | 3ds | pd-core, pd-image, pd-lib3ds, pd-lithium, pd-ui7 |
| pd-ui7 | 0.2.2 | 3ds | pd-core, pd-image, pd-lib3ds, pd-lithium |
| pd-app | 0.2.2 | 3ds | pd-core, pd-image, pd-lib3ds, pd-lithium |
## Credits
| Icon | Username | Description |

View File

@ -25,21 +25,21 @@ SOFTWARE.
*/
// Core
#include <pd/core/bit_util.hpp>
#include <pd/core/color.hpp>
#include <pd/core/common.hpp>
#include <pd/core/io.hpp>
#include <pd/core/strings.hpp>
#include <pd/core/sys.hpp>
#include <pd/core/timer.hpp>
#include <pd/core/timetrace.hpp>
#include <pd/core/vec.hpp>
// Graphics
#include <pd/lithium/renderer.hpp>
#include <pd/lithium/spritesheet.hpp>
// Maths
#include <pd/maths/bit_util.hpp>
#include <pd/maths/color.hpp>
#include <pd/maths/img_blur.hpp>
#include <pd/maths/img_convert.hpp>
#include <pd/maths/vec.hpp>
// Image
#include <pd/image/img_blur.hpp>
#include <pd/image/img_convert.hpp>
// Drivers
#include <pd/drivers/hid.hpp>
// Overlays

View File

@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/maths/vec.hpp>
#include <pd/core/vec.hpp>
namespace PD {
template <typename T>

View File

@ -24,7 +24,7 @@ SOFTWARE.
*/
#include <pd/core/common.hpp>
#include <pd/maths/vec.hpp>
#include <pd/core/vec.hpp>
namespace PD {
class Hid : public SmartCtor<Hid> {

View File

@ -25,8 +25,7 @@ SOFTWARE.
*/
#include <pd/core/common.hpp>
#include <pd/maths/img.hpp>
#include <pd/maths/vec.hpp>
#include <pd/core/vec.hpp>
namespace PD {
namespace ImgBlur {
@ -38,8 +37,11 @@ std::vector<float> GaussianKernel(int radius, float si);
/// @param radius // Blur radius
/// @param si // Blur sigma
/// @param idxfn // Indexing function (if buffer is 3ds tiled)
void GaussianBlur(std::vector<u8> &buf, int w, int h, float radius, float si,
std::function<int(int, int, int)> idxfn = Img::IndexDefault);
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;
});
/// @brief Advanced func to access memory directly
/// @param buf Referenvce to the buffer
/// @param w // width of the image
@ -48,7 +50,10 @@ void GaussianBlur(std::vector<u8> &buf, int w, int h, float radius, float si,
/// @param radius // Blur radius
/// @param si // Blur sigma
/// @param idxfn // Indexing function (if buffer is 3ds tiled)
void GaussianBlur(void *buf, int w, int h, int bpp, float radius, float si,
std::function<int(int, int, int)> idxfn = Img::IndexDefault);
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;
});
} // namespace ImgBlur
} // namespace PD

View File

@ -28,7 +28,7 @@ SOFTWARE.
#include <pd/lithium/flags.hpp>
#include <pd/lithium/texture.hpp>
#include <pd/lithium/vertex.hpp>
#include <pd/maths/vec.hpp>
#include <pd/core/vec.hpp>
namespace PD {
namespace LI {

View File

@ -27,7 +27,7 @@ SOFTWARE.
#include <pd/core/common.hpp>
#include <pd/lithium/rect.hpp>
#include <pd/lithium/texture.hpp>
#include <pd/maths/vec.hpp>
#include <pd/core/vec.hpp>
namespace PD {
namespace LI {

View File

@ -30,7 +30,7 @@ SOFTWARE.
#include <pd/lithium/font.hpp>
#include <pd/lithium/texture.hpp>
#include <pd/lithium/vertex.hpp>
#include <pd/maths/vec.hpp>
#include <pd/core/vec.hpp>
namespace PD {
namespace LI {

View File

@ -24,7 +24,7 @@ SOFTWARE.
*/
#include <pd/core/common.hpp>
#include <pd/maths/vec.hpp>
#include <pd/core/vec.hpp>
namespace PD {
namespace LI {

View File

@ -33,7 +33,7 @@ SOFTWARE.
#include <pd/lithium/screen.hpp>
#include <pd/lithium/texture.hpp>
#include <pd/lithium/vertex.hpp>
#include <pd/maths/vec.hpp>
#include <pd/core/vec.hpp>
namespace PD {
namespace LI {

View File

@ -27,7 +27,7 @@ SOFTWARE.
#include <citro3d.h>
#include <pd/core/common.hpp>
#include <pd/maths/vec.hpp>
#include <pd/core/vec.hpp>
namespace PD {
class Screen : public SmartCtor<Screen> {

View File

@ -28,7 +28,7 @@ SOFTWARE.
#include <pd/core/common.hpp>
#include <pd/lithium/rect.hpp>
#include <pd/maths/vec.hpp>
#include <pd/core/vec.hpp>
namespace PD {
class Texture : public SmartCtor<Texture> {

View File

@ -25,7 +25,7 @@ SOFTWARE.
*/
#include <pd/core/common.hpp>
#include <pd/maths/vec.hpp>
#include <pd/core/vec.hpp>
namespace PD {
namespace LI {

View File

@ -1,39 +0,0 @@
#pragma once
/*
MIT License
Copyright (c) 2024 - 2025 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/common.hpp>
#include <pd/maths/vec.hpp>
namespace PD {
namespace Img {
inline int Index3dsTex(int x, int y, int width) {
return ((((y >> 3) * (width >> 3) + (x >> 3)) << 6) +
((x & 1) | ((y & 1) << 1) | ((x & 2) << 1) | ((y & 2) << 2) |
((x & 4) << 2) | ((y & 4) << 3)));
}
inline int IndexDefault(int x, int y, int width) { return y * width + x; }
} // namespace Img
} // namespace PD

View File

@ -24,7 +24,7 @@ SOFTWARE.
*/
#include <pd/drivers/hid.hpp>
#include <pd/maths/tween.hpp>
#include <pd/core/tween.hpp>
#include <pd/overlays/overlay.hpp>
namespace PD {

View File

@ -24,8 +24,8 @@ SOFTWARE.
*/
#include <pd/lithium/renderer.hpp>
#include <pd/maths/color.hpp>
#include <pd/maths/tween.hpp>
#include <pd/core/color.hpp>
#include <pd/core/tween.hpp>
namespace PD {
class MessageMgr : public PD::SmartCtor<MessageMgr> {

View File

@ -24,7 +24,7 @@ SOFTWARE.
*/
#include <pd/drivers/hid.hpp>
#include <pd/maths/tween.hpp>
#include <pd/core/tween.hpp>
#include <pd/overlays/overlay.hpp>
#include <pd/ui7/ui7.hpp>

View File

@ -26,7 +26,7 @@ SOFTWARE.
#include <pd/core/common.hpp>
#include <pd/core/strings.hpp>
#include <pd/drivers/hid.hpp>
#include <pd/maths/vec.hpp>
#include <pd/core/vec.hpp>
#include <pd/ui7/drawlist.hpp>
namespace PD {

View File

@ -24,7 +24,7 @@ SOFTWARE.
*/
#include <pd/drivers/hid.hpp>
#include <pd/maths/tween.hpp>
#include <pd/core/tween.hpp>
#include <pd/ui7/containers.hpp>
#include <pd/ui7/drawlist.hpp>
#include <pd/ui7/flags.hpp>

View File

@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/maths/bit_util.hpp>
#include <pd/core/bit_util.hpp>
namespace PD::BitUtil {
bool IsSingleBit(u32 v) { return v && !(v & (v - 1)); }

View File

@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/maths/color.hpp>
#include <pd/core/color.hpp>
namespace PD {
// The Solution of the biggest performance issue

View File

@ -24,8 +24,8 @@ SOFTWARE.
#include <cstring>
#include <memory>
#include <pd/maths/img_blur.hpp>
#include <pd/maths/img_convert.hpp>
#include <pd/image/img_blur.hpp>
#include <pd/image/img_convert.hpp>
namespace PD {
namespace ImgBlur {

View File

@ -21,8 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/maths/img.hpp>
#include <pd/maths/img_convert.hpp>
#include <pd/image/img_convert.hpp>
namespace PD::ImgConvert {
void RGB24toRGBA32(std::vector<u8> &out, const std::vector<u8> &in,
@ -42,7 +41,7 @@ void RGB24toRGBA32(std::vector<u8> &out, const std::vector<u8> &in,
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 = Img::IndexDefault(x, y, w);
int i = y * w + x;
u8 t0 = buf[i + 0];
u8 t1 = buf[i + 1];
buf[i + 0] = buf[i + 3];

View File

@ -30,8 +30,8 @@ SOFTWARE.
#include <pd/core/io.hpp>
#include <pd/core/timetrace.hpp>
#include <pd/lithium/texture.hpp>
#include <pd/maths/bit_util.hpp>
#include <pd/maths/img_convert.hpp>
#include <pd/core/bit_util.hpp>
#include <pd/image/img_convert.hpp>
namespace PD {
GPU_TEXCOLOR GetTexFmt(Texture::Type type) {

View File

@ -22,7 +22,7 @@ SOFTWARE.
*/
#include <pd/external/json.hpp>
#include <pd/maths/color.hpp>
#include <pd/core/color.hpp>
#include <pd/overlays/keyboard.hpp>
#include <pd/lib3ds/gamepad_icons.hpp>

View File

@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/maths/color.hpp>
#include <pd/core/color.hpp>
#include <pd/ui7/theme.hpp>
namespace PD {

View File

@ -25,7 +25,6 @@ SOFTWARE.
#include <ctime>
#include <pd.hpp>
#include <pd/maths/tween.hpp>
class Test : public PD::App {
public: