Author SHA1 Message Date
tobid7 cfb6a9b3dd # small fixes
- Fix Os::GetTimeNano()
- only build tests on non vendored usage
2026-07-19 14:27:48 +02:00
tobid7 799e779fe6 Fix 2026-04-30 12:38:35 +02:00
tobid7 7f708a565e Fix 3ds build and update libpicasso 2026-04-25 00:01:06 +02:00
tobid7 280ce524bf remove poc func 2026-04-18 14:34:45 +02:00
tobid7 b99fc39444 Add support for rotated gradients 2026-04-18 14:33:31 +02:00
tobid7 6dbf5a4812 Add stick and trigger input support 2026-04-09 21:51:38 +02:00
tobid7 ff3b241dd2 Fix clang warning 2026-04-05 04:31:50 +02:00
tobid7 7a1751589e fix preset names for Selection Views 2026-04-05 04:31:22 +02:00
tobid7 8a4b3c119d Add NX Hid Driver Template
- Add WIP HidNX Driver (clangd not working with devkitpro for switch on windows)
- Add default-release as default search path for compile_commands.json
- remove mingw preset (casue its exactly the default target)
- Move Mouse pos cycle into HidDriver::Update
- Test around with HidGlfw on Nintendo switch
2026-04-05 04:20:32 +02:00
tobid7 1f7d96a455 Add proper Gamepad support (WIP) 2026-04-05 00:26:00 +02:00
tobid7 c9768010f2 allo wPD::Color in Drawlist 2026-04-04 17:44:05 +02:00
tobid7 679de3ae94 Add Input functionality to Ultra
- Add point InSpace check to PD::Li::Math
- Add Universal AlignmentCenter flag for Horizontal and and Vertical Alignment
-  Add Fallbackfont to Layout (if you dont want to set font per object)
- Add Button Object WIP
- Rename OnHover to OnFocus and add OnUnfocus
- Move font and FontScale to ElementBase (for fallback logic etc)
- Add UpdateInput func to ElementBase
- Corectly Set fontScale in Text Rendering
- Update ecample
2026-04-03 15:17:43 +02:00
tobid7 af7fc026df Allow implicit usage of "#ffffffff" etc 2026-04-03 14:22:51 +02:00
tobid7 5bc8046ebe Add HidDriver base and small HidGLFW driver 2026-04-03 14:12:42 +02:00
tobid7 8215baac99 rename PDBackendFlags to PDGfxBackendFlags 2026-04-03 12:52:30 +02:00
tobid7 a776addf11 Implement VCanvas and Update TextElem
- Text now requires a font and is able to take an individual scale
- Container requires &ref for Elements to make sure they always exist
- SetViewport now sets the canvas as well
- SetBaseViewport Sets the Virtual Canvas Size
- Layout Now requires a Drawlist reference in Render function
- main.cpp: updated the template
2026-04-03 12:43:49 +02:00
tobid7 1cf3b6f8e6 Actually implement ultra-rendering 2026-04-02 23:29:53 +02:00
44 changed files with 1186 additions and 279 deletions
+1
View File
@@ -1,4 +1,5 @@
CompileFlags: CompileFlags:
CompilationDatabase: build/default-release
Add: [] Add: []
Completion: Completion:
+83 -79
View File
@@ -15,70 +15,72 @@ option(PD_BUILD_TOOLS "Build Palladium Tools" OFF)
option(PD_INCLUDE_STB_IMAGE "Inlude stb image symbols in palladium" ON) option(PD_INCLUDE_STB_IMAGE "Inlude stb image symbols in palladium" ON)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS") if(${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS")
add_compile_options(-Wno-psabi) add_compile_options(-Wno-psabi)
endif() endif()
if(${PD_BUILD_TOOLS}) if(${PD_BUILD_TOOLS})
add_subdirectory(tools) add_subdirectory(tools)
endif() endif()
add_subdirectory(vendor) add_subdirectory(vendor)
# # Include Library Source # # Include Library Source
set(PD_SOURCES set(PD_SOURCES
# Common # Common
source/common.cpp source/common.cpp
# Core # Core
source/core/bits.cpp source/core/bits.cpp
source/core/color.cpp source/core/color.cpp
source/core/io.cpp source/core/io.cpp
source/core/mat.cpp source/core/mat.cpp
source/core/strings.cpp source/core/strings.cpp
source/core/timer.cpp source/core/timer.cpp
source/core/timetrace.cpp source/core/timetrace.cpp
# Image # Image
source/image/image.cpp source/image/image.cpp
# Drivers # Drivers
source/drivers/os.cpp source/drivers/os.cpp
source/drivers/gfx.cpp source/drivers/gfx.cpp
source/drivers/hid.cpp
# Lithium # Lithium
source/lithium/drawlist.cpp source/lithium/drawlist.cpp
source/lithium/font.cpp source/lithium/font.cpp
source/lithium/math.cpp source/lithium/math.cpp
source/lithium/pools.cpp source/lithium/pools.cpp
# Ultra # Ultra
source/ultra/canvas.cpp source/ultra/canvas.cpp
source/ultra/layout.cpp source/ultra/layout.cpp
source/ultra/elems/element.cpp source/ultra/elems/element.cpp
source/ultra/elems/rect.cpp source/ultra/elems/rect.cpp
source/ultra/elems/text.cpp source/ultra/elems/text.cpp
source/ultra/elems/image.cpp source/ultra/elems/image.cpp
source/ultra/elems/button.cpp
) )
if(${PD_BUILD_SHARED}) if(${PD_BUILD_SHARED})
add_library(palladium SHARED ${PD_SOURCES}) add_library(palladium SHARED ${PD_SOURCES})
target_compile_definitions(palladium PRIVATE PD_BUILD_SHARED) target_compile_definitions(palladium PRIVATE PD_BUILD_SHARED)
else() else()
add_library(palladium STATIC ${PD_SOURCES}) add_library(palladium STATIC ${PD_SOURCES})
target_compile_definitions(palladium PUBLIC PD_BUILD_STATIC) target_compile_definitions(palladium PUBLIC PD_BUILD_STATIC)
endif() endif()
target_link_libraries(palladium target_link_libraries(palladium
PUBLIC stb PUBLIC stb
) )
target_compile_definitions(palladium target_compile_definitions(palladium
PUBLIC PUBLIC
PD_DEBUG PD_DEBUG
$<$<OR:$<BOOL:${PD_INCLUDE_STB_IMAGE}>,$<BOOL:${PD_BUILD_SHARED}>>:PD_INCLUDE_STB_IMAGE> # Always on in shared build $<$<OR:$<BOOL:${PD_INCLUDE_STB_IMAGE}>,$<BOOL:${PD_BUILD_SHARED}>>:PD_INCLUDE_STB_IMAGE> # Always on in shared build
) )
target_compile_options(palladium target_compile_options(palladium
PUBLIC $<$<CXX_COMPILER_ID:GNU,Clang>: PUBLIC $<$<CXX_COMPILER_ID:GNU,Clang>:
-fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}/source=source -fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}/source=source
-fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}/include=include -fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}/include=include
> >
@@ -87,76 +89,78 @@ target_compile_options(palladium
add_library(palladium::palladium ALIAS palladium) add_library(palladium::palladium ALIAS palladium)
target_include_directories(palladium target_include_directories(palladium
PUBLIC PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include> $<INSTALL_INTERFACE:include>
) )
target_compile_options(palladium target_compile_options(palladium
PRIVATE PRIVATE
$<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:GNU,Clang>>:-O0 -g> $<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:GNU,Clang>>:-O0 -g>
$<$<AND:$<CONFIG:Release>,$<CXX_COMPILER_ID:GNU,Clang>>:-O3> $<$<AND:$<CONFIG:Release>,$<CXX_COMPILER_ID:GNU,Clang>>:-O3>
$<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:MSVC>>:/Od /Zi> $<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:MSVC>>:/Od /Zi>
$<$<AND:$<CONFIG:Release>,$<CXX_COMPILER_ID:MSVC>>:/O2> $<$<AND:$<CONFIG:Release>,$<CXX_COMPILER_ID:MSVC>>:/O2>
) )
install( install(
TARGETS palladium TARGETS palladium
EXPORT palladiumTargets EXPORT palladiumTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
) )
install( install(
DIRECTORY include/ DIRECTORY include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
) )
install(EXPORT palladiumTargets install(EXPORT palladiumTargets
FILE palladiumTargets.cmake FILE palladiumTargets.cmake
NAMESPACE palladium:: NAMESPACE palladium::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/palladium DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/palladium
) )
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
configure_package_config_file( configure_package_config_file(
cmake/palladiumConfig.cmake.in cmake/palladiumConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/palladiumConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/palladiumConfig.cmake
INSTALL_DESTINATION INSTALL_DESTINATION
${CMAKE_INSTALL_LIBDIR}/cmake/palladium ${CMAKE_INSTALL_LIBDIR}/cmake/palladium
) )
write_basic_package_version_file( write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/palladiumConfigVersion.cmake ${CMAKE_CURRENT_BINARY_DIR}/palladiumConfigVersion.cmake
VERSION VERSION
${PROJECT_VERSION} ${PROJECT_VERSION}
COMPATIBILITY COMPATIBILITY
SameMajorVersion SameMajorVersion
) )
install( install(
FILES FILES
${CMAKE_CURRENT_BINARY_DIR}/palladiumConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/palladiumConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/palladiumConfigVersion.cmake ${CMAKE_CURRENT_BINARY_DIR}/palladiumConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/palladium DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/palladium
) )
find_program(CLANG_FORMAT clang-format) find_program(CLANG_FORMAT clang-format)
file(GLOB_RECURSE PD_FMTFILES file(GLOB_RECURSE PD_FMTFILES
CONFIGURE_DEPENDS CONFIGURE_DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp ${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp
${CMAKE_CURRENT_SOURCE_DIR}/backends/source/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/backends/source/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/backends/include/*.hpp ${CMAKE_CURRENT_SOURCE_DIR}/backends/include/*.hpp
${CMAKE_CURRENT_SOURCE_DIR}/tests/core/source/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tests/core/source/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tests/gfx/source/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tests/gfx/source/*.cpp
) )
add_custom_target(pd-clang-format add_custom_target(pd-clang-format
COMMAND ${CLANG_FORMAT} --style=file -i ${PD_FMTFILES} COMMAND ${CLANG_FORMAT} --style=file -i ${PD_FMTFILES}
COMMENT "Formatting Project Sources" COMMENT "Formatting Project Sources"
) )
add_subdirectory(backends) add_subdirectory(backends)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tests) if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tests)
endif()
-1
View File
@@ -9,7 +9,6 @@
"cmake/presets/default.json", "cmake/presets/default.json",
"cmake/presets/3ds.json", "cmake/presets/3ds.json",
"cmake/presets/switch.json", "cmake/presets/switch.json",
"cmake/presets/mingw.json",
"cmake/presets/msvc.json" "cmake/presets/msvc.json"
] ]
} }
+49 -55
View File
@@ -7,86 +7,80 @@ option(PD_ENABLE_OPENGL3 "Enable OpenGL 3.3 (On Supported Hardware)" ON)
option(PD_ENABLE_DIRECTX9 "Enable DirectX9 Support" ON) option(PD_ENABLE_DIRECTX9 "Enable DirectX9 Support" ON)
option(PD_ENABLE_CITRO3D "Enable Citro3D Support (3DS)" OFF) option(PD_ENABLE_CITRO3D "Enable Citro3D Support (3DS)" OFF)
option(PD_ENABLE_VULKAN "Not implemented yet" OFF) option(PD_ENABLE_VULKAN "Not implemented yet" OFF)
option(PD_ENABLE_HID_GLFW "Enable GLFW Input Driver" ON)
option(PD_ENABLE_HID_NX "Enable NX Input Driver" OFF)
if(NOT WIN32) # cause we are not on windows... if(NOT WIN32) # cause we are not on windows...
set(PD_ENABLE_DIRECTX9 OFF) set(PD_ENABLE_DIRECTX9 OFF)
endif() endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS") if(${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS")
set(PD_ENABLE_OPENGL2 OFF) set(PD_ENABLE_OPENGL2 OFF)
set(PD_ENABLE_OPENGL3 OFF) set(PD_ENABLE_OPENGL3 OFF)
set(PD_ENABLE_VULKAN OFF) set(PD_ENABLE_VULKAN OFF)
set(PD_ENABLE_CITRO3D ON) set(PD_ENABLE_CITRO3D ON)
set(PD_ENABLE_HID_GLFW OFF)
set(PD_ENABLE_HID_NX OFF)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "NintendoSwitch") elseif(${CMAKE_SYSTEM_NAME} STREQUAL "NintendoSwitch")
set(PD_ENABLE_OPENGL2 OFF) set(PD_ENABLE_OPENGL2 OFF)
set(PD_ENABLE_OPENGL3 ON) set(PD_ENABLE_OPENGL3 ON)
set(PD_ENABLE_VULKAN OFF) set(PD_ENABLE_VULKAN OFF)
set(PD_ENABLE_CITRO3D OFF) set(PD_ENABLE_CITRO3D OFF)
set(PD_ENABLE_HID_NX ON) # Best case for Nintendo Switch
set(PD_ENABLE_HID_GLFW ON) # Technically supported but not recommended
endif() endif()
add_library(pd-system STATIC add_library(pd-system STATIC
${CMAKE_CURRENT_SOURCE_DIR}/source/gl-helper.cpp ${CMAKE_CURRENT_SOURCE_DIR}/source/gl-helper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_opengl2.cpp ${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_opengl2.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_opengl3.cpp ${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_opengl3.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_directx9.cpp ${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_directx9.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_citro3d.cpp ${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_citro3d.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/hid_glfw.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/hid_nx.cpp
) )
target_include_directories(pd-system target_include_directories(pd-system
PUBLIC PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include> $<INSTALL_INTERFACE:include>
# Why is this not a default include (same problem as with the __SWITCH__ define)
$<$<STREQUAL:${CMAKE_SYSTEM_NAME},NintendoSwitch>:${DEVKITPRO}/portlibs/switch/include>
) )
target_compile_options(palladium target_compile_options(palladium
PUBLIC $<$<CXX_COMPILER_ID:GNU,Clang>: PUBLIC $<$<CXX_COMPILER_ID:GNU,Clang>:
-fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}/source=source -fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}/source=source
-fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}/include=include -fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}/include=include
> >
) )
target_compile_definitions(pd-system target_compile_definitions(pd-system
PUBLIC PUBLIC
$<$<BOOL:${PD_ENABLE_OPENGL2}>:PD_ENABLE_OPENGL2> $<$<BOOL:${PD_ENABLE_OPENGL2}>:PD_ENABLE_OPENGL2>
$<$<BOOL:${PD_ENABLE_OPENGL3}>:PD_ENABLE_OPENGL3> $<$<BOOL:${PD_ENABLE_OPENGL3}>:PD_ENABLE_OPENGL3>
$<$<BOOL:${PD_ENABLE_VULKAN}>:PD_ENABLE_VULKAN> $<$<BOOL:${PD_ENABLE_VULKAN}>:PD_ENABLE_VULKAN>
$<$<BOOL:${PD_ENABLE_DIRECTX9}>:PD_ENABLE_DIRECTX9> $<$<BOOL:${PD_ENABLE_DIRECTX9}>:PD_ENABLE_DIRECTX9>
$<$<BOOL:${PD_ENABLE_CITRO3D}>:PD_ENABLE_CITRO3D> $<$<BOOL:${PD_ENABLE_CITRO3D}>:PD_ENABLE_CITRO3D>
$<$<BOOL:${PD_ENABLE_HID_GLFW}>:PD_ENABLE_HID_GLFW>
$<$<BOOL:${PD_ENABLE_HID_NX}>:PD_ENABLE_HID_NX>
) )
# Palladium # Palladium
target_link_libraries(pd-system PUBLIC palladium::palladium) target_link_libraries(pd-system PUBLIC palladium::palladium)
# glad (if we have any OpenGL version included)
if(PD_ENABLE_OPENGL2 OR PD_ENABLE_OPENGL3)
target_link_libraries(pd-system
PUBLIC glad
)
endif()
# DirectX9 # Depandant Lib includes (i love this cmake feature)
if(PD_ENABLE_DIRECTX9) target_link_libraries(pd-system PUBLIC
target_link_libraries(pd-system $<$<BOOL:${PD_ENABLE_DIRECTX9}>:d3d9 d3dcompiler> # DirectX9
PUBLIC $<$<BOOL:${PD_ENABLE_CITRO3D}>:pica::pica citro3d ctru> # 3ds
d3d9 $<$<BOOL:${PD_ENABLE_OPENGL3}>:spirv-helper> # OpenGL3
d3dcompiler # Include Glad if we have any OpenGL Usage
) $<$<OR:$<BOOL:${PD_ENABLE_OPENGL2}>,$<BOOL:${PD_ENABLE_OPENGL3}>>:glad>
endif() $<$<BOOL:${PD_ENABLE_HID_NX}>:nx> # Hid NX requirement
# Hid GLFW requirement
$<$<BOOL:${PD_ENABLE_HID_GLFW}>:
$<$<STREQUAL:${CMAKE_SYSTEM_NAME},NintendoSwitch>:glfw3>
$<$<NOT:$<STREQUAL:${CMAKE_SYSTEM_NAME},NintendoSwitch>>:glfw>>
if(${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS") )
target_link_libraries(pd-system
PUBLIC
pica::pica
citro3d
ctru
)
else()
if(${CMAKE_SYSTEM_NAME} STREQUAL "NintendoSwitch")
target_include_directories(pd-system
PUBLIC $ENV{DEVKITPRO}/portlibs/switch/include
)
endif()
target_link_libraries(pd-system
PUBLIC spirv-helper
)
endif()
+21
View File
@@ -0,0 +1,21 @@
#pragma once
#include <pd/drivers/hid.hpp>
typedef struct GLFWwindow GLFWwindow;
typedef struct GLFWgamepadstate GLFWgamepadstate;
namespace PD {
class HidGlfw : public HidDriver {
public:
HidGlfw(GLFWwindow* window);
~HidGlfw();
void Update() override;
private:
void HandleAxisKey(GLFWgamepadstate s, int iK, int eA, bool negative);
struct Impl;
Impl* impl;
};
} // namespace PD
+17
View File
@@ -0,0 +1,17 @@
#pragma once
#include <pd/drivers/hid.hpp>
namespace PD {
class HidNX : public HidDriver {
public:
HidNX();
~HidNX();
void Update() override;
private:
struct Impl;
Impl* impl;
};
} // namespace PD
+4
View File
@@ -1,6 +1,10 @@
#pragma once #pragma once
// Gfx
#include <pd_system/gfx_citro3d.hpp> #include <pd_system/gfx_citro3d.hpp>
#include <pd_system/gfx_directx9.hpp> #include <pd_system/gfx_directx9.hpp>
#include <pd_system/gfx_opengl2.hpp> #include <pd_system/gfx_opengl2.hpp>
#include <pd_system/gfx_opengl3.hpp> #include <pd_system/gfx_opengl3.hpp>
// Hid
#include <pd_system/hid_glfw.hpp>
+1 -1
View File
@@ -119,7 +119,7 @@ void GfxCitro3D::SysInit() {
if (impl) return; if (impl) return;
PDLOG("GfxCitro3D::SysInit();"); PDLOG("GfxCitro3D::SysInit();");
impl = new Impl(); impl = new Impl();
Flags |= PDBackendFlags_FlipUV_Y; Flags |= PDGfxBackendFlags_FlipUV_Y;
impl->pShaderRaw = Pica::AssembleCode(LIShaderCTR); impl->pShaderRaw = Pica::AssembleCode(LIShaderCTR);
impl->pCode = DVLB_ParseFile((uint32_t*)impl->pShaderRaw.data(), impl->pCode = DVLB_ParseFile((uint32_t*)impl->pShaderRaw.data(),
impl->pShaderRaw.size()); impl->pShaderRaw.size());
+156
View File
@@ -0,0 +1,156 @@
#include <pd_system/hid_glfw.hpp>
#ifdef PD_ENABLE_HID_GLFW
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h>
namespace PD {
struct HidGlfw::Impl {
GLFWwindow* Win;
int PrevState;
std::unordered_map<int, int> PrevStates;
std::unordered_map<int, int> GPPrevStates;
GLFWcharfun OldTextCB;
std::string* Text;
bool InTextMode = false;
};
constexpr int KEY_BASE = GLFW_GAMEPAD_BUTTON_LAST;
constexpr int KEY_LSTICK_LEFT = KEY_BASE + 1;
constexpr int KEY_LSTICK_RIGHT = KEY_BASE + 2;
constexpr int KEY_LSTICK_UP = KEY_BASE + 3;
constexpr int KEY_LSTICK_DOWN = KEY_BASE + 4;
constexpr int KEY_RSTICK_LEFT = KEY_BASE + 5;
constexpr int KEY_RSTICK_RIGHT = KEY_BASE + 6;
constexpr int KEY_RSTICK_UP = KEY_BASE + 7;
constexpr int KEY_RSTICK_DOWN = KEY_BASE + 8;
constexpr int KEY_LEFT_TRIGGER = KEY_BASE + 9;
constexpr int KEY_RIGHT_TRIGGER = KEY_BASE + 10;
constexpr int KEY_LAST = KEY_RIGHT_TRIGGER;
HidGlfw::HidGlfw(GLFWwindow* win) : HidDriver("HidGlfw") {
impl = new Impl;
impl->Win = win;
pFlags |= PDHidBackendFlags_HasMouse;
pFlags |= PDHidBackendFlags_HasKeyboard;
if (glfwJoystickPresent(GLFW_JOYSTICK_1)) {
pFlags |= PDHidBackendFlags_HasGamepad;
}
pGamepad[GLFW_GAMEPAD_BUTTON_A] = HidInternal::Gamepad::A;
pGamepad[GLFW_GAMEPAD_BUTTON_B] = HidInternal::Gamepad::B;
pGamepad[GLFW_GAMEPAD_BUTTON_X] = HidInternal::Gamepad::X;
pGamepad[GLFW_GAMEPAD_BUTTON_Y] = HidInternal::Gamepad::Y;
pGamepad[GLFW_GAMEPAD_BUTTON_START] = HidInternal::Gamepad::Start;
pGamepad[GLFW_GAMEPAD_BUTTON_BACK] = HidInternal::Gamepad::Select;
pGamepad[GLFW_GAMEPAD_BUTTON_DPAD_LEFT] = HidInternal::Gamepad::DLeft;
pGamepad[GLFW_GAMEPAD_BUTTON_DPAD_RIGHT] = HidInternal::Gamepad::DRight;
pGamepad[GLFW_GAMEPAD_BUTTON_DPAD_UP] = HidInternal::Gamepad::DUp;
pGamepad[GLFW_GAMEPAD_BUTTON_DPAD_DOWN] = HidInternal::Gamepad::DDown;
pGamepad[GLFW_GAMEPAD_BUTTON_LEFT_BUMPER] = HidInternal::Gamepad::L;
pGamepad[GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER] = HidInternal::Gamepad::R;
pGamepad[GLFW_GAMEPAD_BUTTON_LEFT_THUMB] = HidInternal::Gamepad::LStick;
pGamepad[GLFW_GAMEPAD_BUTTON_RIGHT_THUMB] = HidInternal::Gamepad::RStick;
pGamepad[KEY_LEFT_TRIGGER] = HidInternal::Gamepad::ZL;
pGamepad[KEY_RIGHT_TRIGGER] = HidInternal::Gamepad::ZR;
pGamepad[KEY_LSTICK_LEFT] = HidInternal::Gamepad::CPLeft;
pGamepad[KEY_LSTICK_RIGHT] = HidInternal::Gamepad::CPRight;
pGamepad[KEY_LSTICK_UP] = HidInternal::Gamepad::CPUp;
pGamepad[KEY_LSTICK_DOWN] = HidInternal::Gamepad::CPDown;
pGamepad[KEY_RSTICK_LEFT] = HidInternal::Gamepad::CSLeft;
pGamepad[KEY_RSTICK_RIGHT] = HidInternal::Gamepad::CSRight;
pGamepad[KEY_RSTICK_UP] = HidInternal::Gamepad::CSUp;
pGamepad[KEY_RSTICK_DOWN] = HidInternal::Gamepad::CSDown;
for (int i = 0; i <= KEY_LAST; i++) {
impl->GPPrevStates[i] = 0;
}
}
HidGlfw::~HidGlfw() {}
void HidGlfw::Update() {
HidDriver::Update(); // clear stats
GLFWgamepadstate gpstate;
int gps = glfwGetGamepadState(GLFW_JOYSTICK_1, &gpstate);
if (gps == GLFW_TRUE) {
HandleAxisKey(gpstate, KEY_LEFT_TRIGGER, GLFW_GAMEPAD_AXIS_LEFT_TRIGGER,
false);
HandleAxisKey(gpstate, KEY_RIGHT_TRIGGER, GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER,
false);
HandleAxisKey(gpstate, KEY_LSTICK_LEFT, GLFW_GAMEPAD_AXIS_LEFT_X, true);
HandleAxisKey(gpstate, KEY_LSTICK_RIGHT, GLFW_GAMEPAD_AXIS_LEFT_X, false);
HandleAxisKey(gpstate, KEY_LSTICK_UP, GLFW_GAMEPAD_AXIS_LEFT_Y, true);
HandleAxisKey(gpstate, KEY_LSTICK_DOWN, GLFW_GAMEPAD_AXIS_LEFT_Y, false);
HandleAxisKey(gpstate, KEY_RSTICK_LEFT, GLFW_GAMEPAD_AXIS_RIGHT_X, true);
HandleAxisKey(gpstate, KEY_RSTICK_RIGHT, GLFW_GAMEPAD_AXIS_RIGHT_X, false);
HandleAxisKey(gpstate, KEY_RSTICK_UP, GLFW_GAMEPAD_AXIS_RIGHT_Y, true);
HandleAxisKey(gpstate, KEY_RSTICK_DOWN, GLFW_GAMEPAD_AXIS_RIGHT_Y, false);
pLStick[0].x = gpstate.axes[GLFW_GAMEPAD_AXIS_LEFT_X];
pLStick[0].y = gpstate.axes[GLFW_GAMEPAD_AXIS_LEFT_Y];
pRStick[0].x = gpstate.axes[GLFW_GAMEPAD_AXIS_RIGHT_X];
pRStick[0].y = gpstate.axes[GLFW_GAMEPAD_AXIS_RIGHT_Y];
for (int i = 0; i <= GLFW_GAMEPAD_BUTTON_LAST; i++) {
if (gpstate.buttons[i] == GLFW_PRESS) {
if (impl->GPPrevStates[i] == GLFW_RELEASE) {
pGamepadEvents[0][Event::Down] |= pGamepad[i];
}
pGamepadEvents[0][Event::Held] |= pGamepad[i];
} else if (gpstate.buttons[i] == GLFW_RELEASE &&
impl->GPPrevStates[i] == GLFW_PRESS) {
pGamepadEvents[0][Event::Up] |= pGamepad[i];
}
impl->GPPrevStates[i] = gpstate.buttons[i];
}
}
int state = glfwGetMouseButton(impl->Win, GLFW_MOUSE_BUTTON_LEFT);
if (state == GLFW_PRESS) {
if (impl->PrevState == GLFW_RELEASE) {
pGamepadEvents[0][Event::Down] |= HidInternal::Touch;
}
pGamepadEvents[0][Event::Held] |= HidInternal::Touch;
} else if (state == GLFW_RELEASE && impl->PrevState == GLFW_PRESS) {
pGamepadEvents[0][Event::Up] |= HidInternal::Touch;
}
impl->PrevState = state;
// if (pLocked) {
// SwapTab();
// }
double x, y;
glfwGetCursorPos(impl->Win, &x, &y);
pMouse[0] = fvec2(x, y);
}
void HidGlfw::HandleAxisKey(GLFWgamepadstate s, int iK, int eA, bool negative) {
if (s.axes[eA] <= 1.f && s.axes[eA] >= -1.f) {
if (s.axes[eA] > 0.05f && !negative) {
if (impl->GPPrevStates[iK] == GLFW_RELEASE) {
pGamepadEvents[0][Event::Down] |= pGamepad[iK];
}
pGamepadEvents[0][Event::Held] |= pGamepad[iK];
}
if (s.axes[eA] < -0.05f && negative) {
if (impl->GPPrevStates[iK] == GLFW_RELEASE) {
pGamepadEvents[0][Event::Down] |= pGamepad[iK];
}
pGamepadEvents[0][Event::Held] |= pGamepad[iK];
}
}
impl->GPPrevStates[iK] = (s.axes[eA] <= -0.05 && s.axes[eA] >= 0.05 &&
s.axes[eA] >= -1.f && s.axes[eA] <= 1);
}
} // namespace PD
#else
struct GLFWgamepadstate {};
namespace PD {
HidGlfw::HidGlfw(GLFWwindow* win) : HidDriver("HidGlfw") {}
HidGlfw::~HidGlfw() {}
void HidGlfw::Update() {
HidDriver::Update(); // clear stats
}
void HidGlfw::HandleAxisKey(GLFWgamepadstate s, int iK, int eA, bool negative) {
}
} // namespace PD
#endif
+31
View File
@@ -0,0 +1,31 @@
#include <pd_system/hid_nx.hpp>
#ifdef PD_ENABLE_HID_NX
#include <switch.h>
namespace PD {
struct HidNX::Impl {
PadState Pad;
};
HidNX::HidNX() : HidDriver("HidNX") { impl = new Impl; }
HidNX::~HidNX() {}
void HidNX::Update() {
HidDriver::Update(); // clear stats
}
} // namespace PD
#else
namespace PD {
HidNX::HidNX() : HidDriver("HidNX") {}
HidNX::~HidNX() {}
void HidNX::Update() {
HidDriver::Update(); // clear stats
}
} // namespace PD
#endif
+2 -2
View File
@@ -4,7 +4,7 @@
{ {
"name": "3ds-debug", "name": "3ds-debug",
"generator": "Ninja", "generator": "Ninja",
"displayName": "Nintendo 3DS", "displayName": "Nintendo 3DS Debug",
"binaryDir": "${sourceDir}/build/3ds-debug", "binaryDir": "${sourceDir}/build/3ds-debug",
"toolchainFile": "/opt/devkitPro/cmake/3DS.cmake", "toolchainFile": "/opt/devkitPro/cmake/3DS.cmake",
"cacheVariables": { "cacheVariables": {
@@ -14,7 +14,7 @@
{ {
"name": "3ds-release", "name": "3ds-release",
"generator": "Ninja", "generator": "Ninja",
"displayName": "Nintendo 3DS", "displayName": "Nintendo 3DS Release",
"binaryDir": "${sourceDir}/build/3ds-release", "binaryDir": "${sourceDir}/build/3ds-release",
"toolchainFile": "/opt/devkitPro/cmake/3DS.cmake", "toolchainFile": "/opt/devkitPro/cmake/3DS.cmake",
"cacheVariables": { "cacheVariables": {
+2 -2
View File
@@ -4,7 +4,7 @@
{ {
"name": "default-debug", "name": "default-debug",
"generator": "Ninja", "generator": "Ninja",
"displayName": "Default", "displayName": "Default Debug",
"binaryDir": "${sourceDir}/build/default-debug", "binaryDir": "${sourceDir}/build/default-debug",
"cacheVariables": { "cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug" "CMAKE_BUILD_TYPE": "Debug"
@@ -13,7 +13,7 @@
{ {
"name": "default-release", "name": "default-release",
"generator": "Ninja", "generator": "Ninja",
"displayName": "Default", "displayName": "Default Release",
"binaryDir": "${sourceDir}/build/default-release", "binaryDir": "${sourceDir}/build/default-release",
"cacheVariables": { "cacheVariables": {
"CMAKE_BUILD_TYPE": "Release" "CMAKE_BUILD_TYPE": "Release"
-35
View File
@@ -1,35 +0,0 @@
{
"version": 10,
"configurePresets": [
{
"name": "mingw-release",
"displayName": "MinGW",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/mingw-release",
"cacheVariables": {
"SPV_EXCLUDE_GLSLANG": "ON",
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "mingw-debug",
"displayName": "MinGW",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/mingw-debug",
"cacheVariables": {
"SPV_EXCLUDE_GLSLANG": "ON",
"CMAKE_BUILD_TYPE": "Debug"
}
}
],
"buildPresets": [
{
"name": "mingw-release",
"configurePreset": "mingw-release"
},
{
"name": "mingw-debug",
"configurePreset": "mingw-debug"
}
]
}
+2 -2
View File
@@ -4,7 +4,7 @@
{ {
"name": "switch-debug", "name": "switch-debug",
"generator": "Ninja", "generator": "Ninja",
"displayName": "Nintendo Switch", "displayName": "Nintendo Switch Debug",
"binaryDir": "${sourceDir}/build/switch-debug", "binaryDir": "${sourceDir}/build/switch-debug",
"toolchainFile": "/opt/devkitPro/cmake/Switch.cmake", "toolchainFile": "/opt/devkitPro/cmake/Switch.cmake",
"cacheVariables": { "cacheVariables": {
@@ -15,7 +15,7 @@
{ {
"name": "switch-release", "name": "switch-release",
"generator": "Ninja", "generator": "Ninja",
"displayName": "Nintendo Switch", "displayName": "Nintendo Switch Release",
"binaryDir": "${sourceDir}/build/switch-release", "binaryDir": "${sourceDir}/build/switch-release",
"toolchainFile": "/opt/devkitPro/cmake/Switch.cmake", "toolchainFile": "/opt/devkitPro/cmake/Switch.cmake",
"cacheVariables": { "cacheVariables": {
+20
View File
@@ -71,6 +71,12 @@ class PD_API Color {
*/ */
constexpr Color(const std::string_view& hex) { Hex(hex); } constexpr Color(const std::string_view& hex) { Hex(hex); }
/**
* Constructor for Hex Input (is abel to run at compile time xD)
* @param hex Hex String in `#ffffff` or `#ffffffff` format
*/
constexpr Color(const char* hex) { Hex(std::string_view{hex}); }
/** /**
* Create Color Object by Hex String (at compile time btw) * Create Color Object by Hex String (at compile time btw)
* @param hex Hex String in `#ffffff` or `#ffffffff` format * @param hex Hex String in `#ffffff` or `#ffffffff` format
@@ -115,6 +121,20 @@ class PD_API Color {
return *this; return *this;
} }
/**
* Lerp
* @param v Target color
* @param t interpolation factor
* @return Class Reference
*/
constexpr Color& Lerp(const Color& v, float t) {
a = static_cast<u8>(a + (v.a - a) * t);
b = static_cast<u8>(b + (v.b - b) * t);
g = static_cast<u8>(g + (v.g - g) * t);
r = static_cast<u8>(r + (v.r - r) * t);
return *this;
}
/** /**
* Get 32Bit Color Value * Get 32Bit Color Value
* @return 32Bit Color Value (ABGR iirc) * @return 32Bit Color Value (ABGR iirc)
+1
View File
@@ -1,4 +1,5 @@
#pragma once #pragma once
#include <pd/drivers/gfx.hpp> #include <pd/drivers/gfx.hpp>
#include <pd/drivers/hid.hpp>
#include <pd/drivers/os.hpp> #include <pd/drivers/os.hpp>
+8 -8
View File
@@ -6,11 +6,11 @@
#include <pd/lithium/pools.hpp> #include <pd/lithium/pools.hpp>
#include <pd/lithium/texture.hpp> #include <pd/lithium/texture.hpp>
using PDBackendFlags = PD::u32; using PDGfxBackendFlags = PD::u32;
enum PDBackendFlags_ { enum PDGfxBackendFlags_ {
PDBackendFlags_None = 0, PDGfxBackendFlags_None = 0,
PDBackendFlags_FlipUV_Y = 1 << 0, // Essential for font loading PDGfxBackendFlags_FlipUV_Y = 1 << 0, // Essential for font loading
PDBackendFlags_WindingCW = 1 << 0, // Use CW instead of CCW winding PDGfxBackendFlags_WindingCW = 1 << 0, // Use CW instead of CCW winding
}; };
namespace PD { namespace PD {
@@ -40,7 +40,7 @@ class PD_API GfxDriver : public DriverInterface {
virtual void DeleteTexture(const Li::Texture& tex) {} virtual void DeleteTexture(const Li::Texture& tex) {}
virtual void Draw(const Pool<Li::Command>& commands) {} virtual void Draw(const Pool<Li::Command>& commands) {}
Li::Texture::Ptr GetWhiteTexture() { return &pWhite; } Li::Texture::Ptr GetWhiteTexture() { return &pWhite; }
PDBackendFlags GetFlags() { return Flags; } PDGfxBackendFlags GetFlags() { return Flags; }
size_t GetNumVertices() const { return CountVertices; } size_t GetNumVertices() const { return CountVertices; }
size_t GetNumIndices() const { return CountIndices; } size_t GetNumIndices() const { return CountIndices; }
@@ -70,7 +70,7 @@ class PD_API GfxDriver : public DriverInterface {
ivec2 ViewPort; ivec2 ViewPort;
std::unordered_map<TextureID, Li::Texture> pTextureRegestry; std::unordered_map<TextureID, Li::Texture> pTextureRegestry;
Li::Texture pWhite; Li::Texture pWhite;
PDBackendFlags Flags = 0; PDGfxBackendFlags Flags = 0;
}; };
struct DefaultGfxConfig { struct DefaultGfxConfig {
@@ -174,7 +174,7 @@ class PD_API Gfx {
return driver->GetWhiteTexture(); return driver->GetWhiteTexture();
} }
static PDBackendFlags GetFlags() { return driver->GetFlags(); } static PDGfxBackendFlags GetFlags() { return driver->GetFlags(); }
static const char* GetDriverName() { return driver->GetName(); } static const char* GetDriverName() { return driver->GetName(); }
+183
View File
@@ -0,0 +1,183 @@
#pragma once
#include <pd/core/core.hpp>
#include <pd/drivers/interface.hpp>
using PDHidBackendFlags = PD::u32;
enum PDHidBackendFlags_ {
PDHidBackendFlags_None = 0,
PDHidBackendFlags_HasTouch = 1 << 1,
PDHidBackendFlags_HasGamepad = 1 << 2,
PDHidBackendFlags_HasMouse = 1 << 3,
PDHidBackendFlags_HasKeyboard = 1 << 4,
};
namespace PD {
namespace HidInternal {
class Keyboard {
public:
Keyboard() = default;
virtual ~Keyboard() = default;
using Key = u128;
constexpr static Key No = 0;
constexpr static Key Escape = Key::Flag(0);
constexpr static Key Q = Key::Flag(1);
constexpr static Key W = Key::Flag(2);
constexpr static Key E = Key::Flag(3);
constexpr static Key R = Key::Flag(4);
constexpr static Key T = Key::Flag(5);
constexpr static Key Z = Key::Flag(6);
constexpr static Key U = Key::Flag(7);
constexpr static Key I = Key::Flag(8);
constexpr static Key O = Key::Flag(9);
constexpr static Key P = Key::Flag(10);
constexpr static Key A = Key::Flag(11);
constexpr static Key S = Key::Flag(12);
constexpr static Key D = Key::Flag(13);
constexpr static Key F = Key::Flag(14);
constexpr static Key G = Key::Flag(15);
constexpr static Key H = Key::Flag(16);
constexpr static Key J = Key::Flag(17);
constexpr static Key K = Key::Flag(18);
constexpr static Key L = Key::Flag(19);
constexpr static Key Y = Key::Flag(20);
constexpr static Key X = Key::Flag(21);
constexpr static Key C = Key::Flag(22);
constexpr static Key V = Key::Flag(23);
constexpr static Key B = Key::Flag(24);
constexpr static Key N = Key::Flag(25);
constexpr static Key M = Key::Flag(26);
constexpr static Key _1 = Key::Flag(27);
constexpr static Key _2 = Key::Flag(28);
constexpr static Key _3 = Key::Flag(29);
constexpr static Key _4 = Key::Flag(30);
constexpr static Key _5 = Key::Flag(31);
constexpr static Key _6 = Key::Flag(32);
constexpr static Key _7 = Key::Flag(33);
constexpr static Key _8 = Key::Flag(34);
constexpr static Key _9 = Key::Flag(35);
constexpr static Key _0 = Key::Flag(36);
constexpr static Key F1 = Key::Flag(37);
constexpr static Key F2 = Key::Flag(38);
constexpr static Key F3 = Key::Flag(39);
constexpr static Key F4 = Key::Flag(40);
constexpr static Key F5 = Key::Flag(41);
constexpr static Key F6 = Key::Flag(42);
constexpr static Key F7 = Key::Flag(43);
constexpr static Key F8 = Key::Flag(44);
constexpr static Key F9 = Key::Flag(45);
constexpr static Key F10 = Key::Flag(46);
constexpr static Key F11 = Key::Flag(47);
constexpr static Key F12 = Key::Flag(48);
constexpr static Key MouseLeft = Key::Flag(120);
};
using GamepadKey = u32;
enum Gamepad : GamepadKey {
None = 0, ///< No Key
A = 1 << 0, ///< A
B = 1 << 1, ///< B
X = 1 << 2, ///< X
Y = 1 << 3, ///< Y
Start = 1 << 4, ///< Start
Select = 1 << 5, ///< Select
L = 1 << 6, ///< L
R = 1 << 7, ///< R
DUp = 1 << 8, ///< Dpad Up
DDown = 1 << 9, ///< Dpad down
DLeft = 1 << 10, ///< Dpad left
DRight = 1 << 11, ///< Dpad right
CPUp = 1 << 12, ///< Cpad up
CPDown = 1 << 13, ///< cpad down
CPLeft = 1 << 14, ///< cpad left
CPRight = 1 << 15, ///< Cpad right
CSUp = 1 << 16, ///< Cstick up
CSDown = 1 << 17, ///< cstick down
CSLeft = 1 << 18, ///< cstick left
CSRight = 1 << 19, ///< cstick right
ZL = 1 << 20, ///< ZL
ZR = 1 << 21, ///< ZR
Touch = 1 << 22, ///< Touch
LStick = 1 << 23, ///< Left Stick
RStick = 1 << 24, ///< Right Stick
Up = DUp | CPUp, ///< DPad or CPad Up
Down = DDown | CPDown, ///< DPad or CPad Down
Left = DLeft | CPLeft, ///< DPad or CPad Left
Right = DRight | CPRight, ///< DPad or CPad Right
};
} // namespace HidInternal
// Pre interface class
class PD_API HidDriver : public DriverInterface {
public:
enum class Event {
Null, ///< Nothing happended
Down, ///< Key Pressed
Held, ///< Key held
Up, ///< Key released
};
HidDriver(std::string_view name = "HidNull");
virtual ~HidDriver();
virtual void Init() {}
virtual void Deinit() {}
virtual const fvec2& MousePos() const { return pMouse[0]; }
virtual const fvec2& MousePosLast() const { return pMouse[1]; }
virtual const fvec2& TouchPos() const { return pMouse[0]; }
virtual const fvec2& TouchPosLast() const { return pMouse[1]; }
virtual void Update();
virtual bool IsEvent(Event e, HidInternal::GamepadKey keys);
virtual bool IsEvent(Event e, HidInternal::Keyboard::Key keys);
virtual const fvec2& GetLeftStick() const { return pLStick[0]; }
virtual const fvec2& GetRightStick() const { return pRStick[0]; }
PDHidBackendFlags GetFlags() const { return pFlags; }
protected:
void SwapTab();
PDHidBackendFlags pFlags = PDHidBackendFlags_None;
fvec2 pMouse[2]; // Current And last pos
fvec2 pLStick[2];
fvec2 pRStick[2];
std::unordered_map<u32, u32> pGamepad;
std::unordered_map<u128, u128> pKeyboard;
std::unordered_map<Event, u32> pGamepadEvents[2];
std::unordered_map<Event, u128> pKeyboardEvents[2];
};
class PD_API Hid {
public:
using Gamepad = HidInternal::Gamepad;
using Keyboard = HidInternal::Keyboard;
using Event = HidDriver::Event;
Hid() = default;
~Hid() = default;
template <typename T, typename... Args>
static void UseDriver(Args&&... args) {
// assert(driver == nullptr && "OS Driver already set");
driver = std::make_unique<T>(std::forward<Args>(args)...);
}
static void Init() { driver->Init(); }
static void Deinit() { driver->Deinit(); }
static const fvec2& MousePos() { return driver->MousePos(); }
static const fvec2& MousePosLast() { return driver->MousePosLast(); }
static const fvec2& TouchPos() { return driver->TouchPos(); }
static const fvec2& TouchPosLast() { return driver->TouchPosLast(); }
static void Update() { driver->Update(); }
static bool IsEvent(Event e, HidInternal::GamepadKey keys) {
return driver->IsEvent(e, keys);
}
static bool IsEvent(Event e, HidInternal::Keyboard::Key keys) {
return driver->IsEvent(e, keys);
}
static PDHidBackendFlags GetFlags() { return driver->GetFlags(); }
static const fvec2& GetLeftStick() { return driver->GetLeftStick(); }
static const fvec2& GetRightStick() { return driver->GetRightStick(); }
static const char* GetDriverName() { return driver->GetName(); }
private:
static std::unique_ptr<HidDriver> driver;
};
} // namespace PD
+1 -1
View File
@@ -25,7 +25,7 @@ class PD_API Image {
void Copy(const std::vector<u8>& pixels, int w, int h, int bpp = 4); void Copy(const std::vector<u8>& pixels, int w, int h, int bpp = 4);
const int& Width() const { return pSize.x; } const int& Width() const { return pSize.x; }
const int& Height() const { return pSize.x; } const int& Height() const { return pSize.y; }
const ivec2& Size() const { return pSize; } const ivec2& Size() const { return pSize; }
const std::vector<u8>& data() const { return pData; } const std::vector<u8>& data() const { return pData; }
+25 -16
View File
@@ -26,6 +26,7 @@ using LiDrawFlags = PD::u32;
enum LiDrawFlags_ : PD::u32 { enum LiDrawFlags_ : PD::u32 {
LiDrawFlags_None = 0, LiDrawFlags_None = 0,
LiDrawFlags_Close = 1 << 0, LiDrawFlags_Close = 1 << 0,
LiDrawFlags_AA = 1 << 1,
}; };
namespace PD { namespace PD {
@@ -55,8 +56,11 @@ class PD_API Drawlist {
* only for special use cases * only for special use cases
*/ */
void PathReserve(size_t num) { pPath.ExpandIf(num); } void PathReserve(size_t num) { pPath.ExpandIf(num); }
void PathStroke(u32 color, int t = 1, LiDrawFlags flags = LiDrawFlags_None); void PathStroke(const PD::Color& color, int t = 1,
void PathFill(u32 color); LiDrawFlags flags = LiDrawFlags_None);
void PathFill(const PD::Color& color);
void PathFillGradient(const PD::Color& a, const PD::Color& b,
float rad = 0.f);
void PathArcToN(const fvec2& c, float r, float amin, float amax, int s); void PathArcToN(const fvec2& c, float r, float amin, float amax, int s);
void PathFastArcToN(const fvec2& c, float r, float amin, float amax, int s); void PathFastArcToN(const fvec2& c, float r, float amin, float amax, int s);
void PathRect(const fvec2& tl, const fvec2& br, float r = 0.f); void PathRect(const fvec2& tl, const fvec2& br, float r = 0.f);
@@ -77,27 +81,32 @@ class PD_API Drawlist {
operator const Pool<Command>&() const { return pCommands; } operator const Pool<Command>&() const { return pCommands; }
/** Drawing functions */ /** Drawing functions */
void DrawRect(const fvec2& pos, const fvec2& size, u32 color, int t = 1); void DrawRect(const fvec2& pos, const fvec2& size, const PD::Color& color,
void DrawRectFilled(const fvec2& pos, const fvec2& size, u32 color); int t = 1);
void DrawTriangle(const fvec2& a, const fvec2& b, const fvec2& c, u32 color, void DrawRectFilled(const fvec2& pos, const fvec2& size,
int t = 1); const PD::Color& color);
void DrawTriangle(const fvec2& a, const fvec2& b, const fvec2& c,
const PD::Color& color, int t = 1);
void DrawTriangleFilled(const fvec2& a, const fvec2& b, const fvec2& c, void DrawTriangleFilled(const fvec2& a, const fvec2& b, const fvec2& c,
u32 color); const PD::Color& color);
void DrawCircle(const fvec2& center, float rad, u32 color, int num_segments, void DrawCircle(const fvec2& center, float rad, const PD::Color& color,
int t = 1); int num_segments, int t = 1);
void DrawCircleFilled(const fvec2& center, float rad, u32 color, void DrawCircleFilled(const fvec2& center, float rad, const PD::Color& color,
int num_segments); int num_segments);
void DrawText(const fvec2& p, const char* text, u32 color); void DrawText(const fvec2& p, const char* text, const PD::Color& color);
void DrawTextEx(const fvec2& p, const char* text, u32 color, void DrawTextEx(const fvec2& p, const char* text, const PD::Color& color,
LiTextFlags flags, const fvec2& box = fvec2(0.f)); LiTextFlags flags, const fvec2& box = fvec2(0.f));
void DrawPolyLine(const Pool<fvec2>& points, u32 color, void DrawPolyLine(const Pool<fvec2>& points, const PD::Color& color,
LiDrawFlags flags = LiDrawFlags_None, int t = 1); LiDrawFlags flags = LiDrawFlags_None, int t = 1);
void DrawConvexPolyFilled(const Pool<fvec2>& points, u32 color); void DrawConvexPolyFilled(const Pool<fvec2>& points, const PD::Color& color);
void DrawConvexPolyFilled(const Pool<fvec2>& points, const PD::Color& a,
const PD::Color b, float rad = 0.f);
void PrimQuad(Command& cmd, const Rect& quad, const Rect& uv, u32 color); void PrimQuad(Command& cmd, const Rect& quad, const Rect& uv,
const PD::Color& color);
void PrimTriangle(Command& cmd, const fvec2& a, const fvec2& b, void PrimTriangle(Command& cmd, const fvec2& a, const fvec2& b,
const fvec2& c, u32 color); const fvec2& c, const PD::Color& color);
private: private:
Texture pCurrentTexture; Texture pCurrentTexture;
+1
View File
@@ -10,6 +10,7 @@ PD_API bool InBounds(const fvec2& pos, const fvec2& size, const fvec4& rect);
PD_API bool InBounds(const fvec2& pos, const fvec4& rect); PD_API bool InBounds(const fvec2& pos, const fvec4& rect);
PD_API bool InBounds(const fvec2& a, const fvec2& b, const fvec2& c, PD_API bool InBounds(const fvec2& a, const fvec2& b, const fvec2& c,
const fvec4& rect); const fvec4& rect);
PD_API bool InSpace(const PD::fvec2& pos, const Rect& rect);
PD_API void RotateCorner(fvec2& pos, float sinus, float cosinus); PD_API void RotateCorner(fvec2& pos, float sinus, float cosinus);
PD_API Rect PrimRect(const fvec2& pos, const fvec2& size, float angle = 0.f); PD_API Rect PrimRect(const fvec2& pos, const fvec2& size, float angle = 0.f);
PD_API Rect PrimLine(const fvec2& a, const fvec2& b, int t = 1); PD_API Rect PrimLine(const fvec2& a, const fvec2& b, int t = 1);
+11 -4
View File
@@ -1,6 +1,7 @@
#pragma once #pragma once
#include <pd/lithium/lithium.hpp> #include <pd/lithium/lithium.hpp>
#include <pd/ultra/canvas.hpp>
#include <pd/ultra/elems/element.hpp> #include <pd/ultra/elems/element.hpp>
namespace PD { namespace PD {
@@ -11,14 +12,18 @@ class Container {
Container(const PD::Li::Rect& r) : pRect(r) {} Container(const PD::Li::Rect& r) : pRect(r) {}
virtual ~Container() {} virtual ~Container() {}
void Push(PD::Ultra::ElementBase* elem) { void Push(PD::Ultra::ElementBase& elem) {
elem->SetParent(this); elem.SetParent(this);
pElems.Push(elem); pElems.Push(&elem);
} }
void Reset() { pElems.ResetFast(); } void Reset() { pElems.ResetFast(); }
const PD::Li::Rect& GetRenderspace() const { return pRect; } const PD::Li::Rect& GetRenderspace() const { return pRect; }
void SetViewport(const PD::fvec2& vp) { pRect = PD::fvec4(PD::fvec2(0), vp); } void SetViewport(const PD::fvec2& vp) {
pCanvas.SetViewport(vp);
pRect = PD::fvec4(PD::fvec2(0), vp);
}
void SetBaseViewport(const PD::ivec2& vp) { pCanvas.SetVirtualViewport(vp); }
const PD::fvec2 GetTopLeft() const { return pRect.TopLeft(); } const PD::fvec2 GetTopLeft() const { return pRect.TopLeft(); }
const PD::fvec2 GetTopRight() const { return pRect.TopRight(); } const PD::fvec2 GetTopRight() const { return pRect.TopRight(); }
@@ -26,12 +31,14 @@ class Container {
const PD::fvec2 GetBotRight() const { return pRect.BotRight(); } const PD::fvec2 GetBotRight() const { return pRect.BotRight(); }
const PD::fvec2 GetSize() const { return pRect.BotRight() - pRect.TopLeft(); } const PD::fvec2 GetSize() const { return pRect.BotRight() - pRect.TopLeft(); }
const PD::fvec2 GetPosition() const { return pRect.TopLeft(); } const PD::fvec2 GetPosition() const { return pRect.TopLeft(); }
const Canvas& GetCanvas() const { return pCanvas; }
protected: protected:
PD::Pool<PD::Ultra::ElementBase*>& GetElements() { return pElems; } PD::Pool<PD::Ultra::ElementBase*>& GetElements() { return pElems; }
private: private:
PD::Li::Rect pRect; PD::Li::Rect pRect;
Canvas pCanvas;
PD::Pool<PD::Ultra::ElementBase*> pElems; PD::Pool<PD::Ultra::ElementBase*> pElems;
}; };
} // namespace Ultra } // namespace Ultra
+56
View File
@@ -0,0 +1,56 @@
#pragma once
#include <pd/core/core.hpp>
#include <pd/ultra/elems/element.hpp>
namespace PD {
namespace Ultra {
class PD_API Button : public ElementBase {
public:
Button() {}
Button(const PD::fvec2& pos, const PD::fvec2& size, const PD::Color& color,
float rounding = 0.f, UltraAlignment align = 0)
: pColor(color), pRounding(rounding) {
this->pAlignment = align;
this->pPos = pos;
this->pSize = size;
}
Button(float x, float y, float w, float h, const PD::Color& color,
float rounding = 0.f, UltraAlignment align = 0)
: pColor(color), pRounding(rounding) {
this->pAlignment = align;
this->pPos = PD::fvec2(x, y);
this->pSize = PD::fvec2(w, h);
}
~Button() {}
void Draw(PD::Li::Drawlist& l) override;
void Update() override;
void SetColor(const PD::Color& color) { pColor = color; }
void SetFocusedColor(const PD::Color& color) { pHovered = color; }
void SetTextColor(const PD::Color& color) { pTextColor = color; }
void SetRounding(float r) { pRounding = r; }
void SetLined(bool v) { pLined = v; }
void SetThickness(int v) { pThickness = v; }
void SetText(const std::string& text) { pText = text; }
void SetAutoSizePadding(const PD::fvec2& size) { pAsp = size; }
// Discard these funcs
void OnFocus(EventFunc func) override {}
void OnUnFocus(EventFunc func) override {}
private:
std::string pText;
PD::Color pRenderColor;
PD::Color pColor;
PD::Color pHovered;
PD::Color pTextColor;
float pRounding = 0.f;
bool pLined = false;
int pThickness = 1.f;
// Auto-Size-Padding
PD::fvec2 pAsp = PD::fvec2(30, 10);
};
} // namespace Ultra
} // namespace PD
+38 -1
View File
@@ -1,5 +1,6 @@
#pragma once #pragma once
#include <functional>
#include <pd/lithium/lithium.hpp> #include <pd/lithium/lithium.hpp>
#include <pd/ultra/flags.hpp> #include <pd/ultra/flags.hpp>
@@ -7,6 +8,7 @@ namespace PD {
namespace Ultra { namespace Ultra {
class Canvas; class Canvas;
class Container; class Container;
using EventFunc = std::function<void()>;
class PD_API ElementBase { class PD_API ElementBase {
public: public:
ElementBase() {} ElementBase() {}
@@ -17,22 +19,57 @@ class PD_API ElementBase {
* Reset Function (for PD::Pool::FastReset) * Reset Function (for PD::Pool::FastReset)
*/ */
virtual void Reset() {} virtual void Reset() {}
virtual void Update();
void SetAlignment(UltraAlignment a) { pAlignment = a; } void SetAlignment(UltraAlignment a) { pAlignment = a; }
void SetPosition(const PD::fvec2& pos) { pPos = pos; } void SetPosition(const PD::fvec2& pos) { pPos = pos; }
void SetPosition(float x, float y) { pPos = PD::fvec2(x, y); } void SetPosition(float x, float y) { pPos = PD::fvec2(x, y); }
void SetSize(const PD::fvec2& size) { pSize = size; } void SetSize(const PD::fvec2& size) { pSize = size; }
void SetSize(float w, float h) { pSize = PD::fvec2(w, h); } void SetSize(float w, float h) { pSize = PD::fvec2(w, h); }
/**
* Executed on Hovering
* Elemnents can override / discard this func
*/
virtual void OnFocus(EventFunc func) { pHover = func; }
/**
* Executed on Mocing out of the space
* Elemnents can override / discard this func
*/
virtual void OnUnFocus(EventFunc func) { pUnHover = func; }
/**
* Executrd on KeyUp event
* Elemnents can override / discard this func
*/
virtual void OnPress(EventFunc func) { pPress = func; }
void SetFontScale(float s = 1.f) { pFontScale = 1.f; }
float GetFontScale() const { return pFontScale; }
void SetFont(PD::Li::Font& font) { pFont = &font; }
void SetFontIfNull(PD::Li::Font& font) {
if (!pFont) pFont = &font;
}
virtual void UpdateInput();
protected: protected:
friend class Container; friend class Container;
void SetParent(Container* c) { pParent = c; } void SetParent(Container* c) { pParent = c; }
bool RevisionUpdate(PD::u32 req); bool RevisionUpdate(PD::u32 req);
Container* pParent; Container* pParent = nullptr;
PD::u32 pCanvasRev = 0; PD::u32 pCanvasRev = 0;
UltraAlignment pAlignment = 0; UltraAlignment pAlignment = 0;
PD::fvec2 pPos; PD::fvec2 pPos;
PD::fvec2 pSize; PD::fvec2 pSize;
PD::Li::Rect pRenderspace;
EventFunc pHover = nullptr;
EventFunc pUnHover = nullptr;
EventFunc pPress = nullptr;
bool pFocued = false;
// Not used by every object btw
PD::Li::Font* pFont = nullptr;
float pFontScale = 1.f;
}; };
} // namespace Ultra } // namespace Ultra
} // namespace PD } // namespace PD
+1
View File
@@ -11,6 +11,7 @@ class PD_API Text : public ElementBase {
~Text() {} ~Text() {}
void Draw(PD::Li::Drawlist& l) override; void Draw(PD::Li::Drawlist& l) override;
void Update() override;
void SetColor(const PD::Color& color) { pColor = color; } void SetColor(const PD::Color& color) { pColor = color; }
void SetText(const std::string& text) { pText = text; } void SetText(const std::string& text) { pText = text; }
+2
View File
@@ -15,4 +15,6 @@ enum UltraAlignment_ {
UltraAlignment_TopRight = UltraAlignment_Top | UltraAlignment_Right, UltraAlignment_TopRight = UltraAlignment_Top | UltraAlignment_Right,
UltraAlignment_BotLeft = UltraAlignment_Bot | UltraAlignment_Left, UltraAlignment_BotLeft = UltraAlignment_Bot | UltraAlignment_Left,
UltraAlignment_BotRight = UltraAlignment_Bot | UltraAlignment_Right, UltraAlignment_BotRight = UltraAlignment_Bot | UltraAlignment_Right,
UltraAlignment_Center =
UltraAlignment_CenterVertical | UltraAlignment_CenterHorizontal,
}; };
+7 -6
View File
@@ -11,14 +11,15 @@ class PD_API Layout : public Container {
Layout() {} Layout() {}
~Layout() {} ~Layout() {}
void SetFont(PD::Li::Font& font); /**
* Set a fallback font if you dont want to explicitly set a font for every
void Render(); * objectt individually
*/
const PD::Li::Drawlist& Data() const { return pList; } void SetFont(PD::Li::Font& font) { pFont = &font; }
void Render(PD::Li::Drawlist& list);
private: private:
PD::Li::Drawlist pList; PD::Li::Font* pFont = nullptr;
}; };
} // namespace Ultra } // namespace Ultra
} // namespace PD } // namespace PD
+1
View File
@@ -14,6 +14,7 @@ PD_API void Log(const std::string& txt, LogLevel lvl) {
const char* clr = pColorNo; const char* clr = pColorNo;
const char* plvl = "INFO"; const char* plvl = "INFO";
switch (lvl) { switch (lvl) {
case PD::LogLevel::None:
case PD::LogLevel::Info: case PD::LogLevel::Info:
clr = pColorNo; clr = pColorNo;
plvl = "INFO"; plvl = "INFO";
+48
View File
@@ -0,0 +1,48 @@
#include <pd/drivers/hid.hpp>
namespace PD {
PD_API std::unique_ptr<HidDriver> Hid::driver;
PD_API HidDriver::HidDriver(std::string_view name) : DriverInterface(name) {}
PD_API HidDriver::~HidDriver() {}
PD_API bool HidDriver::IsEvent(Event e, HidInternal::GamepadKey keys) {
return pGamepadEvents[0][e] & keys;
}
PD_API bool HidDriver::IsEvent(Event e, HidInternal::Keyboard::Key keys) {
return pKeyboardEvents[0][e].Has(keys);
}
/**
* Todo: Keyboard support
*/
PD_API void HidDriver::SwapTab() {
auto tkd = pGamepadEvents[1][Event::Down];
auto tkh = pGamepadEvents[1][Event::Held];
auto tku = pGamepadEvents[1][Event::Up];
pGamepadEvents[1][Event::Down] = pGamepadEvents[0][Event::Down];
pGamepadEvents[1][Event::Held] = pGamepadEvents[0][Event::Held];
pGamepadEvents[1][Event::Up] = pGamepadEvents[0][Event::Up];
pGamepadEvents[0][Event::Down] = tkd;
pGamepadEvents[0][Event::Held] = tkh;
pGamepadEvents[0][Event::Up] = tku;
}
/**
* If this func has no verride, still clear the stats
* cause if they are empty this leads to a crash
*/
PD_API void HidDriver::Update() {
// Clear States
for (int i = 0; i < 2; i++) {
pGamepadEvents[i][Event::Down] = 0;
pGamepadEvents[i][Event::Held] = 0;
pGamepadEvents[i][Event::Up] = 0;
for (auto& it : pKeyboardEvents[i]) {
it.second = 0; // ? why was this Event_Null
}
}
pMouse[1] = pMouse[0]; // cycle here
}
} // namespace PD
+1 -1
View File
@@ -10,7 +10,7 @@ PD_API u64 OsDriver::GetTime() const {
} }
PD_API u64 OsDriver::GetTimeNano() const { PD_API u64 OsDriver::GetTimeNano() const {
return std::chrono::duration_cast<std::chrono::milliseconds>( return std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::steady_clock::now().time_since_epoch()) std::chrono::steady_clock::now().time_since_epoch())
.count(); .count();
} }
+85 -20
View File
@@ -34,16 +34,23 @@ PD_API Command& Drawlist::NewCommand() {
PD_API void Drawlist::BindTexture(const Texture& tex) { pCurrentTexture = tex; } PD_API void Drawlist::BindTexture(const Texture& tex) { pCurrentTexture = tex; }
/** Path API */ /** Path API */
PD_API void Drawlist::PathStroke(u32 color, int t, LiDrawFlags flags) { PD_API void Drawlist::PathStroke(const PD::Color& color, int t,
LiDrawFlags flags) {
DrawPolyLine(pPath, color, flags, t); DrawPolyLine(pPath, color, flags, t);
PathClear(); PathClear();
} }
PD_API void Drawlist::PathFill(u32 color) { PD_API void Drawlist::PathFill(const PD::Color& color) {
DrawConvexPolyFilled(pPath, color); DrawConvexPolyFilled(pPath, color);
PathClear(); PathClear();
} }
PD_API void Drawlist::PathFillGradient(const PD::Color& a, const PD::Color& b,
float rad) {
DrawConvexPolyFilled(pPath, a, b, rad);
PathClear();
}
PD_API void Drawlist::PathArcToN(const fvec2& c, float r, float amin, PD_API void Drawlist::PathArcToN(const fvec2& c, float r, float amin,
float amax, int s) { float amax, int s) {
// Path.push_back(c); // Path.push_back(c);
@@ -152,20 +159,21 @@ PD_API void Drawlist::PathRectEx(const fvec2& tl, const fvec2& br,
} }
/** Drawing functions */ /** Drawing functions */
PD_API void Drawlist::DrawRect(const fvec2& pos, const fvec2& size, u32 color, PD_API void Drawlist::DrawRect(const fvec2& pos, const fvec2& size,
int t) { const PD::Color& color, int t) {
PathRect(pos, pos + size); PathRect(pos, pos + size);
PathStroke(color, t, LiDrawFlags_Close); PathStroke(color, t, LiDrawFlags_Close);
} }
PD_API void Drawlist::DrawRectFilled(const fvec2& pos, const fvec2& size, PD_API void Drawlist::DrawRectFilled(const fvec2& pos, const fvec2& size,
u32 color) { const PD::Color& color) {
PathRect(pos, pos + size); PathRect(pos, pos + size);
PathFill(color); PathFill(color);
} }
PD_API void Drawlist::DrawTriangle(const fvec2& a, const fvec2& b, PD_API void Drawlist::DrawTriangle(const fvec2& a, const fvec2& b,
const fvec2& c, u32 color, int t) { const fvec2& c, const PD::Color& color,
int t) {
PathAdd(a); PathAdd(a);
PathAdd(b); PathAdd(b);
PathAdd(c); PathAdd(c);
@@ -173,15 +181,17 @@ PD_API void Drawlist::DrawTriangle(const fvec2& a, const fvec2& b,
} }
PD_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) { const fvec2& c,
const PD::Color& color) {
PathAdd(a); PathAdd(a);
PathAdd(b); PathAdd(b);
PathAdd(c); PathAdd(c);
PathFill(color); PathFill(color);
} }
PD_API void Drawlist::DrawCircle(const fvec2& center, float rad, u32 color, PD_API void Drawlist::DrawCircle(const fvec2& center, float rad,
int num_segments, int t) { const PD::Color& color, int num_segments,
int t) {
if (num_segments <= 0) { if (num_segments <= 0) {
// Auto Segment // Auto Segment
} else { } else {
@@ -193,7 +203,8 @@ PD_API void Drawlist::DrawCircle(const fvec2& center, float rad, u32 color,
} }
PD_API void Drawlist::DrawCircleFilled(const fvec2& center, float rad, PD_API void Drawlist::DrawCircleFilled(const fvec2& center, float rad,
u32 color, int num_segments) { const PD::Color& color,
int num_segments) {
if (num_segments <= 0) { if (num_segments <= 0) {
// Auto Segment // Auto Segment
} else { } else {
@@ -203,27 +214,30 @@ PD_API void Drawlist::DrawCircleFilled(const fvec2& center, float rad,
PathFill(color); PathFill(color);
} }
PD_API void Drawlist::DrawText(const fvec2& p, const char* text, u32 color) { PD_API void Drawlist::DrawText(const fvec2& p, const char* text,
const PD::Color& color) {
if (!pFont) return; if (!pFont) return;
pFont->CmdTextEx(*this, p, color, pFontScale, text); pFont->CmdTextEx(*this, p, color, pFontScale, text);
} }
PD_API void Drawlist::DrawTextEx(const fvec2& p, const char* text, u32 color, PD_API void Drawlist::DrawTextEx(const fvec2& p, const char* text,
LiTextFlags flags, const fvec2& box) { const PD::Color& color, LiTextFlags flags,
const fvec2& box) {
if (!pFont) return; if (!pFont) return;
pFont->CmdTextEx(*this, p, color, pFontScale, text, flags, box); pFont->CmdTextEx(*this, p, color, pFontScale, text, flags, box);
} }
PD_API void Drawlist::DrawPolyLine(const Pool<fvec2>& points, u32 color, PD_API void Drawlist::DrawPolyLine(const Pool<fvec2>& points,
LiDrawFlags flags, int t) { const PD::Color& color, LiDrawFlags flags,
int t) {
if (points.size() < 2) { if (points.size() < 2) {
return; return;
} }
UnbindTexture(); UnbindTexture();
auto& cmd = NewCommand(); auto& cmd = NewCommand();
bool close = (flags & (1 << 0)); bool close = (flags & LiDrawFlags_Close);
int num_points = close ? (int)points.size() : (int)points.size() - 1; int num_points = close ? (int)points.size() : (int)points.size() - 1;
if (flags & (1 << 1)) { if (flags & LiDrawFlags_AA) {
// TODO: Find a way to draw less garbage looking lines // TODO: Find a way to draw less garbage looking lines
} else { } else {
// Non antialiased lines look awful when rendering with thickness != 1 // Non antialiased lines look awful when rendering with thickness != 1
@@ -236,7 +250,7 @@ PD_API void Drawlist::DrawPolyLine(const Pool<fvec2>& points, u32 color,
} }
PD_API void Drawlist::DrawConvexPolyFilled(const Pool<fvec2>& points, PD_API void Drawlist::DrawConvexPolyFilled(const Pool<fvec2>& points,
u32 color) { const PD::Color& color) {
if (points.size() < 3) { if (points.size() < 3) {
return; // Need at least three points return; // Need at least three points
} }
@@ -274,8 +288,59 @@ PD_API void Drawlist::DrawConvexPolyFilled(const Pool<fvec2>& points,
} }
} }
PD_API void Drawlist::DrawConvexPolyFilled(const Pool<fvec2>& points,
const PD::Color& a,
const PD::Color b, float rad) {
if (points.size() < 3) {
return; // Need at least three points
}
fvec2 dir = fvec2(std::cos(rad), std::sin(rad));
// Support for Custom Textures (UV calculation)
float minX = points[0].x, minY = points[0].y;
float maxX = minX, maxY = minY;
// Check for the max and min Positions
for (const auto& it : points) {
if (it.x < minX) minX = it.x;
if (it.y < minY) minY = it.y;
if (it.x > maxX) maxX = it.x;
if (it.y > maxY) maxY = it.y;
}
// Get Short defines for UV
// (Bottom Right is not required)
auto uv_tl = pCurrentTexture.GetUV().TopLeft();
auto uv_tr = pCurrentTexture.GetUV().TopRight();
auto uv_bl = pCurrentTexture.GetUV().BotLeft();
// Gradient
float tmin = std::numeric_limits<float>::max();
float tmax = std::numeric_limits<float>::lowest();
for (const auto& p : points) {
float t = p.x * dir.x + p.y * dir.y;
if (t < tmin) tmin = t;
if (t > tmax) tmax = t;
}
// potential div0
float irange = (tmax != tmin) ? (1.0f / (tmax - tmin)) : 0.0f;
// Command building (oder so)
auto& cmd = NewCommand();
cmd.Reserve(points.size(), (points.size() - 2) * 3);
// Render
for (int i = 2; i < (int)points.size(); i++) {
cmd.Add(0, i, i - 1);
}
// Why was this for loop not used in normal Convex Poly filled???
for (auto& it : points) {
// Calculate U and V coords
float u = uv_tl.x + ((it.x - minX) / (maxX - minX)) * (uv_tr.x - uv_tl.x);
float v = uv_tl.y + ((it.y - minY) / (maxY - minY)) * (uv_bl.y - uv_tl.y);
float t = it.x * dir.x + it.y * dir.y;
cmd.Add(Vertex(it, fvec2(u, v), PD::Color(a).Lerp(b, (t - tmin) * irange)));
}
}
PD_API void Drawlist::PrimQuad(Command& cmd, const Rect& quad, const Rect& uv, PD_API void Drawlist::PrimQuad(Command& cmd, const Rect& quad, const Rect& uv,
u32 color) { const PD::Color& color) {
cmd.Reserve(4, 6); cmd.Reserve(4, 6);
cmd.Add(2, 1, 0); cmd.Add(2, 1, 0);
cmd.Add(3, 2, 0); cmd.Add(3, 2, 0);
@@ -286,7 +351,7 @@ PD_API void Drawlist::PrimQuad(Command& cmd, const Rect& quad, const Rect& uv,
} }
PD_API void Drawlist::PrimTriangle(Command& cmd, const fvec2& a, const fvec2& b, PD_API void Drawlist::PrimTriangle(Command& cmd, const fvec2& a, const fvec2& b,
const fvec2& c, u32 color) { const fvec2& c, const PD::Color& color) {
cmd.Reserve(3, 3); cmd.Reserve(3, 3);
cmd.Add(2, 1, 0); cmd.Add(2, 1, 0);
cmd.Add(Vertex(a, vec2(0.f, 1.f), color)); cmd.Add(Vertex(a, vec2(0.f, 1.f), color));
+1 -1
View File
@@ -103,7 +103,7 @@ PD_API void Font::LoadTTF(const std::vector<u8>& data, int px_height) {
uvs.z = (off.x + w) / static_cast<float>(texszs); uvs.z = (off.x + w) / static_cast<float>(texszs);
uvs.w = (off.y + h) / static_cast<float>(texszs); uvs.w = (off.y + h) / static_cast<float>(texszs);
// Flip if needed // Flip if needed
if (PD::Gfx::GetFlags() & PDBackendFlags_FlipUV_Y) { if (PD::Gfx::GetFlags() & PDGfxBackendFlags_FlipUV_Y) {
uvs.y = 1.f - uvs.y; uvs.y = 1.f - uvs.y;
uvs.w = 1.f - uvs.w; uvs.w = 1.f - uvs.w;
} }
+6
View File
@@ -20,6 +20,11 @@ PD_API bool InBounds(const fvec2& a, const fvec2& b, const fvec2& c,
(a.x > 0 && b.x > 0 && c.x > 0) || (a.y > 0 && b.y > 0 && c.y > 0)); (a.x > 0 && b.x > 0 && c.x > 0) || (a.y > 0 && b.y > 0 && c.y > 0));
} }
PD_API bool InSpace(const PD::fvec2& pos, const Rect& rect) {
return (pos.x > rect.Top.x && pos.x < rect.Top.z && pos.y > rect.Top.y &&
pos.y < rect.Bot.y);
}
PD_API void RotateCorner(fvec2& pos, float sinus, float cosinus) { PD_API void RotateCorner(fvec2& pos, float sinus, float cosinus) {
float x = pos.x * cosinus - pos.y * sinus; float x = pos.x * cosinus - pos.y * sinus;
float y = pos.y * cosinus - pos.x * sinus; float y = pos.y * cosinus - pos.x * sinus;
@@ -53,6 +58,7 @@ PD_API Rect PrimLine(const fvec2& a, const fvec2& b, int t) {
// Using the vec maths api makes the code as short as it is // Using the vec maths api makes the code as short as it is
vec2 dir = a - b; vec2 dir = a - b;
float len = dir.Len(); float len = dir.Len();
if (len == 0.0f) return Rect();
vec2 unit_dir = dir / len; vec2 unit_dir = dir / len;
vec2 perpendicular(-unit_dir.y, unit_dir.x); vec2 perpendicular(-unit_dir.y, unit_dir.x);
vec2 off = perpendicular * ((float)t * 0.5f); vec2 off = perpendicular * ((float)t * 0.5f);
+46
View File
@@ -0,0 +1,46 @@
#include <pd/drivers/drivers.hpp>
#include <pd/ultra/container.hpp>
#include <pd/ultra/elems/button.hpp>
namespace PD {
namespace Ultra {
PD_API void Button::Draw(PD::Li::Drawlist& l) {
float r = pRounding;
if (pParent) r = pParent->GetCanvas().VTranslateSize(r).x;
l.PathRect(pRenderspace.TopLeft(), pRenderspace.BotRight(), r);
if (pLined) {
l.PathStroke(pRenderColor, pThickness, LiDrawFlags_Close);
} else {
l.PathFill(pRenderColor);
}
if (!pFont) return; // discard here if we dont have a font
PD::fvec2 off = 0.f;
if (pParent) off = pParent->GetCanvas().VTranslateSize(pAsp) * 0.5;
l.SetFont(pFont);
l.SetFontscale(pParent->GetCanvas().VTranslateFontscale(pFontScale));
l.DrawText(pRenderspace.TopLeft() + off, pText.c_str(), pTextColor);
}
PD_API void Button::Update() {
pRenderColor = pColor;
if (!pParent || !pFont) ElementBase::Update();
PD::fvec2 size = pSize;
if (size == PD::fvec2(0)) {
size = pFont->GetTextBounds(
pText.c_str(),
pParent->GetCanvas().VTranslateFontscale(pFontScale)) +
pParent->GetCanvas().VTranslateSize(pAsp);
} else {
size = pParent->GetCanvas().VTranslateSize(size);
}
pRenderspace = pParent->GetCanvas().VTranslateObject(
pParent->GetTopLeft() + pPos, size, pAlignment, true);
if (PD::Li::Math::InSpace(PD::Hid::MousePos(), pRenderspace)) {
pRenderColor = pHovered;
} else {
pRenderColor = pColor;
}
UpdateInput();
}
} // namespace Ultra
} // namespace PD
+33 -1
View File
@@ -1,4 +1,5 @@
#include <pd/ultra/canvas.hpp> #include <pd/drivers/drivers.hpp>
#include <pd/ultra/container.hpp>
#include <pd/ultra/elems/element.hpp> #include <pd/ultra/elems/element.hpp>
namespace PD { namespace PD {
@@ -11,5 +12,36 @@ PD_API bool ElementBase::RevisionUpdate(PD::u32 req) {
return false; return false;
} }
} }
PD_API void ElementBase::Update() {
if (!pParent)
pRenderspace = PD::fvec4(pPos, pPos + pSize);
else
pRenderspace = pParent->GetCanvas().VTranslateObject(
pParent->GetTopLeft() + pPos, pSize, pAlignment);
UpdateInput();
/*pRenderspace = PD::fvec4(pParent->GetTopLeft() + pPos,
pParent->GetTopLeft() + pPos + pSize);*/
}
PD_API void ElementBase::UpdateInput() {
if (PD::Li::Math::InSpace(
PD::Hid::MousePos(),
PD::fvec4(pRenderspace.TopLeft(), pRenderspace.BotRight()))) {
if (pHover && !pFocued) {
pHover();
pFocued = true;
}
if (PD::Hid::IsEvent(PD::Hid::Event::Up, PD::Hid::Gamepad::Touch)) {
if (pPress) {
pPress();
}
}
} else {
if (pUnHover && pFocued) {
pUnHover();
pFocued = false;
}
}
}
} // namespace Ultra } // namespace Ultra
} // namespace PD } // namespace PD
+3 -3
View File
@@ -3,9 +3,9 @@
namespace PD { namespace PD {
namespace Ultra { namespace Ultra {
PD_API void Image::Draw(PD::Li::Drawlist& l) { PD_API void Image::Draw(PD::Li::Drawlist& l) {
// l.BindTexture(*pTex); l.BindTexture(*pTex);
// l.PathRect(pRenderspace.TopLeft(), pRenderspace.BotRight(), pRounding); l.PathRect(pRenderspace.TopLeft(), pRenderspace.BotRight(), pRounding);
// l.PathFill(pColor); l.PathFill(pColor);
} }
} // namespace Ultra } // namespace Ultra
} // namespace PD } // namespace PD
+1 -1
View File
@@ -3,7 +3,7 @@
namespace PD { namespace PD {
namespace Ultra { namespace Ultra {
PD_API void Rect::Draw(PD::Li::Drawlist& l) { PD_API void Rect::Draw(PD::Li::Drawlist& l) {
l.PathRect(pPos, pPos + pSize, pRounding); l.PathRect(pRenderspace.TopLeft(), pRenderspace.BotRight(), pRounding);
if (pLined) { if (pLined) {
l.PathStroke(pColor, pThickness, LiDrawFlags_Close); l.PathStroke(pColor, pThickness, LiDrawFlags_Close);
} else { } else {
+15 -1
View File
@@ -1,9 +1,23 @@
#include <pd/ultra/container.hpp>
#include <pd/ultra/elems/text.hpp> #include <pd/ultra/elems/text.hpp>
namespace PD { namespace PD {
namespace Ultra { namespace Ultra {
PD_API void Text::Draw(PD::Li::Drawlist& l) { PD_API void Text::Draw(PD::Li::Drawlist& l) {
l.DrawText(pPos, pText.c_str(), pColor); if (!pFont) return;
l.SetFont(pFont);
l.SetFontscale(pParent->GetCanvas().VTranslateFontscale(pFontScale));
l.DrawText(pRenderspace.TopLeft(), pText.c_str(), pColor);
}
PD_API void Text::Update() {
if (!pFont) return;
if (!pParent) ElementBase::Update();
pRenderspace = pParent->GetCanvas().VTranslateObject(
pParent->GetTopLeft() + pPos,
pFont->GetTextBounds(
pText.c_str(), pParent->GetCanvas().VTranslateFontscale(pFontScale)),
pAlignment, true);
} }
} // namespace Ultra } // namespace Ultra
} // namespace PD } // namespace PD
+10 -5
View File
@@ -1,14 +1,19 @@
#include <pd/lithium/formatters.hpp>
#include <pd/ultra/layout.hpp> #include <pd/ultra/layout.hpp>
namespace PD { namespace PD {
namespace Ultra { namespace Ultra {
PD_API void Layout::SetFont(PD::Li::Font& font) { pList.SetFont(&font); } PD_API void Layout::Render(PD::Li::Drawlist& list) {
float fc = list.GetFontScale();
PD_API void Layout::Render() { list.SetFontscale(GetCanvas().VTranslateFontscale(fc));
pList.Clear();
for (auto& it : GetElements()) { for (auto& it : GetElements()) {
it->Draw(pList); it->SetFontIfNull(*pFont);
it->Update();
it->Draw(list);
} }
list.DrawText(PD::fvec2(5, GetBotLeft().y - 40),
std::format("Lyt: [{}]", GetRenderspace()).c_str(), 0xffff00ff);
list.SetFontscale(fc);
} }
} // namespace Ultra } // namespace Ultra
} // namespace PD } // namespace PD
+209 -32
View File
@@ -4,10 +4,13 @@
#include <palladium> #include <palladium>
//// ////
#include <pd/ultra/elems/button.hpp>
#include <pd/ultra/elems/element.hpp>
#include <pd/ultra/elems/image.hpp> #include <pd/ultra/elems/image.hpp>
#include <pd/ultra/elems/rect.hpp> #include <pd/ultra/elems/rect.hpp>
#include <pd/ultra/elems/text.hpp> #include <pd/ultra/elems/text.hpp>
#include <pd/ultra/layout.hpp> #include <pd/ultra/layout.hpp>
//// ////
PD::OsCtx* pOs = nullptr; PD::OsCtx* pOs = nullptr;
@@ -22,6 +25,147 @@ const char* ResourcePath(const char* in) {
#endif #endif
} }
std::string Key2String(PD::Hid::Gamepad gp) {
std::string res;
if (gp & PD::Hid::Gamepad::A) {
res += "A";
}
if (gp & PD::Hid::Gamepad::B) {
res += "B";
}
if (gp & PD::Hid::Gamepad::X) {
res += "X";
}
if (gp & PD::Hid::Gamepad::Y) {
res += "Y";
}
if (gp & PD::Hid::Gamepad::Start) {
res += "Start";
}
if (gp & PD::Hid::Gamepad::Select) {
res += "Select";
}
if (gp & PD::Hid::Gamepad::DDown) {
res += "DDown";
}
if (gp & PD::Hid::Gamepad::DUp) {
res += "DUp";
}
if (gp & PD::Hid::Gamepad::DLeft) {
res += "DLeft";
}
if (gp & PD::Hid::Gamepad::DRight) {
res += "DRight";
}
if (gp & PD::Hid::Gamepad::CPDown) {
res += "CPDown";
}
if (gp & PD::Hid::Gamepad::CPUp) {
res += "CPUp";
}
if (gp & PD::Hid::Gamepad::CPLeft) {
res += "CPLeft";
}
if (gp & PD::Hid::Gamepad::CPRight) {
res += "CPRight";
}
if (gp & PD::Hid::Gamepad::CSDown) {
res += "CSDown";
}
if (gp & PD::Hid::Gamepad::CSUp) {
res += "CSUp";
}
if (gp & PD::Hid::Gamepad::CSLeft) {
res += "CSLeft";
}
if (gp & PD::Hid::Gamepad::CSRight) {
res += "CSRight";
}
if (gp & PD::Hid::Gamepad::L) {
res += "L";
}
if (gp & PD::Hid::Gamepad::R) {
res += "R";
}
if (gp & PD::Hid::Gamepad::ZL) {
res += "ZL";
}
if (gp & PD::Hid::Gamepad::ZR) {
res += "ZR";
}
return res;
}
std::string ComboGpOut(PD::Hid::Gamepad gp) {
std::string res = Key2String(gp);
if (PD::Hid::IsEvent(PD::Hid::Event::Down, gp)) {
res += ": 1";
} else if (PD::Hid::IsEvent(PD::Hid::Event::Held, gp)) {
res += ": 2";
} else if (PD::Hid::IsEvent(PD::Hid::Event::Up, gp)) {
res += ": 3";
}
return res;
}
class MainMenu : public PD::Ultra::Layout {
public:
MainMenu(PD::Li::Font& font) {
SetFont(font);
SetBaseViewport(PD::ivec2(1280, 720));
pBackground.SetSize(800, 450);
pBackground.SetColor("#ffffffff");
pBackground.SetAlignment(UltraAlignment_Center);
Push(pBackground);
pText.SetColor("#ffffff");
pText.SetText("MousePos: ");
pText.SetAlignment(UltraAlignment_TopLeft);
Push(pText);
pBtn.SetText("Test");
pBtn.SetAlignment(UltraAlignment_Center);
pBtn.SetColor("#1273fb");
pBtn.SetFocusedColor("#0011ff");
pBtn.SetTextColor("#ffffff");
pBtn.SetRounding(10);
pBtn.OnPress([]() { PD::Log("Btn Pressed..."); });
Push(pBtn);
}
~MainMenu() {}
void Update() {
pText.SetText(std::format("MousePos: {}", PD::Hid::MousePos()));
}
private:
PD::Ultra::Rect pBackground;
PD::Ultra::Text pText;
PD::Ultra::Button pBtn;
};
class App {
public:
App(PD::Li::Font& font) : main(font) {}
~App() {}
void Update(PD::ivec2 vp, PD::Li::Drawlist& list) {
main.Update();
main.SetViewport(vp);
main.Render(list);
}
private:
MainMenu main;
};
struct Cursor {
PD::fvec2 pPos = 0;
std::string name;
PD::Color pColor = 0xffff00ff;
void Render(PD::Li::Drawlist& l) {
l.DrawCircleFilled(pPos, 32.f, pColor, 15);
}
};
int main(int argc, char** argv) { int main(int argc, char** argv) {
// PD::LogFilter(PD::LogLevel::Warning); // PD::LogFilter(PD::LogLevel::Warning);
Driver drv = Driver::OpenGL3; Driver drv = Driver::OpenGL3;
@@ -49,45 +193,78 @@ int main(int argc, char** argv) {
PD::Li::Font font; PD::Li::Font font;
font.LoadTTF(ResourcePath("default.ttf"), 64); font.LoadTTF(ResourcePath("default.ttf"), 64);
pList.SetFont(&font); pList.SetFont(&font);
PD::Ultra::Layout lyt; App app(font);
lyt.SetViewport(PD::fvec2(1280, 720)); Cursor LeftStick;
lyt.SetFont(font); Cursor RightStick;
PD::Ultra::Rect r; RightStick.pColor = "#00ffff";
r.SetColor(0xff0000ff);
r.SetRounding(10.f);
r.SetLined(true);
r.SetPosition(250, 150);
r.SetSize(100, 70);
PD::Ultra::Rect rr;
r.SetColor(0xff0000ff);
r.SetRounding(10.f);
r.SetPosition(250, 150);
r.SetSize(100, 70);
lyt.Push(&rr);
lyt.Push(&r);
PD::Ultra::Text txt;
txt.SetPosition(PD::fvec2(5, 200));
txt.SetText("OpenGL");
txt.SetColor(PD::Color("#ffffffff"));
lyt.Push(&txt);
while (pOs->Mainloop()) { while (pOs->Mainloop()) {
PD::Hid::Update();
pOs->ClearViewPort(); pOs->ClearViewPort();
PD::Li::ResetPools(); PD::Li::ResetPools(); // Move to other place (or refactor this)
pList.DrawRectFilled(150, 50, 0x88ffffff); app.Update(pOs->GetViewport(), pList);
pList.DrawRect(150, 50, 0xffffffff); pList.SetFontscale(0.7);
lyt.Render(); if (PD::Hid::IsEvent(PD::Hid::Event::Down, PD::Hid::Gamepad::CPLeft |
PD::Hid::Gamepad::CPRight)) {
LeftStick.pPos.x += PD::Hid::GetLeftStick().x * 15;
}
if (PD::Hid::IsEvent(PD::Hid::Event::Down,
PD::Hid::Gamepad::CPUp | PD::Hid::Gamepad::CPDown)) {
LeftStick.pPos.y += PD::Hid::GetLeftStick().y * 15;
}
if (PD::Hid::IsEvent(PD::Hid::Event::Down, PD::Hid::Gamepad::CSLeft |
PD::Hid::Gamepad::CSRight)) {
RightStick.pPos.x += PD::Hid::GetRightStick().x * 15;
}
if (PD::Hid::IsEvent(PD::Hid::Event::Down,
PD::Hid::Gamepad::CSUp | PD::Hid::Gamepad::CSDown)) {
RightStick.pPos.y += PD::Hid::GetRightStick().y * 15;
}
pList.DrawText( pList.DrawText(
5, PD::fvec2(5, 37),
std::format( std::format(
"Font Scale: {}\nVP: [{}]\nVIDC: [{}, {}, {}, {}]\nGfxDriver: {}", "Input:\n Driver: {}\n Gamepad: {}\n {}\n {}\n "
pList.GetFontScale(), pOs->GetViewport(), PD::Gfx::GetNumVertices(), "{}\n {}\n {}\n {}\n {}\n {}\n {}\n {}\n "
PD::Gfx::GetNumIndices(), PD::Gfx::GetNumDrawcalls(), "{}\n {}\n {}\n {}\n {}\n {}\n {}\n {}\n "
PD::Gfx::GetNumCommands(), PD::Gfx::GetDriverName()) "{}\n {}\n "
"{}\n {}\n LS: [{}]\n RS: [{}]\nLSP: {}",
PD::Hid::GetDriverName(),
bool(PD::Hid::GetFlags() & PDHidBackendFlags_HasGamepad),
ComboGpOut(PD::Hid::Gamepad::Start),
ComboGpOut(PD::Hid::Gamepad::Select),
ComboGpOut(PD::Hid::Gamepad::A), ComboGpOut(PD::Hid::Gamepad::B),
ComboGpOut(PD::Hid::Gamepad::X), ComboGpOut(PD::Hid::Gamepad::Y),
ComboGpOut(PD::Hid::Gamepad::DDown),
ComboGpOut(PD::Hid::Gamepad::DUp),
ComboGpOut(PD::Hid::Gamepad::DLeft),
ComboGpOut(PD::Hid::Gamepad::DRight),
ComboGpOut(PD::Hid::Gamepad::L), ComboGpOut(PD::Hid::Gamepad::R),
ComboGpOut(PD::Hid::Gamepad::ZL), ComboGpOut(PD::Hid::Gamepad::ZR),
ComboGpOut(PD::Hid::Gamepad::CPLeft),
ComboGpOut(PD::Hid::Gamepad::CPRight),
ComboGpOut(PD::Hid::Gamepad::CPUp),
ComboGpOut(PD::Hid::Gamepad::CPDown),
ComboGpOut(PD::Hid::Gamepad::CSLeft),
ComboGpOut(PD::Hid::Gamepad::CSRight),
ComboGpOut(PD::Hid::Gamepad::CSUp),
ComboGpOut(PD::Hid::Gamepad::CSDown), PD::Hid::GetLeftStick(),
PD::Hid::GetRightStick(), LeftStick.pPos)
.c_str(), .c_str(),
0xffffffff); "#ffffff");
LeftStick.Render(pList);
RightStick.Render(pList);
pList.UnbindTexture();
pList.PathRect(50, PD::fvec2(450, 240));
pList.PathFillGradient("#ff0000", "#990000", PD::Radians(135));
pList.PathAdd(PD::fvec2(100, 120));
pList.PathAdd(PD::fvec2(250, 260));
pList.PathAdd(PD::fvec2(420, 180));
pList.PathAdd(PD::fvec2(600, 320));
pList.PathAdd(PD::fvec2(820, 220));
pList.PathAdd(PD::fvec2(1000, 360));
pList.PathStroke("#ff00ff", 10, LiDrawFlags_AA);
PD::Gfx::Reset(); PD::Gfx::Reset();
PD::Gfx::Draw(pList); PD::Gfx::Draw(pList);
PD::Gfx::Draw(lyt.Data());
pList.Clear(); pList.Clear();
pOs->SwapBuffers(); pOs->SwapBuffers();
} }
+1
View File
@@ -72,6 +72,7 @@ void DesktopOS::Init() {
} }
#endif #endif
glfwSwapInterval(1); glfwSwapInterval(1);
PD::Hid::UseDriver<HidGlfw>(impl->win);
} }
void DesktopOS::Deinit() { void DesktopOS::Deinit() {
+1
View File
@@ -42,6 +42,7 @@ void HorizonCtr::Init() {
C3D_RenderTargetSetOutput(impl->Bottom, GFX_BOTTOM, GFX_LEFT, C3D_RenderTargetSetOutput(impl->Bottom, GFX_BOTTOM, GFX_LEFT,
DisplayTransferFlags); DisplayTransferFlags);
PD::Gfx::UseDriver<PD::GfxCitro3D>(); PD::Gfx::UseDriver<PD::GfxCitro3D>();
PD::Hid::UseDriver<PD::HidDriver>();
} }
void HorizonCtr::Deinit() { void HorizonCtr::Deinit() {
+1
View File
@@ -29,6 +29,7 @@ void HorizonNX::Init() {
gladLoadGL(); gladLoadGL();
glfwSwapInterval(1); glfwSwapInterval(1);
PD::Gfx::UseDriver<PD::GfxOpenGL3>(); PD::Gfx::UseDriver<PD::GfxOpenGL3>();
PD::Hid::UseDriver<PD::HidGlfw>(impl->win);
} }
void HorizonNX::Deinit() { void HorizonNX::Deinit() {