Reformat platform code
This commit is contained in:
parent
3c9835a662
commit
c0928ea80c
11 changed files with 488 additions and 543 deletions
|
@ -1,23 +1,23 @@
|
|||
if(ENABLE_WINDOWS)
|
||||
add_subdirectory(sdl)
|
||||
endif()
|
||||
if (ENABLE_WINDOWS)
|
||||
add_subdirectory(sdl)
|
||||
endif ()
|
||||
|
||||
if(ENABLE_LINUX)
|
||||
add_subdirectory(sdl)
|
||||
endif()
|
||||
if (ENABLE_LINUX)
|
||||
add_subdirectory(sdl)
|
||||
endif ()
|
||||
|
||||
if(ENABLE_MACOS)
|
||||
add_subdirectory(sdl)
|
||||
endif()
|
||||
if (ENABLE_MACOS)
|
||||
add_subdirectory(sdl)
|
||||
endif ()
|
||||
|
||||
if(ENABLE_IOS)
|
||||
add_subdirectory(ios)
|
||||
endif()
|
||||
if (ENABLE_IOS)
|
||||
add_subdirectory(ios)
|
||||
endif ()
|
||||
|
||||
if(ENABLE_TVOS)
|
||||
add_subdirectory(tvos)
|
||||
endif()
|
||||
if (ENABLE_TVOS)
|
||||
add_subdirectory(tvos)
|
||||
endif ()
|
||||
|
||||
if(ENABLE_WEB)
|
||||
add_subdirectory(web)
|
||||
endif()
|
||||
if (ENABLE_WEB)
|
||||
add_subdirectory(web)
|
||||
endif ()
|
|
@ -1,31 +1,31 @@
|
|||
cmake_minimum_required(VERSION 3.7)
|
||||
include(BundleUtilities)
|
||||
|
||||
if(ENABLE_METAL)
|
||||
find_library(METAL Metal)
|
||||
if (ENABLE_METAL)
|
||||
find_library(METAL Metal)
|
||||
|
||||
set(EXTRA_LIBRARIES GFXMetal ${METAL} ${EXTRA_LIBRARIES})
|
||||
endif()
|
||||
set(EXTRA_LIBRARIES GFXMetal ${METAL} ${EXTRA_LIBRARIES})
|
||||
endif ()
|
||||
|
||||
if(ENABLE_VULKAN)
|
||||
set(EXTRA_LIBRARIES GFXVulkan ${EXTRA_LIBRARIES})
|
||||
endif()
|
||||
if (ENABLE_VULKAN)
|
||||
set(EXTRA_LIBRARIES GFXVulkan ${EXTRA_LIBRARIES})
|
||||
endif ()
|
||||
|
||||
set(APP_HEADER_FILES
|
||||
${PROJECT_SOURCE_DIR}/platforms/uikit/AppDelegate.h
|
||||
)
|
||||
${PROJECT_SOURCE_DIR}/platforms/uikit/AppDelegate.h
|
||||
)
|
||||
|
||||
set(APP_SOURCE_FILES
|
||||
${PROJECT_SOURCE_DIR}/platforms/uikit/AppDelegate.m
|
||||
${PROJECT_SOURCE_DIR}/platforms/uikit/main.m
|
||||
)
|
||||
${PROJECT_SOURCE_DIR}/platforms/uikit/AppDelegate.m
|
||||
${PROJECT_SOURCE_DIR}/platforms/uikit/main.m
|
||||
)
|
||||
|
||||
set(RESOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Main.storyboard
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/LaunchScreen.storyboard
|
||||
${CMAKE_SOURCE_DIR}/example/data
|
||||
${CMAKE_BINARY_DIR}/bin/shaders
|
||||
)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Main.storyboard
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/LaunchScreen.storyboard
|
||||
${CMAKE_SOURCE_DIR}/example/data
|
||||
${CMAKE_BINARY_DIR}/bin/shaders
|
||||
)
|
||||
|
||||
include(../../cmake/AddPlatformExecutable.cmake)
|
||||
|
||||
|
@ -40,80 +40,80 @@ find_library(METAL Metal)
|
|||
find_library(CORE_GRAPHICS CoreGraphics)
|
||||
|
||||
add_platform(
|
||||
MAIN_FILE
|
||||
../uikit/ViewController.mm.in
|
||||
SRC
|
||||
MACOSX_BUNDLE
|
||||
${APP_HEADER_FILES}
|
||||
${APP_SOURCE_FILES}
|
||||
${RESOURCES}
|
||||
${PROJECT_SOURCE_DIR}/platforms/uikit/file.mm
|
||||
EXECUTABLE_PROPERTIES
|
||||
MACOSX_BUNDLE ON
|
||||
LINK_LIBRARIES
|
||||
Core
|
||||
${UIKIT}
|
||||
${FOUNDATION}
|
||||
${MOBILECORESERVICES}
|
||||
${CFNETWORK}
|
||||
${SYSTEMCONFIGURATION}
|
||||
${GAMECONTROLLER}
|
||||
${QUARTZ}
|
||||
${METAL}
|
||||
${CORE_GRAPHICS}
|
||||
${EXTRA_LIBRARIES}
|
||||
GFXDummy
|
||||
COMPILE_OPTIONS
|
||||
MAIN_FILE
|
||||
../uikit/ViewController.mm.in
|
||||
SRC
|
||||
MACOSX_BUNDLE
|
||||
${APP_HEADER_FILES}
|
||||
${APP_SOURCE_FILES}
|
||||
${RESOURCES}
|
||||
${PROJECT_SOURCE_DIR}/platforms/uikit/file.mm
|
||||
EXECUTABLE_PROPERTIES
|
||||
MACOSX_BUNDLE ON
|
||||
LINK_LIBRARIES
|
||||
Core
|
||||
${UIKIT}
|
||||
${FOUNDATION}
|
||||
${MOBILECORESERVICES}
|
||||
${CFNETWORK}
|
||||
${SYSTEMCONFIGURATION}
|
||||
${GAMECONTROLLER}
|
||||
${QUARTZ}
|
||||
${METAL}
|
||||
${CORE_GRAPHICS}
|
||||
${EXTRA_LIBRARIES}
|
||||
GFXDummy
|
||||
COMPILE_OPTIONS
|
||||
)
|
||||
|
||||
function(add_platform_commands APP_NAME data_directory)
|
||||
# you should set these as cmake options as these reset on cmake reconfigure
|
||||
#set(APP_BUNDLE_IDENTIFIER "your app bundle id here, such as com.redstrate.prismtest")
|
||||
#set(CODE_SIGN_IDENTITY "iPhone Developer")
|
||||
#set(DEVELOPMENT_TEAM_ID "your dev team id here")
|
||||
# you should set these as cmake options as these reset on cmake reconfigure
|
||||
#set(APP_BUNDLE_IDENTIFIER "your app bundle id here, such as com.redstrate.prismtest")
|
||||
#set(CODE_SIGN_IDENTITY "iPhone Developer")
|
||||
#set(DEVELOPMENT_TEAM_ID "your dev team id here")
|
||||
|
||||
set(DEPLOYMENT_TARGET 13.5)
|
||||
set(DEVICE_FAMILY "1,2")
|
||||
set(DEPLOYMENT_TARGET 13.5)
|
||||
set(DEVICE_FAMILY "1,2")
|
||||
|
||||
# plist values
|
||||
set(PRODUCT_NAME ${APP_NAME})
|
||||
set(EXECUTABLE_NAME ${APP_NAME})
|
||||
set(MACOSX_BUNDLE_EXECUTABLE_NAME ${APP_NAME})
|
||||
set(MACOSX_BUNDLE_INFO_STRING ${APP_BUNDLE_IDENTIFIER})
|
||||
set(MACOSX_BUNDLE_GUI_IDENTIFIER ${APP_BUNDLE_IDENTIFIER})
|
||||
set(MACOSX_BUNDLE_BUNDLE_NAME ${APP_BUNDLE_IDENTIFIER})
|
||||
set(MACOSX_BUNDLE_ICON_FILE "")
|
||||
set(MACOSX_BUNDLE_LONG_VERSION_STRING "1.0")
|
||||
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "1.0")
|
||||
set(MACOSX_BUNDLE_BUNDLE_VERSION "1.0")
|
||||
set(MACOSX_BUNDLE_COPYRIGHT "Copyright lololol")
|
||||
set(MACOSX_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET})
|
||||
# plist values
|
||||
set(PRODUCT_NAME ${APP_NAME})
|
||||
set(EXECUTABLE_NAME ${APP_NAME})
|
||||
set(MACOSX_BUNDLE_EXECUTABLE_NAME ${APP_NAME})
|
||||
set(MACOSX_BUNDLE_INFO_STRING ${APP_BUNDLE_IDENTIFIER})
|
||||
set(MACOSX_BUNDLE_GUI_IDENTIFIER ${APP_BUNDLE_IDENTIFIER})
|
||||
set(MACOSX_BUNDLE_BUNDLE_NAME ${APP_BUNDLE_IDENTIFIER})
|
||||
set(MACOSX_BUNDLE_ICON_FILE "")
|
||||
set(MACOSX_BUNDLE_LONG_VERSION_STRING "1.0")
|
||||
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "1.0")
|
||||
set(MACOSX_BUNDLE_BUNDLE_VERSION "1.0")
|
||||
set(MACOSX_BUNDLE_COPYRIGHT "Copyright lololol")
|
||||
set(MACOSX_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET})
|
||||
|
||||
set(IOS_DIRECTORY ${PROJECT_SOURCE_DIR}/platforms/ios)
|
||||
set(IOS_DIRECTORY ${PROJECT_SOURCE_DIR}/platforms/ios)
|
||||
|
||||
configure_file(${PROJECT_SOURCE_DIR}/platforms/uikit/plist.in ${CMAKE_BINARY_DIR}/${add_platform_executable_TARGET}Info.plist)
|
||||
configure_file(${PROJECT_SOURCE_DIR}/platforms/uikit/plist.in ${CMAKE_BINARY_DIR}/${add_platform_executable_TARGET}Info.plist)
|
||||
|
||||
set(RESOURCES
|
||||
${IOS_DIRECTORY}/Main.storyboard
|
||||
${IOS_DIRECTORY}/LaunchScreen.storyboard
|
||||
${PROJECT_SOURCE_DIR}/example/data
|
||||
${CMAKE_BINARY_DIR}/bin/shaders
|
||||
)
|
||||
set(RESOURCES
|
||||
${IOS_DIRECTORY}/Main.storyboard
|
||||
${IOS_DIRECTORY}/LaunchScreen.storyboard
|
||||
${PROJECT_SOURCE_DIR}/example/data
|
||||
${CMAKE_BINARY_DIR}/bin/shaders
|
||||
)
|
||||
|
||||
set_target_properties(${APP_NAME} PROPERTIES
|
||||
XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf-with-dsym"
|
||||
RESOURCE "${RESOURCES}"
|
||||
XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES"
|
||||
XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET}
|
||||
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ${CODE_SIGN_IDENTITY}
|
||||
XCODE_ATTRIBUTE_DEVELOPMENT_TEAM ${DEVELOPMENT_TEAM_ID}
|
||||
XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY ${DEVICE_FAMILY}
|
||||
MACOSX_BUNDLE TRUE
|
||||
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_BINARY_DIR}/${APP_NAME}Info.plist"
|
||||
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES
|
||||
XCODE_ATTRIBUTE_COMBINE_HIDPI_IMAGES NO
|
||||
XCODE_ATTRIBUTE_INSTALL_PATH "$(LOCAL_APPS_DIR)"
|
||||
XCODE_ATTRIBUTE_ENABLE_TESTABILITY YES
|
||||
XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN YES
|
||||
)
|
||||
set_target_properties(${APP_NAME} PROPERTIES
|
||||
XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf-with-dsym"
|
||||
RESOURCE "${RESOURCES}"
|
||||
XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES"
|
||||
XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET}
|
||||
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ${CODE_SIGN_IDENTITY}
|
||||
XCODE_ATTRIBUTE_DEVELOPMENT_TEAM ${DEVELOPMENT_TEAM_ID}
|
||||
XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY ${DEVICE_FAMILY}
|
||||
MACOSX_BUNDLE TRUE
|
||||
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_BINARY_DIR}/${APP_NAME}Info.plist"
|
||||
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES
|
||||
XCODE_ATTRIBUTE_COMBINE_HIDPI_IMAGES NO
|
||||
XCODE_ATTRIBUTE_INSTALL_PATH "$(LOCAL_APPS_DIR)"
|
||||
XCODE_ATTRIBUTE_ENABLE_TESTABILITY YES
|
||||
XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN YES
|
||||
)
|
||||
endfunction()
|
||||
|
|
|
@ -1,32 +1,32 @@
|
|||
include(../../cmake/AddPlatformExecutable.cmake)
|
||||
|
||||
if(ENABLE_METAL)
|
||||
if (ENABLE_METAL)
|
||||
find_library(METAL Metal)
|
||||
|
||||
set(EXTRA_LIBRARIES GFXMetal ${METAL} ${EXTRA_LIBRARIES})
|
||||
set(EXTRA_SRC ${CMAKE_CURRENT_SOURCE_DIR}/sdl_metal.mm ${EXTRA_SRC})
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if(ENABLE_VULKAN)
|
||||
if (ENABLE_VULKAN)
|
||||
set(EXTRA_LIBRARIES GFXVulkan ${EXTRA_LIBRARIES})
|
||||
set(EXTRA_SRC ${CMAKE_CURRENT_SOURCE_DIR}/sdl_vulkan.cpp ${EXTRA_SRC})
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if(ENABLE_DX12)
|
||||
if (ENABLE_DX12)
|
||||
set(EXTRA_LIBRARIES GFXDX12 ${EXTRA_LIBRARIES})
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if(TARGET SDL2::SDL2)
|
||||
if (TARGET SDL2::SDL2)
|
||||
set(EXTRA_LIBRARIES SDL2::SDL2 ${EXTRA_LIBRARIES})
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if(TARGET SDL2::Main)
|
||||
if (TARGET SDL2::Main)
|
||||
set(EXTRA_LIBRARIES SDL2::Main ${EXTRA_LIBRARIES})
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if(TARGET SDL2::SDL2main)
|
||||
if (TARGET SDL2::SDL2main)
|
||||
set(EXTRA_LIBRARIES SDL2::SDL2main ${EXTRA_LIBRARIES})
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
add_platform(
|
||||
SRC
|
||||
|
@ -44,12 +44,12 @@ add_platform(
|
|||
)
|
||||
|
||||
function(add_platform_commands target data_directory skip_data)
|
||||
if(NOT skip_data)
|
||||
if(ENABLE_MACOS)
|
||||
if (NOT skip_data)
|
||||
if (ENABLE_MACOS)
|
||||
file(MAKE_DIRECTORY $<TARGET_FILE_DIR:${target}>/../Resources/game)
|
||||
|
||||
add_custom_target(${target}_copy_assets
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${data_directory} $<TARGET_FILE_DIR:${target}>/../Resources/game)
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${data_directory} $<TARGET_FILE_DIR:${target}>/../Resources/game)
|
||||
|
||||
file(MAKE_DIRECTORY $<TARGET_FILE_DIR:${target}>/../Resources/base)
|
||||
|
||||
|
@ -57,7 +57,7 @@ function(add_platform_commands target data_directory skip_data)
|
|||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/bin/base $<TARGET_FILE_DIR:${target}>/../Resources/base)
|
||||
|
||||
add_dependencies(${target} ${target}_copy_assets ${target}_copy_base)
|
||||
else()
|
||||
else ()
|
||||
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin/game)
|
||||
|
||||
add_custom_target(${target}_copy_assets
|
||||
|
@ -65,6 +65,6 @@ function(add_platform_commands target data_directory skip_data)
|
|||
)
|
||||
|
||||
add_dependencies(${target} ${target}_copy_assets)
|
||||
endif()
|
||||
endif()
|
||||
endif ()
|
||||
endif ()
|
||||
endfunction()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <@APP_INCLUDE@>
|
||||
#include <engine.hpp>
|
||||
#include <chrono>
|
||||
#include <engine.hpp>
|
||||
|
||||
#include "platform.hpp"
|
||||
#include <string_utils.hpp>
|
||||
|
@ -9,25 +9,25 @@
|
|||
#include <SDL_vulkan.h>
|
||||
|
||||
#ifdef ENABLE_DX12
|
||||
#include "gfx_dx12.hpp"
|
||||
#include "gfx_dx12.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_VULKAN
|
||||
#include "gfx_vulkan.hpp"
|
||||
#include "gfx_vulkan.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_METAL
|
||||
#include "gfx_metal.hpp"
|
||||
#include "gfx_metal.hpp"
|
||||
#endif
|
||||
|
||||
#include "gfx_dummy.hpp"
|
||||
|
||||
#if defined(PLATFORM_WINDOWS) && !defined(__MINGW32__)
|
||||
#include <winrt/Windows.UI.ViewManagement.h>
|
||||
#pragma comment(lib, "windowsapp")
|
||||
#include <winrt/Windows.UI.ViewManagement.h>
|
||||
#pragma comment(lib, "windowsapp")
|
||||
#endif
|
||||
|
||||
@APP_CLASS@* app = nullptr;
|
||||
@APP_CLASS@ * app = nullptr;
|
||||
GFX* gfx_interface = nullptr;
|
||||
|
||||
std::vector<SDL_Window*> windows;
|
||||
|
@ -35,8 +35,8 @@ std::map<SDL_Window*, SDL_Renderer*> renderers;
|
|||
SDL_Window* main_window = nullptr;
|
||||
|
||||
extern "C" SDL_Window* get_window(const platform::window_ptr index) {
|
||||
for(auto& window : windows) {
|
||||
if(window == index)
|
||||
for (auto& window : windows) {
|
||||
if (window == index)
|
||||
return window;
|
||||
}
|
||||
|
||||
|
@ -44,8 +44,8 @@ extern "C" SDL_Window* get_window(const platform::window_ptr index) {
|
|||
}
|
||||
|
||||
SDL_Window* get_window_by_sdl_id(const Uint32 id) {
|
||||
for(auto& window : windows) {
|
||||
if(SDL_GetWindowID(window) == id)
|
||||
for (auto& window : windows) {
|
||||
if (SDL_GetWindowID(window) == id)
|
||||
return window;
|
||||
}
|
||||
|
||||
|
@ -61,29 +61,28 @@ void* get_next_metal_drawable(platform::window_ptr window);
|
|||
void* create_vulkan_surface(platform::window_ptr window, void* surface_creation_info);
|
||||
#endif
|
||||
|
||||
static std::map<InputButton, int> inputToKeyCode = { {
|
||||
{InputButton::C, SDL_SCANCODE_C},
|
||||
{InputButton::V, SDL_SCANCODE_V},
|
||||
{InputButton::X, SDL_SCANCODE_X},
|
||||
{InputButton::Y, SDL_SCANCODE_Y},
|
||||
{InputButton::Z, SDL_SCANCODE_Z},
|
||||
{InputButton::Backspace, SDL_SCANCODE_BACKSPACE},
|
||||
{InputButton::Enter, SDL_SCANCODE_RETURN},
|
||||
{InputButton::W, SDL_SCANCODE_W},
|
||||
{InputButton::A, SDL_SCANCODE_A},
|
||||
{InputButton::S, SDL_SCANCODE_S},
|
||||
{InputButton::D, SDL_SCANCODE_D},
|
||||
{InputButton::Q, SDL_SCANCODE_Q},
|
||||
{InputButton::Shift, SDL_SCANCODE_LSHIFT},
|
||||
{InputButton::Alt, SDL_SCANCODE_LALT},
|
||||
{InputButton::Super, SDL_SCANCODE_APPLICATION},
|
||||
{InputButton::Escape, SDL_SCANCODE_ESCAPE},
|
||||
{InputButton::Tab, SDL_SCANCODE_TAB},
|
||||
{InputButton::Ctrl, SDL_SCANCODE_LCTRL},
|
||||
{InputButton::Space, SDL_SCANCODE_SPACE},
|
||||
{InputButton::LeftArrow, SDL_SCANCODE_LEFT},
|
||||
{InputButton::RightArrow, SDL_SCANCODE_RIGHT}
|
||||
}};
|
||||
static std::map<InputButton, int> inputToKeyCode = {
|
||||
{{InputButton::C, SDL_SCANCODE_C},
|
||||
{InputButton::V, SDL_SCANCODE_V},
|
||||
{InputButton::X, SDL_SCANCODE_X},
|
||||
{InputButton::Y, SDL_SCANCODE_Y},
|
||||
{InputButton::Z, SDL_SCANCODE_Z},
|
||||
{InputButton::Backspace, SDL_SCANCODE_BACKSPACE},
|
||||
{InputButton::Enter, SDL_SCANCODE_RETURN},
|
||||
{InputButton::W, SDL_SCANCODE_W},
|
||||
{InputButton::A, SDL_SCANCODE_A},
|
||||
{InputButton::S, SDL_SCANCODE_S},
|
||||
{InputButton::D, SDL_SCANCODE_D},
|
||||
{InputButton::Q, SDL_SCANCODE_Q},
|
||||
{InputButton::Shift, SDL_SCANCODE_LSHIFT},
|
||||
{InputButton::Alt, SDL_SCANCODE_LALT},
|
||||
{InputButton::Super, SDL_SCANCODE_APPLICATION},
|
||||
{InputButton::Escape, SDL_SCANCODE_ESCAPE},
|
||||
{InputButton::Tab, SDL_SCANCODE_TAB},
|
||||
{InputButton::Ctrl, SDL_SCANCODE_LCTRL},
|
||||
{InputButton::Space, SDL_SCANCODE_SPACE},
|
||||
{InputButton::LeftArrow, SDL_SCANCODE_LEFT},
|
||||
{InputButton::RightArrow, SDL_SCANCODE_RIGHT}}};
|
||||
|
||||
/*
|
||||
* Platform functions"
|
||||
|
@ -94,26 +93,27 @@ const char* platform::get_name() {
|
|||
}
|
||||
|
||||
bool platform::supports_feature(const PlatformFeature feature) {
|
||||
if(feature == PlatformFeature::Windowing)
|
||||
if (feature == PlatformFeature::Windowing)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
platform::window_ptr platform::open_window(const std::string_view title, const prism::Rectangle rect, const WindowFlags flags) {
|
||||
platform::window_ptr
|
||||
platform::open_window(const std::string_view title, const prism::Rectangle rect, const WindowFlags flags) {
|
||||
auto& win = windows.emplace_back();
|
||||
|
||||
int sdl_flags = SDL_WINDOW_ALLOW_HIGHDPI;
|
||||
if(gfx_interface->required_context() == GFXContext::Vulkan)
|
||||
if (gfx_interface->required_context() == GFXContext::Vulkan)
|
||||
sdl_flags |= SDL_WINDOW_VULKAN;
|
||||
|
||||
if(flags & WindowFlags::Borderless)
|
||||
if (flags & WindowFlags::Borderless)
|
||||
sdl_flags |= SDL_WINDOW_BORDERLESS;
|
||||
|
||||
if(flags & WindowFlags::Resizable)
|
||||
if (flags & WindowFlags::Resizable)
|
||||
sdl_flags |= SDL_WINDOW_RESIZABLE;
|
||||
|
||||
if(flags & WindowFlags::Hidden)
|
||||
if (flags & WindowFlags::Hidden)
|
||||
sdl_flags |= SDL_WINDOW_HIDDEN;
|
||||
|
||||
auto resolution = platform::get_monitor_resolution();
|
||||
|
@ -121,28 +121,28 @@ platform::window_ptr platform::open_window(const std::string_view title, const p
|
|||
int real_x = rect.offset.x;
|
||||
int real_y = rect.offset.y;
|
||||
|
||||
if(rect.offset.x <= -1 || rect.offset.x > resolution.extent.width)
|
||||
if (rect.offset.x <= -1 || rect.offset.x > resolution.extent.width)
|
||||
real_x = SDL_WINDOWPOS_CENTERED;
|
||||
|
||||
if(rect.offset.y <= -1 || rect.offset.x > resolution.extent.height)
|
||||
if (rect.offset.y <= -1 || rect.offset.x > resolution.extent.height)
|
||||
real_y = SDL_WINDOWPOS_CENTERED;
|
||||
|
||||
int real_width = rect.extent.width;
|
||||
int real_height = rect.extent.height;
|
||||
|
||||
if(rect.extent.width <= -1 || rect.extent.width > resolution.extent.width)
|
||||
if (rect.extent.width <= -1 || rect.extent.width > resolution.extent.width)
|
||||
real_width = 640;
|
||||
|
||||
if(rect.extent.height <= -1 || rect.extent.height > resolution.extent.height)
|
||||
if (rect.extent.height <= -1 || rect.extent.height > resolution.extent.height)
|
||||
real_height = 480;
|
||||
|
||||
win = SDL_CreateWindow(title.data(), real_x, real_y, real_width, real_height, sdl_flags);
|
||||
|
||||
if(windows.size() == 1)
|
||||
if (windows.size() == 1)
|
||||
main_window = win;
|
||||
|
||||
#ifdef ENABLE_METAL
|
||||
if(gfx_interface->required_context() == GFXContext::Metal) {
|
||||
if (gfx_interface->required_context() == GFXContext::Metal) {
|
||||
SDL_Renderer* renderer = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
|
||||
renderers[win] = renderer;
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ void platform::show_window(const platform::window_ptr index) {
|
|||
}
|
||||
|
||||
bool platform::get_key_down(const InputButton key) {
|
||||
const Uint8 *state = SDL_GetKeyboardState(NULL);
|
||||
const Uint8* state = SDL_GetKeyboardState(NULL);
|
||||
|
||||
return state[inputToKeyCode[key]] && state[SDL_SCANCODE_DOWN];
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ prism::Offset platform::get_screen_cursor_position() {
|
|||
|
||||
bool platform::get_mouse_button_down(const int button) {
|
||||
Uint8 sdl_button = SDL_BUTTON_LEFT;
|
||||
switch(button) {
|
||||
switch (button) {
|
||||
case 0:
|
||||
sdl_button = SDL_BUTTON_LEFT;
|
||||
break;
|
||||
|
@ -324,21 +324,21 @@ void platform::end_text_input() {
|
|||
|
||||
bool platform::supports_context(GFXContext context) {
|
||||
#ifdef ENABLE_DX12
|
||||
if(context == GFXContext::DirectX)
|
||||
if (context == GFXContext::DirectX)
|
||||
return true;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_VULKAN
|
||||
if(context == GFXContext::Vulkan)
|
||||
if (context == GFXContext::Vulkan)
|
||||
return true;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_METAL
|
||||
if(context == GFXContext::Metal)
|
||||
if (context == GFXContext::Metal)
|
||||
return true;
|
||||
#endif
|
||||
|
||||
if(context == GFXContext::None)
|
||||
if (context == GFXContext::None)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -346,13 +346,13 @@ bool platform::supports_context(GFXContext context) {
|
|||
|
||||
void platform::initialize_context(const GFXContext context) {
|
||||
#ifdef ENABLE_METAL
|
||||
if(context == GFXContext::Metal) {
|
||||
if (context == GFXContext::Metal) {
|
||||
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "metal");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_VULKAN
|
||||
if(context == GFXContext::Vulkan) {
|
||||
if (context == GFXContext::Vulkan) {
|
||||
SDL_Vulkan_LoadLibrary(nullptr);
|
||||
}
|
||||
#endif
|
||||
|
@ -360,7 +360,7 @@ void platform::initialize_context(const GFXContext context) {
|
|||
|
||||
void* platform::get_context_information() {
|
||||
#ifdef ENABLE_VULKAN
|
||||
if(gfx_interface->required_context() == GFXContext::Vulkan) {
|
||||
if (gfx_interface->required_context() == GFXContext::Vulkan) {
|
||||
unsigned int count = 0;
|
||||
SDL_Vulkan_GetInstanceExtensions(nullptr, &count, nullptr);
|
||||
|
||||
|
@ -379,13 +379,13 @@ void* platform::get_context_information() {
|
|||
|
||||
void* platform::create_surface(window_ptr window, void* surface_creation_info) {
|
||||
#ifdef ENABLE_VULKAN
|
||||
if(gfx_interface->required_context() == GFXContext::Vulkan) {
|
||||
if (gfx_interface->required_context() == GFXContext::Vulkan) {
|
||||
return create_vulkan_surface(window, surface_creation_info);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_METAL
|
||||
if(gfx_interface->required_context() == GFXContext::Metal) {
|
||||
if (gfx_interface->required_context() == GFXContext::Metal) {
|
||||
return create_metal_surface(window, surface_creation_info);
|
||||
}
|
||||
#endif
|
||||
|
@ -395,7 +395,7 @@ void* platform::create_surface(window_ptr window, void* surface_creation_info) {
|
|||
|
||||
void* platform::get_next_image(window_ptr window) {
|
||||
#ifdef ENABLE_METAL
|
||||
if(gfx_interface->required_context() == GFXContext::Metal) {
|
||||
if (gfx_interface->required_context() == GFXContext::Metal) {
|
||||
return get_next_metal_drawable(window);
|
||||
}
|
||||
#endif
|
||||
|
@ -403,12 +403,11 @@ void* platform::get_next_image(window_ptr window) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
template<class GFXBackend>
|
||||
void try_initialize() {
|
||||
if(gfx_interface == nullptr) {
|
||||
template<class GFXBackend> void try_initialize() {
|
||||
if (gfx_interface == nullptr) {
|
||||
auto backend = new GFXBackend();
|
||||
const bool supported = backend->is_supported() && platform::supports_context(backend->required_context());
|
||||
if(!supported) {
|
||||
if (!supported) {
|
||||
prism::log("Failed to initialize GFX backend... trying next...");
|
||||
} else {
|
||||
gfx_interface = backend;
|
||||
|
@ -433,39 +432,39 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
// determine gfx context at the beginning
|
||||
#ifdef ENABLE_DX12
|
||||
gfx_backend_order.emplace_back(gfx_backend_initializer{"dx12", []{
|
||||
try_initialize<gfx_dx12>();
|
||||
}});
|
||||
gfx_backend_order.emplace_back(gfx_backend_initializer{"dx12", [] {
|
||||
try_initialize<gfx_dx12>();
|
||||
}});
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_METAL
|
||||
gfx_backend_order.emplace_back(gfx_backend_initializer{"metal", []{
|
||||
try_initialize<GFXMetal>();
|
||||
}});
|
||||
gfx_backend_order.emplace_back(gfx_backend_initializer{"metal", [] {
|
||||
try_initialize<GFXMetal>();
|
||||
}});
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_VULKAN
|
||||
gfx_backend_order.emplace_back(gfx_backend_initializer{"vulkan", []{
|
||||
try_initialize<GFXVulkan>();
|
||||
}});
|
||||
gfx_backend_order.emplace_back(gfx_backend_initializer{"vulkan", [] {
|
||||
try_initialize<GFXVulkan>();
|
||||
}});
|
||||
#endif
|
||||
|
||||
gfx_backend_order.emplace_back(gfx_backend_initializer{"dummy", []{
|
||||
try_initialize<GFXDummy>();
|
||||
}});
|
||||
gfx_backend_order.emplace_back(gfx_backend_initializer{"dummy", [] {
|
||||
try_initialize<GFXDummy>();
|
||||
}});
|
||||
|
||||
for(auto arg : engine->command_line_arguments) {
|
||||
for (auto arg : engine->command_line_arguments) {
|
||||
utility::move_to_front(gfx_backend_order, [arg](gfx_backend_initializer& init) {
|
||||
return arg == "-" + std::string(init.name);
|
||||
});
|
||||
}
|
||||
|
||||
for(auto backend : gfx_backend_order) {
|
||||
for (auto backend : gfx_backend_order) {
|
||||
backend.init_func();
|
||||
}
|
||||
|
||||
GFXCreateInfo info = {};
|
||||
if(gfx_interface->initialize(info)) {
|
||||
if (gfx_interface->initialize(info)) {
|
||||
engine->set_gfx(gfx_interface);
|
||||
} else {
|
||||
return -1;
|
||||
|
@ -481,78 +480,70 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
|
||||
while(!engine->is_quitting()) {
|
||||
SDL_Event event = {};
|
||||
while(SDL_PollEvent(&event)) {
|
||||
switch(event.type) {
|
||||
case SDL_QUIT:
|
||||
engine->quit();
|
||||
break;
|
||||
case SDL_MOUSEWHEEL: {
|
||||
mouse_wheel_x = event.wheel.x;
|
||||
mouse_wheel_y = event.wheel.y;
|
||||
}
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
{
|
||||
int engine_button = 0;
|
||||
if(event.button.button == SDL_BUTTON_RIGHT)
|
||||
engine_button = 1;
|
||||
else if(event.button.button == SDL_BUTTON_MIDDLE)
|
||||
engine_button = 2;
|
||||
while (!engine->is_quitting()) {
|
||||
SDL_Event event = {};
|
||||
while (SDL_PollEvent(&event)) {
|
||||
switch (event.type) {
|
||||
case SDL_QUIT:
|
||||
engine->quit();
|
||||
break;
|
||||
case SDL_MOUSEWHEEL: {
|
||||
mouse_wheel_x = event.wheel.x;
|
||||
mouse_wheel_y = event.wheel.y;
|
||||
} break;
|
||||
case SDL_MOUSEBUTTONDOWN: {
|
||||
int engine_button = 0;
|
||||
if (event.button.button == SDL_BUTTON_RIGHT)
|
||||
engine_button = 1;
|
||||
else if (event.button.button == SDL_BUTTON_MIDDLE)
|
||||
engine_button = 2;
|
||||
|
||||
engine->process_mouse_down(engine_button, {0, 0});
|
||||
}
|
||||
break;
|
||||
case SDL_KEYDOWN:
|
||||
{
|
||||
engine->process_key_down(event.key.keysym.scancode);
|
||||
}
|
||||
break;
|
||||
case SDL_KEYUP:
|
||||
{
|
||||
engine->process_key_up(event.key.keysym.scancode);
|
||||
}
|
||||
break;
|
||||
case SDL_WINDOWEVENT:
|
||||
{
|
||||
if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
|
||||
auto window = get_window_by_sdl_id(event.window.windowID);
|
||||
if(window != nullptr)
|
||||
engine->resize(window, {static_cast<uint32_t>(event.window.data1), static_cast<uint32_t>(event.window.data2)});
|
||||
} else if(event.window.event == SDL_WINDOWEVENT_MOVED) {
|
||||
auto window = get_window_by_sdl_id(event.window.windowID);
|
||||
if(window != nullptr)
|
||||
engine->move(window);
|
||||
} else if(event.window.event == SDL_WINDOWEVENT_CLOSE) {
|
||||
engine->quit();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDL_TEXTINPUT:
|
||||
{
|
||||
engine->process_mouse_down(engine_button, {0, 0});
|
||||
} break;
|
||||
case SDL_KEYDOWN: {
|
||||
engine->process_key_down(event.key.keysym.scancode);
|
||||
} break;
|
||||
case SDL_KEYUP: {
|
||||
engine->process_key_up(event.key.keysym.scancode);
|
||||
} break;
|
||||
case SDL_WINDOWEVENT: {
|
||||
if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
|
||||
auto window = get_window_by_sdl_id(event.window.windowID);
|
||||
if (window != nullptr)
|
||||
engine->resize(
|
||||
window,
|
||||
{static_cast<uint32_t>(event.window.data1), static_cast<uint32_t>(event.window.data2)});
|
||||
} else if (event.window.event == SDL_WINDOWEVENT_MOVED) {
|
||||
auto window = get_window_by_sdl_id(event.window.windowID);
|
||||
if (window != nullptr)
|
||||
engine->move(window);
|
||||
} else if (event.window.event == SDL_WINDOWEVENT_CLOSE) {
|
||||
engine->quit();
|
||||
}
|
||||
} break;
|
||||
case SDL_TEXTINPUT: {
|
||||
engine->process_text_input(event.text.text);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
if(engine->is_quitting())
|
||||
break;
|
||||
if (engine->is_quitting())
|
||||
break;
|
||||
|
||||
auto begin = std::chrono::high_resolution_clock::now();
|
||||
|
||||
float deltatime = (float)std::chrono::duration_cast<std::chrono::nanoseconds>(begin - end).count() / 1000000000ULL;
|
||||
float deltatime =
|
||||
(float)std::chrono::duration_cast<std::chrono::nanoseconds>(begin - end).count() / 1000000000ULL;
|
||||
end = begin;
|
||||
|
||||
engine->update(deltatime);
|
||||
engine->begin_frame(deltatime);
|
||||
|
||||
for(auto window : windows)
|
||||
for (auto window : windows)
|
||||
engine->render(window);
|
||||
|
||||
engine->end_frame();
|
||||
}
|
||||
}
|
||||
|
||||
engine->prepare_quit();
|
||||
|
||||
|
@ -561,17 +552,17 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
#if defined(PLATFORM_WINDOWS) && !defined(__MINGW32__)
|
||||
PlatformTheme platform::get_theme() {
|
||||
using namespace winrt::Windows::UI::ViewManagement;
|
||||
using namespace winrt::Windows::UI::ViewManagement;
|
||||
|
||||
// TODO: figure out if this works pre-anniversary update/other windows other than 10
|
||||
UISettings settings;
|
||||
auto background = settings.GetColorValue(UIColorType::Background);
|
||||
auto foreground = settings.GetColorValue(UIColorType::Foreground);
|
||||
// TODO: figure out if this works pre-anniversary update/other windows other than 10
|
||||
UISettings settings;
|
||||
auto background = settings.GetColorValue(UIColorType::Background);
|
||||
auto foreground = settings.GetColorValue(UIColorType::Foreground);
|
||||
|
||||
if (background == winrt::Windows::UI::Colors::White())
|
||||
return PlatformTheme::Light;
|
||||
else
|
||||
return PlatformTheme::Dark;
|
||||
if (background == winrt::Windows::UI::Colors::White())
|
||||
return PlatformTheme::Light;
|
||||
else
|
||||
return PlatformTheme::Dark;
|
||||
}
|
||||
#else
|
||||
PlatformTheme platform::get_theme() {
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
cmake_minimum_required (VERSION 3.7)
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
|
||||
include(BundleUtilities)
|
||||
|
||||
set(APP_HEADER_FILES
|
||||
${PROJECT_SOURCE_DIR}/platforms/uikit/AppDelegate.h
|
||||
)
|
||||
${PROJECT_SOURCE_DIR}/platforms/uikit/AppDelegate.h
|
||||
)
|
||||
|
||||
set(APP_SOURCE_FILES
|
||||
${PROJECT_SOURCE_DIR}/platforms/uikit/AppDelegate.m
|
||||
${PROJECT_SOURCE_DIR}/platforms/uikit/main.m
|
||||
)
|
||||
${PROJECT_SOURCE_DIR}/platforms/uikit/AppDelegate.m
|
||||
${PROJECT_SOURCE_DIR}/platforms/uikit/main.m
|
||||
)
|
||||
|
||||
set(RESOURCES
|
||||
${PROJECT_SOURCE_DIR}/platforms/tvos/Main.storyboard
|
||||
${PROJECT_SOURCE_DIR}/platforms/tvos/LaunchScreen.storyboard
|
||||
${CMAKE_SOURCE_DIR}/data
|
||||
${CMAKE_BINARY_DIR}/shaders
|
||||
)
|
||||
${PROJECT_SOURCE_DIR}/platforms/tvos/Main.storyboard
|
||||
${PROJECT_SOURCE_DIR}/platforms/tvos/LaunchScreen.storyboard
|
||||
${CMAKE_SOURCE_DIR}/data
|
||||
${CMAKE_BINARY_DIR}/shaders
|
||||
)
|
||||
|
||||
include(../../cmake/AddPlatformExecutable.cmake)
|
||||
|
||||
|
@ -30,73 +30,73 @@ find_library(QUARTZ QuartzCore)
|
|||
find_library(METAL Metal)
|
||||
|
||||
add_platform(
|
||||
MAIN_FILE
|
||||
../uikit/ViewController.mm.in
|
||||
SRC
|
||||
MACOSX_BUNDLE
|
||||
${APP_HEADER_FILES}
|
||||
${APP_SOURCE_FILES}
|
||||
${RESOURCES}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../uikit/file.mm
|
||||
EXECUTABLE_PROPERTIES
|
||||
MACOSX_BUNDLE ON
|
||||
LINK_LIBRARIES
|
||||
Core
|
||||
GFXMetal
|
||||
${UIKIT}
|
||||
${FOUNDATION}
|
||||
${MOBILECORESERVICES}
|
||||
${CFNETWORK}
|
||||
${SYSTEMCONFIGURATION}
|
||||
${GAMECONTROLLER}
|
||||
${QUARTZ}
|
||||
${METAL}
|
||||
GFXMetal
|
||||
COMPILE_OPTIONS
|
||||
MAIN_FILE
|
||||
../uikit/ViewController.mm.in
|
||||
SRC
|
||||
MACOSX_BUNDLE
|
||||
${APP_HEADER_FILES}
|
||||
${APP_SOURCE_FILES}
|
||||
${RESOURCES}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../uikit/file.mm
|
||||
EXECUTABLE_PROPERTIES
|
||||
MACOSX_BUNDLE ON
|
||||
LINK_LIBRARIES
|
||||
Core
|
||||
GFXMetal
|
||||
${UIKIT}
|
||||
${FOUNDATION}
|
||||
${MOBILECORESERVICES}
|
||||
${CFNETWORK}
|
||||
${SYSTEMCONFIGURATION}
|
||||
${GAMECONTROLLER}
|
||||
${QUARTZ}
|
||||
${METAL}
|
||||
GFXMetal
|
||||
COMPILE_OPTIONS
|
||||
)
|
||||
|
||||
function(add_platform_commands APP_NAME data_directory)
|
||||
# set in cmake optionss
|
||||
#set(APP_BUNDLE_IDENTIFIER "com.test.app")
|
||||
#set(CODE_SIGN_IDENTITY "iPhone Developer")
|
||||
#set(DEVELOPMENT_TEAM_ID "aaaa")
|
||||
# set in cmake optionss
|
||||
#set(APP_BUNDLE_IDENTIFIER "com.test.app")
|
||||
#set(CODE_SIGN_IDENTITY "iPhone Developer")
|
||||
#set(DEVELOPMENT_TEAM_ID "aaaa")
|
||||
|
||||
set(RESOURCES
|
||||
${PROJECT_SOURCE_DIR}/platforms/tvos/Main.storyboard
|
||||
${PROJECT_SOURCE_DIR}/platforms/tvos/LaunchScreen.storyboard
|
||||
${CMAKE_SOURCE_DIR}/data
|
||||
${CMAKE_BINARY_DIR}/shaders
|
||||
)
|
||||
set(RESOURCES
|
||||
${PROJECT_SOURCE_DIR}/platforms/tvos/Main.storyboard
|
||||
${PROJECT_SOURCE_DIR}/platforms/tvos/LaunchScreen.storyboard
|
||||
${CMAKE_SOURCE_DIR}/data
|
||||
${CMAKE_BINARY_DIR}/shaders
|
||||
)
|
||||
|
||||
set(PRODUCT_NAME ${APP_NAME})
|
||||
set(EXECUTABLE_NAME ${APP_NAME})
|
||||
set(MACOSX_BUNDLE_EXECUTABLE_NAME ${APP_NAME})
|
||||
set(MACOSX_BUNDLE_INFO_STRING ${APP_BUNDLE_IDENTIFIER})
|
||||
set(MACOSX_BUNDLE_GUI_IDENTIFIER ${APP_BUNDLE_IDENTIFIER})
|
||||
set(MACOSX_BUNDLE_BUNDLE_NAME ${APP_BUNDLE_IDENTIFIER})
|
||||
set(MACOSX_BUNDLE_ICON_FILE "")
|
||||
set(MACOSX_BUNDLE_LONG_VERSION_STRING "1.0")
|
||||
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "1.0")
|
||||
set(MACOSX_BUNDLE_BUNDLE_VERSION "1.0")
|
||||
set(MACOSX_BUNDLE_COPYRIGHT "Copyright YOU")
|
||||
set(MACOSX_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET})
|
||||
set(PRODUCT_NAME ${APP_NAME})
|
||||
set(EXECUTABLE_NAME ${APP_NAME})
|
||||
set(MACOSX_BUNDLE_EXECUTABLE_NAME ${APP_NAME})
|
||||
set(MACOSX_BUNDLE_INFO_STRING ${APP_BUNDLE_IDENTIFIER})
|
||||
set(MACOSX_BUNDLE_GUI_IDENTIFIER ${APP_BUNDLE_IDENTIFIER})
|
||||
set(MACOSX_BUNDLE_BUNDLE_NAME ${APP_BUNDLE_IDENTIFIER})
|
||||
set(MACOSX_BUNDLE_ICON_FILE "")
|
||||
set(MACOSX_BUNDLE_LONG_VERSION_STRING "1.0")
|
||||
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "1.0")
|
||||
set(MACOSX_BUNDLE_BUNDLE_VERSION "1.0")
|
||||
set(MACOSX_BUNDLE_COPYRIGHT "Copyright YOU")
|
||||
set(MACOSX_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET})
|
||||
|
||||
configure_file(${PROJECT_SOURCE_DIR}/platforms/uikit/plist.in ${CMAKE_BINARY_DIR}/${add_platform_executable_TARGET}Info.plist)
|
||||
configure_file(${PROJECT_SOURCE_DIR}/platforms/uikit/plist.in ${CMAKE_BINARY_DIR}/${add_platform_executable_TARGET}Info.plist)
|
||||
|
||||
set_target_properties(${APP_NAME} PROPERTIES
|
||||
XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf-with-dsym"
|
||||
RESOURCE "${RESOURCES}"
|
||||
XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES"
|
||||
XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET}
|
||||
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ${CODE_SIGN_IDENTITY}
|
||||
XCODE_ATTRIBUTE_DEVELOPMENT_TEAM ${DEVELOPMENT_TEAM_ID}
|
||||
XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY ${DEVICE_FAMILY}
|
||||
MACOSX_BUNDLE TRUE
|
||||
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_BINARY_DIR}/${APP_NAME}Info.plist"
|
||||
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES
|
||||
XCODE_ATTRIBUTE_COMBINE_HIDPI_IMAGES NO
|
||||
XCODE_ATTRIBUTE_INSTALL_PATH "$(LOCAL_APPS_DIR)"
|
||||
XCODE_ATTRIBUTE_ENABLE_TESTABILITY YES
|
||||
XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN YES
|
||||
)
|
||||
set_target_properties(${APP_NAME} PROPERTIES
|
||||
XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf-with-dsym"
|
||||
RESOURCE "${RESOURCES}"
|
||||
XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES"
|
||||
XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET}
|
||||
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ${CODE_SIGN_IDENTITY}
|
||||
XCODE_ATTRIBUTE_DEVELOPMENT_TEAM ${DEVELOPMENT_TEAM_ID}
|
||||
XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY ${DEVICE_FAMILY}
|
||||
MACOSX_BUNDLE TRUE
|
||||
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_BINARY_DIR}/${APP_NAME}Info.plist"
|
||||
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES
|
||||
XCODE_ATTRIBUTE_COMBINE_HIDPI_IMAGES NO
|
||||
XCODE_ATTRIBUTE_INSTALL_PATH "$(LOCAL_APPS_DIR)"
|
||||
XCODE_ATTRIBUTE_ENABLE_TESTABILITY YES
|
||||
XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN YES
|
||||
)
|
||||
endfunction()
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
|
||||
@interface AppDelegate : UIResponder <UIApplicationDelegate>
|
||||
|
||||
@property (strong, nonatomic) UIWindow *window;
|
||||
@property(strong, nonatomic) UIWindow* window;
|
||||
|
||||
@end
|
|
@ -1,30 +1,30 @@
|
|||
#define VK_USE_PLATFORM_METAL_EXT
|
||||
|
||||
#include <MetalKit/MetalKit.h>
|
||||
#include <GameController/GameController.h>
|
||||
#import "QuartzCore/QuartzCore.hpp"
|
||||
#include <GameController/GameController.h>
|
||||
#include <MetalKit/MetalKit.h>
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#include <engine.hpp>
|
||||
#include <@APP_INCLUDE@>
|
||||
#include <engine.hpp>
|
||||
|
||||
#ifdef ENABLE_VULKAN
|
||||
#ifdef PLATFORM_IOS
|
||||
#define VK_USE_PLATFORM_IOS_MVK
|
||||
#else
|
||||
#define VK_USE_PLATFORM_TVOS_MVK
|
||||
#endif
|
||||
#include "gfx_vulkan.hpp"
|
||||
#ifdef PLATFORM_IOS
|
||||
#define VK_USE_PLATFORM_IOS_MVK
|
||||
#else
|
||||
#define VK_USE_PLATFORM_TVOS_MVK
|
||||
#endif
|
||||
#include "gfx_vulkan.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_METAL
|
||||
#include "gfx_metal.hpp"
|
||||
#include "gfx_metal.hpp"
|
||||
#endif
|
||||
|
||||
#include "gfx_dummy.hpp"
|
||||
|
||||
@APP_CLASS@* app = nullptr;
|
||||
@APP_CLASS@ * app = nullptr;
|
||||
GFX* gfx_interface = nullptr;
|
||||
|
||||
int maxFPS = 60;
|
||||
|
@ -48,7 +48,7 @@ void* create_vulkan_surface(platform::window_ptr window, void* surface_creation_
|
|||
|
||||
@implementation GameView
|
||||
|
||||
+ (Class) layerClass {
|
||||
+ (Class)layerClass {
|
||||
return [CAMetalLayer class];
|
||||
}
|
||||
|
||||
|
@ -59,36 +59,37 @@ void* create_vulkan_surface(platform::window_ptr window, void* surface_creation_
|
|||
engine->end_frame();
|
||||
}
|
||||
|
||||
- (void) controllerConnected {
|
||||
- (void)controllerConnected {
|
||||
GCController* controller = [GCController controllers][0];
|
||||
[[controller extendedGamepad] setValueChangedHandler:^(GCExtendedGamepad * _Nonnull gamepad, GCControllerElement * _Nonnull element) {
|
||||
const auto& handle_element = [element](int index, GCControllerElement* e) {
|
||||
if(element == e)
|
||||
inputKeys[index] = [(GCControllerButtonInput*)e value] == 1.0f;
|
||||
};
|
||||
[[controller extendedGamepad]
|
||||
setValueChangedHandler:^(GCExtendedGamepad* _Nonnull gamepad, GCControllerElement* _Nonnull element) {
|
||||
const auto& handle_element = [element](int index, GCControllerElement* e) {
|
||||
if (element == e)
|
||||
inputKeys[index] = [(GCControllerButtonInput*)e value] == 1.0f;
|
||||
};
|
||||
|
||||
handle_element(0, [[controller extendedGamepad] buttonA]);
|
||||
handle_element(1, [[controller extendedGamepad] buttonB]);
|
||||
handle_element(2, [[controller extendedGamepad] buttonX]);
|
||||
handle_element(3, [[controller extendedGamepad] buttonY]);
|
||||
handle_element(0, [[controller extendedGamepad] buttonA]);
|
||||
handle_element(1, [[controller extendedGamepad] buttonB]);
|
||||
handle_element(2, [[controller extendedGamepad] buttonX]);
|
||||
handle_element(3, [[controller extendedGamepad] buttonY]);
|
||||
|
||||
if(element == [[controller extendedGamepad] dpad]) {
|
||||
inputKeys[4] = [[[[controller extendedGamepad] dpad] up] value] == 1.0f;
|
||||
inputKeys[5] = [[[[controller extendedGamepad] dpad] down] value] == 1.0f;
|
||||
inputKeys[6] = [[[[controller extendedGamepad] dpad] left] value] == 1.0f;
|
||||
inputKeys[7] = [[[[controller extendedGamepad] dpad] right] value] == 1.0f;
|
||||
}
|
||||
if (element == [[controller extendedGamepad] dpad]) {
|
||||
inputKeys[4] = [[[[controller extendedGamepad] dpad] up] value] == 1.0f;
|
||||
inputKeys[5] = [[[[controller extendedGamepad] dpad] down] value] == 1.0f;
|
||||
inputKeys[6] = [[[[controller extendedGamepad] dpad] left] value] == 1.0f;
|
||||
inputKeys[7] = [[[[controller extendedGamepad] dpad] right] value] == 1.0f;
|
||||
}
|
||||
|
||||
if(element == [[controller extendedGamepad] leftThumbstick]) {
|
||||
leftX = [[[[controller extendedGamepad] leftThumbstick] xAxis] value];
|
||||
leftY = [[[[controller extendedGamepad] leftThumbstick] yAxis] value];
|
||||
}
|
||||
if (element == [[controller extendedGamepad] leftThumbstick]) {
|
||||
leftX = [[[[controller extendedGamepad] leftThumbstick] xAxis] value];
|
||||
leftY = [[[[controller extendedGamepad] leftThumbstick] yAxis] value];
|
||||
}
|
||||
|
||||
if(element == [[controller extendedGamepad] rightThumbstick]) {
|
||||
rightX = [[[[controller extendedGamepad] rightThumbstick] xAxis] value];
|
||||
rightY = [[[[controller extendedGamepad] rightThumbstick] yAxis] value];
|
||||
}
|
||||
}];
|
||||
if (element == [[controller extendedGamepad] rightThumbstick]) {
|
||||
rightX = [[[[controller extendedGamepad] rightThumbstick] xAxis] value];
|
||||
rightY = [[[[controller extendedGamepad] rightThumbstick] yAxis] value];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -100,17 +101,17 @@ void* create_vulkan_surface(platform::window_ptr window, void* surface_creation_
|
|||
float mouse_x = 0.0f, mouse_y = 0.0f;
|
||||
bool mouse_down = false;
|
||||
|
||||
@interface GameViewController ()
|
||||
{
|
||||
@interface GameViewController () {
|
||||
GameView* view;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation GameViewController
|
||||
|
||||
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
||||
- (void)touchesBegan:(NSSet<UITouch*>*)touches withEvent:(UIEvent*)event {
|
||||
UITouch* touch = [touches anyObject];
|
||||
CGPoint touchPoint = [touch locationInView: self.view];
|
||||
CGPoint touchPoint = [touch locationInView:self.view];
|
||||
|
||||
mouse_x = touchPoint.x;
|
||||
mouse_y = touchPoint.y;
|
||||
|
@ -119,9 +120,9 @@ bool mouse_down = false;
|
|||
engine->process_mouse_down(0, {static_cast<int32_t>(touchPoint.x), static_cast<int32_t>(touchPoint.y)});
|
||||
}
|
||||
|
||||
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
||||
- (void)touchesEnded:(NSSet<UITouch*>*)touches withEvent:(UIEvent*)event {
|
||||
UITouch* touch = [touches anyObject];
|
||||
CGPoint touchPoint = [touch locationInView: self.view];
|
||||
CGPoint touchPoint = [touch locationInView:self.view];
|
||||
|
||||
mouse_x = touchPoint.x;
|
||||
mouse_y = touchPoint.y;
|
||||
|
@ -129,9 +130,9 @@ bool mouse_down = false;
|
|||
mouse_down = false;
|
||||
}
|
||||
|
||||
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
||||
- (void)touchesMoved:(NSSet<UITouch*>*)touches withEvent:(UIEvent*)event {
|
||||
UITouch* touch = [touches anyObject];
|
||||
CGPoint touchPoint = [touch locationInView: self.view];
|
||||
CGPoint touchPoint = [touch locationInView:self.view];
|
||||
|
||||
mouse_x = touchPoint.x;
|
||||
mouse_y = touchPoint.y;
|
||||
|
@ -141,12 +142,11 @@ int width, height;
|
|||
int drawable_width, drawable_height;
|
||||
CAMetalLayer* layer;
|
||||
|
||||
template<class GFXBackend>
|
||||
void try_initialize() {
|
||||
if(gfx_interface == nullptr) {
|
||||
template<class GFXBackend> void try_initialize() {
|
||||
if (gfx_interface == nullptr) {
|
||||
auto backend = new GFXBackend();
|
||||
const bool supported = backend->is_supported() && platform::supports_context(backend->required_context());
|
||||
if(!supported) {
|
||||
if (!supported) {
|
||||
prism::log("Failed to initialize GFX backend... trying next...");
|
||||
} else {
|
||||
gfx_interface = backend;
|
||||
|
@ -174,18 +174,18 @@ void try_initialize() {
|
|||
|
||||
engine = new prism::engine(0, nullptr);
|
||||
|
||||
#ifdef ENABLE_METAL
|
||||
try_initialize<GFXMetal>();
|
||||
#endif
|
||||
#ifdef ENABLE_METAL
|
||||
try_initialize<GFXMetal>();
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_VULKAN
|
||||
try_initialize<GFXVulkan>();
|
||||
#endif
|
||||
#ifdef ENABLE_VULKAN
|
||||
try_initialize<GFXVulkan>();
|
||||
#endif
|
||||
|
||||
try_initialize<GFXDummy>();
|
||||
|
||||
GFXCreateInfo info = {};
|
||||
if(gfx_interface->initialize(info)) {
|
||||
if (gfx_interface->initialize(info)) {
|
||||
engine->set_gfx(gfx_interface);
|
||||
} else {
|
||||
return -1;
|
||||
|
@ -195,15 +195,13 @@ void try_initialize() {
|
|||
app_main(engine);
|
||||
engine->set_app(app);
|
||||
|
||||
engine->add_window((void*)CFBridgingRetain([view layer]), (void*)1, {static_cast<uint32_t>(width), static_cast<uint32_t>(height)});
|
||||
engine->add_window(
|
||||
(void*)CFBridgingRetain([view layer]), (void*)1, {static_cast<uint32_t>(width), static_cast<uint32_t>(height)});
|
||||
|
||||
app->initialize_render();
|
||||
|
||||
NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
|
||||
[nc addObserver:view
|
||||
selector:@selector(controllerConnected)
|
||||
name:GCControllerDidConnectNotification
|
||||
object:nil];
|
||||
[nc addObserver:view selector:@selector(controllerConnected) name:GCControllerDidConnectNotification object:nil];
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
|
@ -211,7 +209,7 @@ void try_initialize() {
|
|||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
-(bool)prefersStatusBarHidden {
|
||||
- (bool)prefersStatusBarHidden {
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
@ -219,33 +217,31 @@ void try_initialize() {
|
|||
|
||||
bool platform::supports_context(GFXContext context) {
|
||||
#ifdef ENABLE_DX12
|
||||
if(context == GFXContext::DirectX)
|
||||
if (context == GFXContext::DirectX)
|
||||
return true;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_VULKAN
|
||||
if(context == GFXContext::Vulkan)
|
||||
if (context == GFXContext::Vulkan)
|
||||
return true;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_METAL
|
||||
if(context == GFXContext::Metal)
|
||||
if (context == GFXContext::Metal)
|
||||
return true;
|
||||
#endif
|
||||
|
||||
if(context == GFXContext::None)
|
||||
if (context == GFXContext::None)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void platform::initialize_context(const GFXContext context) {
|
||||
|
||||
}
|
||||
void platform::initialize_context(const GFXContext context) {}
|
||||
|
||||
void* platform::get_context_information() {
|
||||
#ifdef ENABLE_VULKAN
|
||||
if(gfx_interface->required_context() == GFXContext::Vulkan) {
|
||||
if (gfx_interface->required_context() == GFXContext::Vulkan) {
|
||||
auto info = new vulkan_information();
|
||||
info->surface_extensions = {VK_EXT_METAL_SURFACE_EXTENSION_NAME};
|
||||
|
||||
|
@ -258,13 +254,13 @@ void* platform::get_context_information() {
|
|||
|
||||
void* platform::create_surface(window_ptr window, void* surface_creation_info) {
|
||||
#ifdef ENABLE_VULKAN
|
||||
if(gfx_interface->required_context() == GFXContext::Vulkan) {
|
||||
if (gfx_interface->required_context() == GFXContext::Vulkan) {
|
||||
return create_vulkan_surface(window, surface_creation_info);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_METAL
|
||||
if(gfx_interface->required_context() == GFXContext::Metal) {
|
||||
if (gfx_interface->required_context() == GFXContext::Metal) {
|
||||
return create_metal_surface(window, surface_creation_info);
|
||||
}
|
||||
#endif
|
||||
|
@ -274,7 +270,7 @@ void* platform::create_surface(window_ptr window, void* surface_creation_info) {
|
|||
|
||||
void* platform::get_next_image(window_ptr window) {
|
||||
#ifdef ENABLE_METAL
|
||||
if(gfx_interface->required_context() == GFXContext::Metal) {
|
||||
if (gfx_interface->required_context() == GFXContext::Metal) {
|
||||
return get_next_metal_drawable(window);
|
||||
}
|
||||
#endif
|
||||
|
@ -282,9 +278,7 @@ void* platform::get_next_image(window_ptr window) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void platform::capture_mouse(const bool capture) {
|
||||
|
||||
}
|
||||
void platform::capture_mouse(const bool capture) {}
|
||||
|
||||
// TODO: unimplemented
|
||||
PlatformTheme platform::get_theme() {
|
||||
|
@ -292,11 +286,11 @@ PlatformTheme platform::get_theme() {
|
|||
}
|
||||
|
||||
void platform::begin_text_input() {
|
||||
// TODO: stub
|
||||
// TODO: stub
|
||||
}
|
||||
|
||||
void platform::end_text_input() {
|
||||
// TODO: stub
|
||||
// TODO: stub
|
||||
}
|
||||
|
||||
void* create_vulkan_surface(platform::window_ptr index, void* surface_creation_info) {
|
||||
|
@ -337,9 +331,7 @@ bool platform::is_main_window(platform::window_ptr index) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void platform::show_window(const platform::window_ptr index) {
|
||||
|
||||
}
|
||||
void platform::show_window(const platform::window_ptr index) {}
|
||||
|
||||
bool platform::supports_feature(const PlatformFeature feature) {
|
||||
return false;
|
||||
|
@ -358,48 +350,43 @@ std::tuple<float, float> platform::get_left_stick_position() {
|
|||
}
|
||||
|
||||
bool platform::get_key_down(InputButton key) {
|
||||
if(key == InputButton::ButtonA)
|
||||
if (key == InputButton::ButtonA)
|
||||
return inputKeys[0];
|
||||
|
||||
if(key == InputButton::ButtonB)
|
||||
if (key == InputButton::ButtonB)
|
||||
return inputKeys[1];
|
||||
|
||||
if(key == InputButton::ButtonX)
|
||||
if (key == InputButton::ButtonX)
|
||||
return inputKeys[2];
|
||||
|
||||
if(key == InputButton::ButtonY)
|
||||
if (key == InputButton::ButtonY)
|
||||
return inputKeys[3];
|
||||
|
||||
if(key == InputButton::DPadUp)
|
||||
if (key == InputButton::DPadUp)
|
||||
return inputKeys[4];
|
||||
|
||||
if(key == InputButton::DPadDown)
|
||||
if (key == InputButton::DPadDown)
|
||||
return inputKeys[5];
|
||||
|
||||
if(key == InputButton::DPadLeft)
|
||||
if (key == InputButton::DPadLeft)
|
||||
return inputKeys[6];
|
||||
|
||||
if(key == InputButton::DPadRight)
|
||||
if (key == InputButton::DPadRight)
|
||||
return inputKeys[7];
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
platform::window_ptr platform::open_window(const std::string_view title, const prism::Rectangle rect, const WindowFlags flags) {
|
||||
return (void*)1;
|
||||
platform::window_ptr
|
||||
platform::open_window(const std::string_view title, const prism::Rectangle rect, const WindowFlags flags) {
|
||||
return (void*)1;
|
||||
}
|
||||
|
||||
void platform::set_window_title(const platform::window_ptr index, const std::string_view title) {
|
||||
void platform::set_window_title(const platform::window_ptr index, const std::string_view title) {}
|
||||
|
||||
}
|
||||
bool platform::is_window_focused(const platform::window_ptr index) {}
|
||||
|
||||
bool platform::is_window_focused(const platform::window_ptr index) {
|
||||
|
||||
}
|
||||
|
||||
void platform::set_window_focused(const platform::window_ptr index) {
|
||||
|
||||
}
|
||||
void platform::set_window_focused(const platform::window_ptr index) {}
|
||||
|
||||
prism::Extent platform::get_window_size(const platform::window_ptr index) {
|
||||
return {static_cast<uint32_t>(width), static_cast<uint32_t>(height)};
|
||||
|
@ -409,37 +396,21 @@ prism::Extent platform::get_window_drawable_size(const platform::window_ptr inde
|
|||
return {static_cast<uint32_t>(drawable_width), static_cast<uint32_t>(drawable_height)};
|
||||
}
|
||||
|
||||
prism::Offset platform::get_window_position(const platform::window_ptr index) {
|
||||
prism::Offset platform::get_window_position(const platform::window_ptr index) {}
|
||||
|
||||
}
|
||||
void platform::set_window_size(const platform::window_ptr index, const prism::Extent extent) {}
|
||||
|
||||
void platform::set_window_size(const platform::window_ptr index, const prism::Extent extent) {
|
||||
void platform::set_window_position(const platform::window_ptr index, const prism::Offset offset) {}
|
||||
|
||||
}
|
||||
void platform::close_window(const platform::window_ptr index) {}
|
||||
|
||||
void platform::set_window_position(const platform::window_ptr index, const prism::Offset offset) {
|
||||
int platform::get_keycode(const InputButton button) {}
|
||||
|
||||
}
|
||||
prism::Rectangle platform::get_monitor_resolution() {}
|
||||
|
||||
void platform::close_window(const platform::window_ptr index) {
|
||||
prism::Rectangle platform::get_monitor_work_area() {}
|
||||
|
||||
}
|
||||
|
||||
int platform::get_keycode(const InputButton button) {
|
||||
|
||||
}
|
||||
|
||||
prism::Rectangle platform::get_monitor_resolution() {
|
||||
|
||||
}
|
||||
|
||||
prism::Rectangle platform::get_monitor_work_area() {
|
||||
|
||||
}
|
||||
|
||||
prism::Offset platform::get_screen_cursor_position() {
|
||||
|
||||
}
|
||||
prism::Offset platform::get_screen_cursor_position() {}
|
||||
|
||||
bool platform::get_mouse_button_down(const int index) {
|
||||
return mouse_down;
|
||||
|
@ -449,9 +420,7 @@ float platform::get_monitor_dpi() {
|
|||
return 2.0f;
|
||||
}
|
||||
|
||||
std::tuple<float, float> platform::get_wheel_delta() {
|
||||
|
||||
}
|
||||
std::tuple<float, float> platform::get_wheel_delta() {}
|
||||
|
||||
const char* platform::get_name() {
|
||||
return "iOS";
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* \endcode
|
||||
*/
|
||||
#ifndef KEEP_IN_MODULE
|
||||
#define KEEP_IN_MODULE extern "C" __attribute__((used, visibility("default")))
|
||||
#define KEEP_IN_MODULE extern "C" __attribute__((used, visibility("default")))
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -30,9 +30,9 @@ extern "C" int __main__(int /*argc*/, char* /*argv*/[]);
|
|||
//****************************************************************************/
|
||||
|
||||
namespace impl {
|
||||
/**
|
||||
* JavaScript async calls that need to finish before calling \c main().
|
||||
*/
|
||||
/**
|
||||
* JavaScript async calls that need to finish before calling \c main().
|
||||
*/
|
||||
EM_JS(void, glue_preint, (), {
|
||||
var entry = __glue_main_;
|
||||
if (entry) {
|
||||
|
@ -43,14 +43,14 @@ namespace impl {
|
|||
* loading the Wasm).
|
||||
*/
|
||||
if (navigator["gpu"]) {
|
||||
navigator["gpu"]["requestAdapter"]().then(function (adapter) {
|
||||
adapter["requestDevice"]().then( function (device) {
|
||||
Module["preinitializedWebGPUDevice"] = device;
|
||||
entry();
|
||||
});
|
||||
}, function () {
|
||||
console.error("No WebGPU adapter; not starting");
|
||||
});
|
||||
navigator["gpu"]["requestAdapter"]().then(
|
||||
function(adapter) {
|
||||
adapter["requestDevice"]().then(function(device) {
|
||||
Module["preinitializedWebGPUDevice"] = device;
|
||||
entry();
|
||||
});
|
||||
},
|
||||
function() { console.error("No WebGPU adapter; not starting"); });
|
||||
} else {
|
||||
console.error("No support for WebGPU; not starting");
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ namespace impl {
|
|||
console.error("Entry point not found; unable to start");
|
||||
}
|
||||
});
|
||||
}
|
||||
} // namespace impl
|
||||
|
||||
//****************************************************************************/
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
#include <stdio.h>
|
||||
#include <@APP_INCLUDE@>
|
||||
#include <emscripten/html5.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "engine.hpp"
|
||||
#include "platform.hpp"
|
||||
#include "gfx_webgpu.hpp"
|
||||
#include "file.hpp"
|
||||
#include "gfx_webgpu.hpp"
|
||||
#include "platform.hpp"
|
||||
#include "string_utils.hpp"
|
||||
|
||||
@APP_CLASS@* app = nullptr;
|
||||
GFX* gfx_interface = nullptr;
|
||||
|
||||
EM_BOOL draw(double time, void *userData) {
|
||||
EM_BOOL draw(double time, void* userData) {
|
||||
engine->update(time);
|
||||
engine->begin_frame(time);
|
||||
|
||||
|
@ -27,7 +27,7 @@ extern "C" int __main__(int argc, char* argv[]) {
|
|||
|
||||
GFXCreateInfo info = {};
|
||||
gfx_interface = new GFXWebGPU();
|
||||
if(gfx_interface->initialize(info)) {
|
||||
if (gfx_interface->initialize(info)) {
|
||||
engine->set_gfx(gfx_interface);
|
||||
} else {
|
||||
return -1;
|
||||
|
@ -45,19 +45,15 @@ extern "C" int __main__(int argc, char* argv[]) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void platform::capture_mouse(const bool capture) {
|
||||
|
||||
}
|
||||
void platform::capture_mouse(const bool capture) {}
|
||||
|
||||
PlatformTheme platform::get_theme() {
|
||||
return PlatformTheme::Light;
|
||||
}
|
||||
|
||||
void platform::begin_text_input() {
|
||||
}
|
||||
void platform::begin_text_input() {}
|
||||
|
||||
void platform::end_text_input() {
|
||||
}
|
||||
void platform::end_text_input() {}
|
||||
|
||||
void* platform::create_surface(window_ptr window, void* surface_creation_info) {
|
||||
return nullptr;
|
||||
|
@ -79,9 +75,7 @@ bool platform::supports_context(GFXContext context) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void platform::show_window(const platform::window_ptr index) {
|
||||
|
||||
}
|
||||
void platform::show_window(const platform::window_ptr index) {}
|
||||
|
||||
bool platform::supports_feature(const PlatformFeature feature) {
|
||||
return false;
|
||||
|
@ -103,21 +97,18 @@ bool platform::get_key_down(InputButton key) {
|
|||
return false;
|
||||
}
|
||||
|
||||
platform::window_ptr platform::open_window(const std::string_view title, const prism::Rectangle rect, const WindowFlags flags) {
|
||||
return (void*)1;
|
||||
platform::window_ptr
|
||||
platform::open_window(const std::string_view title, const prism::Rectangle rect, const WindowFlags flags) {
|
||||
return (void*)1;
|
||||
}
|
||||
|
||||
void platform::set_window_title(const platform::window_ptr index, const std::string_view title) {
|
||||
|
||||
}
|
||||
void platform::set_window_title(const platform::window_ptr index, const std::string_view title) {}
|
||||
|
||||
bool platform::is_window_focused(const platform::window_ptr index) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void platform::set_window_focused(const platform::window_ptr index) {
|
||||
|
||||
}
|
||||
void platform::set_window_focused(const platform::window_ptr index) {}
|
||||
|
||||
prism::Extent platform::get_window_size(const platform::window_ptr index) {
|
||||
return {100, 100};
|
||||
|
@ -131,17 +122,11 @@ prism::Offset platform::get_window_position(const platform::window_ptr index) {
|
|||
return {0, 0};
|
||||
}
|
||||
|
||||
void platform::set_window_size(const platform::window_ptr index, const prism::Extent extent) {
|
||||
void platform::set_window_size(const platform::window_ptr index, const prism::Extent extent) {}
|
||||
|
||||
}
|
||||
void platform::set_window_position(const platform::window_ptr index, const prism::Offset offset) {}
|
||||
|
||||
void platform::set_window_position(const platform::window_ptr index, const prism::Offset offset) {
|
||||
|
||||
}
|
||||
|
||||
void platform::close_window(const platform::window_ptr index) {
|
||||
|
||||
}
|
||||
void platform::close_window(const platform::window_ptr index) {}
|
||||
|
||||
int platform::get_keycode(const InputButton button) {
|
||||
return 0;
|
||||
|
@ -179,6 +164,4 @@ void prism::set_domain_path(const prism::domain domain, const prism::path& path)
|
|||
domain_data[(int)domain] = replace_substring(path.string(), "{resource_dir}/", "");
|
||||
}
|
||||
|
||||
prism::path prism::get_writeable_directory() {
|
||||
|
||||
}
|
||||
prism::path prism::get_writeable_directory() {}
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||
<link rel="shortcut icon" href="#" />
|
||||
<title>Hello Triangle</title>
|
||||
<style>
|
||||
<meta charset="utf-8">
|
||||
<meta content="width=device-width, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" name="viewport"/>
|
||||
<meta content="yes" name="apple-mobile-web-app-capable"/>
|
||||
<meta content="black-translucent" name="apple-mobile-web-app-status-bar-style"/>
|
||||
<link href="#" rel="shortcut icon"/>
|
||||
<title>Hello Triangle</title>
|
||||
<style>
|
||||
body {
|
||||
background: #333;
|
||||
font-family: "Verdana", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
|
||||
|
@ -26,7 +26,8 @@
|
|||
overflow: hidden;
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
@ -37,7 +38,8 @@
|
|||
return document.getElementById("canvas");
|
||||
})()
|
||||
};
|
||||
</script>
|
||||
|
||||
</script>
|
||||
{{{ SCRIPT }}}
|
||||
</body>
|
||||
|
||||
|
|
Reference in a new issue