Compare commits
7 commits
940c2bb07e
...
77d359fa52
| Author | SHA1 | Date | |
|---|---|---|---|
| 77d359fa52 | |||
| c5b8eb4f49 | |||
| 810770564e | |||
| bb0c3bb178 | |||
| 056a855a32 | |||
| 9c76feb150 | |||
| 379b1e53a0 |
9 changed files with 65 additions and 7 deletions
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include <psemek/bt/node.hpp>
|
||||
#include <psemek/bt/assert.hpp>
|
||||
|
||||
|
|
@ -18,7 +20,7 @@ namespace psemek::bt
|
|||
using typename node_type::finished;
|
||||
using typename node_type::status;
|
||||
|
||||
static_assert(std::is_same_v<std::result_of_t<ActionFn(Time, Args...)>, void>, "bt::action result type must be void");
|
||||
static_assert(std::is_same_v<std::invoke_result_t<ActionFn, Time, Args...>, void>, "bt::action result type must be void");
|
||||
|
||||
action_node(ActionFn && action_fn)
|
||||
: action_fn_(std::move(action_fn))
|
||||
|
|
|
|||
|
|
@ -25,4 +25,4 @@ namespace psemek::bt
|
|||
|
||||
}
|
||||
|
||||
#define bt_assert(cond, ...) (void)(!(cond) && ::psemek::bt::assertion_failed("BT assertion failed: ", #cond, " ", ##__VA_ARGS__, " (", __FILE__, ":", __LINE__, ")"))
|
||||
#define bt_assert(cond, ...) (void)(!(cond) && ::psemek::bt::assertion_failed("BT assertion failed: ", #cond, " " __VA_OPT__(,) __VA_ARGS__, " (", __FILE__, ":", __LINE__, ")"))
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <psemek/ecs/container.hpp>
|
||||
#include <psemek/util/hash_table.hpp>
|
||||
#include <psemek/util/function.hpp>
|
||||
#include <psemek/util/unused.hpp>
|
||||
|
||||
namespace psemek::ecs
|
||||
{
|
||||
|
|
@ -50,6 +51,7 @@ namespace psemek::ecs
|
|||
}
|
||||
else
|
||||
{
|
||||
unused(this);
|
||||
handler(event);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -27,8 +27,6 @@ namespace psemek::random
|
|||
: range_(range)
|
||||
{}
|
||||
|
||||
uniform_real_distribution(uniform_real_distribution const &) = default;
|
||||
|
||||
template <typename RNG>
|
||||
T operator()(RNG && rng);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,11 +3,29 @@ find_package(SDL2 REQUIRED)
|
|||
file(GLOB_RECURSE PSEMEK_SDL2_HEADERS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "include/*.hpp")
|
||||
file(GLOB_RECURSE PSEMEK_SDL2_SOURCES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "source/*.cpp")
|
||||
|
||||
psemek_add_library(psemek-sdl2 ${PSEMEK_SDL2_HEADERS} ${PSEMEK_SDL2_SOURCES})
|
||||
set(PSEMEK_SDL2_PLATFORM_SOURCES)
|
||||
|
||||
if(APPLE)
|
||||
file(GLOB_RECURSE PSEMEK_SDL2_PLATFORM_SOURCES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "platform/apple/*.m")
|
||||
endif()
|
||||
|
||||
psemek_add_library(psemek-sdl2 ${PSEMEK_SDL2_HEADERS} ${PSEMEK_SDL2_SOURCES} ${PSEMEK_SDL2_PLATFORM_SOURCES})
|
||||
target_include_directories(psemek-sdl2 PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||
target_link_libraries(psemek-sdl2 PUBLIC psemek-log psemek-util psemek-audio psemek-app SDL2)
|
||||
if(PSEMEK_GRAPHICS_API STREQUAL OPENGL)
|
||||
target_link_libraries(psemek-sdl2 PUBLIC psemek-gfx)
|
||||
elseif(PSEMEK_GRAPHICS_API STREQUAL WEBGPU)
|
||||
target_link_libraries(psemek-sdl2 PUBLIC psemek-wgpu)
|
||||
# TODO: shouldn't these come from SDL2 dependencies?
|
||||
find_library(FOUNDATION_FRAMEWORK Foundation REQUIRED)
|
||||
find_library(METAL_FRAMEWORK Metal REQUIRED)
|
||||
find_library(QUARTZCORE_FRAMEWORK QuartzCore REQUIRED)
|
||||
|
||||
target_link_libraries(psemek-sdl2
|
||||
PUBLIC
|
||||
psemek-wgpu
|
||||
PRIVATE
|
||||
${FOUNDATION_FRAMEWORK}
|
||||
${METAL_FRAMEWORK}
|
||||
${QUARTZCORE_FRAMEWORK}
|
||||
)
|
||||
endif()
|
||||
|
|
|
|||
14
libs/sdl2/platform/apple/metal.m
Normal file
14
libs/sdl2/platform/apple/metal.m
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#ifdef __APPLE__
|
||||
#include <Foundation/Foundation.h>
|
||||
#include <QuartzCore/CAMetalLayer.h>
|
||||
#include <Cocoa/Cocoa.h>
|
||||
|
||||
void * metal_layer_from_nswindow(void * nswindow_raw)
|
||||
{
|
||||
NSWindow * ns_window = (NSWindow*)nswindow_raw;
|
||||
[ns_window.contentView setWantsLayer : YES];
|
||||
id metal_layer = [CAMetalLayer layer];
|
||||
[ns_window.contentView setLayer : metal_layer];
|
||||
return metal_layer;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -10,6 +10,9 @@
|
|||
#include <psemek/wgpu/instance.hpp>
|
||||
#include <psemek/wgpu/logging.hpp>
|
||||
#include <psemek/wgpu/version.hpp>
|
||||
#ifdef __APPLE__
|
||||
extern "C" void * metal_layer_from_nswindow(void * nswindow);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <SDL2/SDL_syswm.h>
|
||||
|
|
@ -86,8 +89,12 @@ namespace psemek::sdl2
|
|||
wgpu::surface::descriptor surface_descriptor;
|
||||
#if defined(_WIN32)
|
||||
surface_descriptor.chain = {wgpu::surface::from_windows_hwnd{ .hinstance = wminfo.info.win.hinstance, .hwnd = wminfo.info.win.window }};
|
||||
#else
|
||||
#elif defined(__linux__)
|
||||
surface_descriptor.chain = {wgpu::surface::from_xlib_window{ .display = wminfo.info.x11.display, .window = wminfo.info.x11.window }};
|
||||
#elif defined(__APPLE__)
|
||||
surface_descriptor.chain = {wgpu::surface::from_metal_layer{ .layer = metal_layer_from_nswindow(wminfo.info.cocoa.window) }};
|
||||
#else
|
||||
#error Unknown platform
|
||||
#endif
|
||||
wgpu_surface_ = wgpu_instance_.create_surface(surface_descriptor);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,10 @@
|
|||
#include <winerror.h>
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <mach-o/dyld.h>
|
||||
#endif
|
||||
|
||||
namespace psemek::util
|
||||
{
|
||||
|
||||
|
|
@ -29,6 +33,12 @@ namespace psemek::util
|
|||
return std::filesystem::path(result);
|
||||
#elif defined __linux__
|
||||
return std::filesystem::canonical("/proc/self/exe");
|
||||
#elif defined __APPLE__
|
||||
uint32_t path_length = 0;
|
||||
_NSGetExecutablePath(nullptr, &path_length);
|
||||
std::string path(path_length, '\0');
|
||||
_NSGetExecutablePath(path.data(), &path_length);
|
||||
return std::filesystem::path(std::move(path));
|
||||
#else
|
||||
throw exception("executable_path() is not implemented for this platform");
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -66,10 +66,17 @@ namespace psemek::wgpu
|
|||
struct chained_struct
|
||||
{
|
||||
template <typename T>
|
||||
requires(!std::is_same_v<std::remove_reference_t<T>, chained_struct>)
|
||||
chained_struct(T && value)
|
||||
: impl_(to_chained_struct(std::move(value)))
|
||||
{}
|
||||
|
||||
chained_struct(chained_struct const &) = default;
|
||||
chained_struct(chained_struct &&) = default;
|
||||
|
||||
chained_struct & operator = (chained_struct const &) = default;
|
||||
chained_struct & operator = (chained_struct &&) = default;
|
||||
|
||||
void * ptr() const
|
||||
{
|
||||
return impl_->ptr();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue