mirror of https://github.com/AxioDL/metaforce.git
Merge branch 'dawn' into new-cmodel
This commit is contained in:
commit
40a1f3c4a0
|
@ -1,36 +1,36 @@
|
||||||
[submodule "nod"]
|
[submodule "extern/nod"]
|
||||||
path = extern/nod
|
path = extern/nod
|
||||||
url = ../nod.git
|
url = ../nod.git
|
||||||
branch = master
|
branch = master
|
||||||
[submodule "amuse"]
|
[submodule "extern/amuse"]
|
||||||
path = extern/amuse
|
path = extern/amuse
|
||||||
url = ../amuse.git
|
url = ../amuse.git
|
||||||
branch = master
|
branch = master
|
||||||
[submodule "kabufuda"]
|
[submodule "extern/kabufuda"]
|
||||||
path = extern/kabufuda
|
path = extern/kabufuda
|
||||||
url = ../kabufuda.git
|
url = ../kabufuda.git
|
||||||
branch = master
|
branch = master
|
||||||
[submodule "jbus"]
|
[submodule "extern/jbus"]
|
||||||
path = extern/jbus
|
path = extern/jbus
|
||||||
url = ../jbus.git
|
url = ../jbus.git
|
||||||
branch = master
|
branch = master
|
||||||
[submodule "assetnameparser/tinyxml2"]
|
[submodule "extern/tinyxml2"]
|
||||||
path = extern/tinyxml2
|
path = extern/tinyxml2
|
||||||
url = ../tinyxml2.git
|
url = ../tinyxml2.git
|
||||||
branch = master
|
branch = master
|
||||||
[submodule "sanitizers-cmake"]
|
[submodule "extern/sanitizers-cmake"]
|
||||||
path = extern/sanitizers-cmake
|
path = extern/sanitizers-cmake
|
||||||
url = https://github.com/arsenm/sanitizers-cmake.git
|
url = https://github.com/arsenm/sanitizers-cmake.git
|
||||||
branch = master
|
branch = master
|
||||||
[submodule "discord-rpc"]
|
[submodule "extern/discord-rpc"]
|
||||||
path = extern/discord-rpc
|
path = extern/discord-rpc
|
||||||
url = https://github.com/discordapp/discord-rpc.git
|
url = https://github.com/discordapp/discord-rpc.git
|
||||||
branch = master
|
branch = master
|
||||||
[submodule "rapidjson"]
|
[submodule "extern/rapidjson"]
|
||||||
path = extern/rapidjson
|
path = extern/rapidjson
|
||||||
url = https://github.com/Tencent/rapidjson.git
|
url = https://github.com/Tencent/rapidjson.git
|
||||||
branch = master
|
branch = master
|
||||||
[submodule "NESEmulator/fixNES"]
|
[submodule "extern/fixNES"]
|
||||||
path = extern/fixNES
|
path = extern/fixNES
|
||||||
url = https://github.com/FIX94/fixNES.git
|
url = https://github.com/FIX94/fixNES.git
|
||||||
branch = master
|
branch = master
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
path = extern/libjpeg-turbo
|
path = extern/libjpeg-turbo
|
||||||
url = ../libjpeg-turbo.git
|
url = ../libjpeg-turbo.git
|
||||||
branch = thp
|
branch = thp
|
||||||
[submodule "zeus"]
|
[submodule "extern/zeus"]
|
||||||
path = extern/zeus
|
path = extern/zeus
|
||||||
url = ../zeus.git
|
url = ../zeus.git
|
||||||
branch = master
|
branch = master
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <string>
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -416,7 +416,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void onAppWindowResized(const aurora::WindowSize& size) noexcept override {
|
void onAppWindowResized(const aurora::WindowSize& size) noexcept override {
|
||||||
CGraphics::SetViewportResolution({static_cast<s32>(size.width), static_cast<s32>(size.height)});
|
CGraphics::SetViewportResolution({static_cast<s32>(size.fb_width), static_cast<s32>(size.fb_height)});
|
||||||
}
|
}
|
||||||
|
|
||||||
void onAppWindowMoved(std::int32_t x, std::int32_t y) noexcept override {
|
void onAppWindowMoved(std::int32_t x, std::int32_t y) noexcept override {
|
||||||
|
|
|
@ -24,8 +24,8 @@ add_subdirectory(Particle)
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
list(APPEND PLAT_SRCS CMemoryCardSysWin.cpp)
|
list(APPEND PLAT_SRCS CMemoryCardSysWin.cpp)
|
||||||
elseif (APPLE)
|
#elseif (APPLE)
|
||||||
list(APPEND PLAT_SRCS CMemoryCardSysOSX.cpp)
|
#list(APPEND PLAT_SRCS CMemoryCardSysOSX.cpp)
|
||||||
else ()
|
else ()
|
||||||
list(APPEND PLAT_SRCS CMemoryCardSysNix.cpp)
|
list(APPEND PLAT_SRCS CMemoryCardSysNix.cpp)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "CMemoryCardSys.hpp"
|
#include "CMemoryCardSys.hpp"
|
||||||
#include "Runtime/GameGlobalObjects.hpp"
|
#include "Runtime/GameGlobalObjects.hpp"
|
||||||
#include "Runtime/IMain.hpp"
|
#include "Runtime/IMain.hpp"
|
||||||
|
#include <Runtime/CBasics.hpp>
|
||||||
#include <SDL_filesystem.h>
|
#include <SDL_filesystem.h>
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
|
@ -25,8 +25,8 @@ std::string CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlot slot) {
|
||||||
auto path = *dolphinPath;
|
auto path = *dolphinPath;
|
||||||
path += fmt::format(FMT_STRING("GC/MemoryCard{:c}.USA.raw"), slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B');
|
path += fmt::format(FMT_STRING("GC/MemoryCard{:c}.USA.raw"), slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B');
|
||||||
|
|
||||||
struct stat64 theStat {};
|
CBasics::Sstat theStat{};
|
||||||
if (stat64(path.c_str(), &theStat) != 0 || !S_ISREG(theStat.st_mode)) {
|
if (CBasics::Stat(path.c_str(), &theStat) != 0 || !S_ISREG(theStat.st_mode)) {
|
||||||
/* legacy case for older dolphin versions */
|
/* legacy case for older dolphin versions */
|
||||||
const char* home = getenv("HOME");
|
const char* home = getenv("HOME");
|
||||||
if (home == nullptr || home[0] != '/') {
|
if (home == nullptr || home[0] != '/') {
|
||||||
|
@ -34,9 +34,14 @@ std::string CMemoryCardSys::ResolveDolphinCardPath(kabufuda::ECardSlot slot) {
|
||||||
}
|
}
|
||||||
|
|
||||||
path = home;
|
path = home;
|
||||||
|
#ifndef __APPLE__
|
||||||
path += fmt::format(FMT_STRING("/.dolphin-emu/GC/MemoryCard{:c}.USA.raw"),
|
path += fmt::format(FMT_STRING("/.dolphin-emu/GC/MemoryCard{:c}.USA.raw"),
|
||||||
slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B');
|
slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B');
|
||||||
if (stat64(path.c_str(), &theStat) != 0 || !S_ISREG(theStat.st_mode)) {
|
#else
|
||||||
|
path += fmt::format(FMT_STRING("/Library/Application Support/Dolphin/GC/MemoryCard{:c}.USA.raw"),
|
||||||
|
slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B');
|
||||||
|
#endif
|
||||||
|
if (CBasics::Stat(path.c_str(), &theStat) != 0 || !S_ISREG(theStat.st_mode)) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,8 @@ class CGuiTextSupport {
|
||||||
zeus::CColor x28_outlineColor;
|
zeus::CColor x28_outlineColor;
|
||||||
zeus::CColor x2c_geometryColor;
|
zeus::CColor x2c_geometryColor;
|
||||||
bool x30_imageBaseline = false;
|
bool x30_imageBaseline = false;
|
||||||
|
s32 x30_; // new in PAL/JP
|
||||||
|
s32 x34_; // ""
|
||||||
s32 x34_extentX;
|
s32 x34_extentX;
|
||||||
s32 x38_extentY;
|
s32 x38_extentY;
|
||||||
float x3c_curTime = 0.f;
|
float x3c_curTime = 0.f;
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
#include "Runtime/Memory/CCircularBuffer.hpp"
|
||||||
|
|
||||||
|
namespace metaforce {
|
||||||
|
CCircularBuffer::CCircularBuffer(void* buf, s32 len, EOwnership ownership)
|
||||||
|
: x0_canDelete(buf != nullptr), x4_ptr(reinterpret_cast<u8*>(buf)), x8_bufferLen(len) {
|
||||||
|
if (ownership == EOwnership::Owned)
|
||||||
|
x0_canDelete = false;
|
||||||
|
}
|
||||||
|
CCircularBuffer::~CCircularBuffer() {
|
||||||
|
if (x0_canDelete) {
|
||||||
|
delete x4_ptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 CCircularBuffer::GetAllocatedAmount() const {
|
||||||
|
s32 res = x10_nextFreeAddr - xc_;
|
||||||
|
return (x14_ == -1) ? res : res + (x8_bufferLen - x14_);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CCircularBuffer::IsWrappedMemory(s32 offset, s32 len) {
|
||||||
|
return x14_ > -1 && x14_ >= offset && (x14_ < (offset + len));
|
||||||
|
}
|
||||||
|
|
||||||
|
void* CCircularBuffer::Alloc(s32 len) {
|
||||||
|
if ((x8_bufferLen - x10_nextFreeAddr) >= len && !IsWrappedMemory(x10_nextFreeAddr, len)) {
|
||||||
|
s32 offset = x10_nextFreeAddr;
|
||||||
|
x10_nextFreeAddr = offset + len;
|
||||||
|
return x4_ptr + offset;
|
||||||
|
} else if (xc_ >= len && !IsWrappedMemory(0, len)) {
|
||||||
|
u32 r3 = xc_;
|
||||||
|
xc_ = 0;
|
||||||
|
x10_nextFreeAddr = len;
|
||||||
|
x14_ = r3;
|
||||||
|
return x4_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCircularBuffer::Free(void* ptr, s32 r5) {
|
||||||
|
if (x14_ <= -1) {
|
||||||
|
xc_ += r5;
|
||||||
|
} else if (ptr == x4_ptr) {
|
||||||
|
x14_ = -1;
|
||||||
|
xc_ = r5;
|
||||||
|
} else {
|
||||||
|
x14_ += r5;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x14_ != -1 || xc_ != x10_nextFreeAddr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
x10_nextFreeAddr = 0;
|
||||||
|
xc_ = 0;
|
||||||
|
}
|
||||||
|
} // namespace metaforce
|
|
@ -0,0 +1,25 @@
|
||||||
|
#pragma once
|
||||||
|
#include "Runtime/GCNTypes.hpp"
|
||||||
|
|
||||||
|
namespace metaforce {
|
||||||
|
class CCircularBuffer {
|
||||||
|
public:
|
||||||
|
enum class EOwnership { Unowned, Owned };
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool x0_canDelete;
|
||||||
|
u8* x4_ptr;
|
||||||
|
s32 x8_bufferLen;
|
||||||
|
s32 xc_ = 0;
|
||||||
|
s32 x10_nextFreeAddr = 0;
|
||||||
|
s32 x14_ = -1;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CCircularBuffer(void* buf, s32 len, EOwnership ownership = EOwnership::Owned);
|
||||||
|
~CCircularBuffer();
|
||||||
|
s32 GetAllocatedAmount() const;
|
||||||
|
bool IsWrappedMemory(s32 offset, s32 len);
|
||||||
|
void* Alloc(s32 len);
|
||||||
|
void Free(void* ptr, s32 r5);
|
||||||
|
};
|
||||||
|
} // namespace metaforce
|
|
@ -3,7 +3,7 @@ if (WIN32)
|
||||||
endif ()
|
endif ()
|
||||||
add_subdirectory(../extern/SDL SDL2 EXCLUDE_FROM_ALL)
|
add_subdirectory(../extern/SDL SDL2 EXCLUDE_FROM_ALL)
|
||||||
if (NOT MSVC)
|
if (NOT MSVC)
|
||||||
target_compile_options(SDL2-static PRIVATE -Wno-implicit-fallthrough)
|
target_compile_options(SDL2-static PRIVATE -Wno-implicit-fallthrough -Wno-shadow)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
add_subdirectory(../extern/dawn dawn EXCLUDE_FROM_ALL)
|
add_subdirectory(../extern/dawn dawn EXCLUDE_FROM_ALL)
|
||||||
|
@ -27,9 +27,6 @@ add_library(aurora STATIC
|
||||||
lib/gfx/movie_player/shader.cpp
|
lib/gfx/movie_player/shader.cpp
|
||||||
lib/gfx/textured_quad/shader.cpp
|
lib/gfx/textured_quad/shader.cpp
|
||||||
lib/gfx/colored_quad/shader.cpp
|
lib/gfx/colored_quad/shader.cpp
|
||||||
# TODO move to imgui? or move imgui impl to here?
|
|
||||||
../extern/imgui/backends/imgui_impl_sdl.cpp
|
|
||||||
../extern/imgui/backends/imgui_impl_wgpu.cpp
|
|
||||||
)
|
)
|
||||||
target_compile_definitions(aurora PRIVATE IMGUI_USER_CONFIG="imconfig_user.h") # IMGUI_USE_WCHAR32
|
target_compile_definitions(aurora PRIVATE IMGUI_USER_CONFIG="imconfig_user.h") # IMGUI_USE_WCHAR32
|
||||||
target_include_directories(aurora PUBLIC include ../Runtime)
|
target_include_directories(aurora PUBLIC include ../Runtime)
|
||||||
|
|
|
@ -174,6 +174,11 @@ struct Icon {
|
||||||
struct WindowSize {
|
struct WindowSize {
|
||||||
uint32_t width;
|
uint32_t width;
|
||||||
uint32_t height;
|
uint32_t height;
|
||||||
|
uint32_t fb_width;
|
||||||
|
uint32_t fb_height;
|
||||||
|
float scale;
|
||||||
|
|
||||||
|
bool operator<=>(const WindowSize& rhs) const = default;
|
||||||
};
|
};
|
||||||
enum class MouseButton {
|
enum class MouseButton {
|
||||||
None = 0,
|
None = 0,
|
||||||
|
|
|
@ -15,10 +15,10 @@ static logvisor::Module Log("aurora");
|
||||||
// TODO: Move global state to a class/struct?
|
// TODO: Move global state to a class/struct?
|
||||||
static std::unique_ptr<AppDelegate> g_AppDelegate;
|
static std::unique_ptr<AppDelegate> g_AppDelegate;
|
||||||
static std::vector<std::string> g_Args;
|
static std::vector<std::string> g_Args;
|
||||||
static float g_AppDpi = 1.f;
|
|
||||||
|
|
||||||
// SDL
|
// SDL
|
||||||
static SDL_Window* g_Window;
|
static SDL_Window* g_window;
|
||||||
|
static WindowSize g_windowSize;
|
||||||
|
|
||||||
// GPU
|
// GPU
|
||||||
using gpu::g_depthBuffer;
|
using gpu::g_depthBuffer;
|
||||||
|
@ -40,7 +40,7 @@ static void set_window_icon(Icon icon) noexcept {
|
||||||
Log.report(logvisor::Fatal, FMT_STRING("Failed to create icon surface: {}"), SDL_GetError());
|
Log.report(logvisor::Fatal, FMT_STRING("Failed to create icon surface: {}"), SDL_GetError());
|
||||||
unreachable();
|
unreachable();
|
||||||
}
|
}
|
||||||
SDL_SetWindowIcon(g_Window, iconSurface);
|
SDL_SetWindowIcon(g_window, iconSurface);
|
||||||
SDL_FreeSurface(iconSurface);
|
SDL_FreeSurface(iconSurface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,26 +58,26 @@ static bool poll_events() noexcept {
|
||||||
case SDL_WINDOWEVENT_HIDDEN: {
|
case SDL_WINDOWEVENT_HIDDEN: {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_WINDOWEVENT_EXPOSED: {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SDL_WINDOWEVENT_MOVED: {
|
case SDL_WINDOWEVENT_MOVED: {
|
||||||
g_AppDelegate->onAppWindowMoved(event.window.data1, event.window.data2);
|
g_AppDelegate->onAppWindowMoved(event.window.data1, event.window.data2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SDL_WINDOWEVENT_EXPOSED:
|
||||||
|
case SDL_WINDOWEVENT_DISPLAY_CHANGED:
|
||||||
|
case SDL_WINDOWEVENT_RESIZED:
|
||||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||||
case SDL_WINDOWEVENT_RESIZED: {
|
case SDL_WINDOWEVENT_MINIMIZED:
|
||||||
gpu::resize_swapchain(event.window.data1, event.window.data2);
|
|
||||||
g_AppDelegate->onAppWindowResized(
|
|
||||||
{static_cast<uint32_t>(event.window.data1), static_cast<uint32_t>(event.window.data2)});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SDL_WINDOWEVENT_MINIMIZED: {
|
|
||||||
// TODO: handle minimized event
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SDL_WINDOWEVENT_MAXIMIZED: {
|
case SDL_WINDOWEVENT_MAXIMIZED: {
|
||||||
// TODO: handle maximized event
|
const auto size = get_window_size();
|
||||||
|
if (size == g_windowSize) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (size.scale != g_windowSize.scale) {
|
||||||
|
g_AppDelegate->onAppDisplayScaleChanged(size.scale);
|
||||||
|
}
|
||||||
|
g_windowSize = size;
|
||||||
|
gpu::resize_swapchain(size.fb_width, size.fb_height);
|
||||||
|
g_AppDelegate->onAppWindowResized(size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_WINDOWEVENT_RESTORED: {
|
case SDL_WINDOWEVENT_RESTORED: {
|
||||||
|
@ -112,17 +112,6 @@ static bool poll_events() noexcept {
|
||||||
// TODO: handle hit test?
|
// TODO: handle hit test?
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_WINDOWEVENT_DISPLAY_CHANGED: {
|
|
||||||
printf("DISPLAY_CHANGED!\n");
|
|
||||||
float scale = 1.0f;
|
|
||||||
if (SDL_GetDisplayDPI(SDL_GetWindowDisplayIndex(g_Window), nullptr, &scale, nullptr) == 0) {
|
|
||||||
scale /= 96.0f;
|
|
||||||
if (g_AppDpi != scale) {
|
|
||||||
g_AppDelegate->onAppDisplayScaleChanged(scale);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -259,30 +248,29 @@ void app_run(std::unique_ptr<AppDelegate> app, Icon icon, int argc, char** argv)
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
g_Window = SDL_CreateWindow("Metaforce", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 1280, 720, flags);
|
g_window = SDL_CreateWindow("Metaforce", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 1280, 720, flags);
|
||||||
if (g_Window == nullptr) {
|
if (g_window == nullptr) {
|
||||||
Log.report(logvisor::Fatal, FMT_STRING("Error creating window: {}"), SDL_GetError());
|
Log.report(logvisor::Fatal, FMT_STRING("Error creating window: {}"), SDL_GetError());
|
||||||
unreachable();
|
unreachable();
|
||||||
}
|
}
|
||||||
set_window_icon(std::move(icon));
|
set_window_icon(std::move(icon));
|
||||||
|
|
||||||
gpu::initialize(g_Window);
|
gpu::initialize(g_window);
|
||||||
gfx::initialize();
|
gfx::initialize();
|
||||||
g_AppDpi = 1.0f;
|
|
||||||
if (SDL_GetDisplayDPI(SDL_GetWindowDisplayIndex(g_Window), nullptr, &g_AppDpi, nullptr) == 0) {
|
|
||||||
g_AppDpi /= 96.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
imgui::create_context();
|
imgui::create_context();
|
||||||
g_AppDelegate->onImGuiInit(g_AppDpi);
|
const auto size = get_window_size();
|
||||||
imgui::initialize(g_Window);
|
Log.report(logvisor::Info, FMT_STRING("Using framebuffer size {}x{} scale {}"), size.fb_width, size.fb_height,
|
||||||
|
size.scale);
|
||||||
|
g_AppDelegate->onImGuiInit(size.scale);
|
||||||
|
imgui::initialize(g_window);
|
||||||
g_AppDelegate->onImGuiAddTextures();
|
g_AppDelegate->onImGuiAddTextures();
|
||||||
|
|
||||||
g_AppDelegate->onAppLaunched();
|
g_AppDelegate->onAppLaunched();
|
||||||
g_AppDelegate->onAppWindowResized(get_window_size());
|
g_AppDelegate->onAppWindowResized(size);
|
||||||
|
|
||||||
while (poll_events()) {
|
while (poll_events()) {
|
||||||
imgui::new_frame();
|
imgui::new_frame(g_windowSize);
|
||||||
if (!g_AppDelegate->onAppIdle(ImGui::GetIO().DeltaTime)) {
|
if (!g_AppDelegate->onAppIdle(ImGui::GetIO().DeltaTime)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -354,19 +342,32 @@ void app_run(std::unique_ptr<AppDelegate> app, Icon icon, int argc, char** argv)
|
||||||
imgui::shutdown();
|
imgui::shutdown();
|
||||||
gfx::shutdown();
|
gfx::shutdown();
|
||||||
gpu::shutdown();
|
gpu::shutdown();
|
||||||
SDL_DestroyWindow(g_Window);
|
SDL_DestroyWindow(g_window);
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> get_args() noexcept { return g_Args; }
|
std::vector<std::string> get_args() noexcept { return g_Args; }
|
||||||
|
|
||||||
WindowSize get_window_size() noexcept {
|
WindowSize get_window_size() noexcept {
|
||||||
int width, height;
|
int width, height, fb_w, fb_h;
|
||||||
SDL_GetWindowSize(g_Window, &width, &height);
|
SDL_GetWindowSize(g_window, &width, &height);
|
||||||
return {static_cast<uint32_t>(width), static_cast<uint32_t>(height)};
|
SDL_GL_GetDrawableSize(g_window, &fb_w, &fb_h);
|
||||||
|
float scale = static_cast<float>(fb_w) / static_cast<float>(width);
|
||||||
|
#ifndef __APPLE__
|
||||||
|
if (SDL_GetDisplayDPI(SDL_GetWindowDisplayIndex(g_window), nullptr, &scale, nullptr) == 0) {
|
||||||
|
scale /= 96.f;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return {
|
||||||
|
.width = static_cast<uint32_t>(width),
|
||||||
|
.height = static_cast<uint32_t>(height),
|
||||||
|
.fb_width = static_cast<uint32_t>(fb_w),
|
||||||
|
.fb_height = static_cast<uint32_t>(fb_h),
|
||||||
|
.scale = scale,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_window_title(zstring_view title) noexcept { SDL_SetWindowTitle(g_Window, title.c_str()); }
|
void set_window_title(zstring_view title) noexcept { SDL_SetWindowTitle(g_window, title.c_str()); }
|
||||||
|
|
||||||
Backend get_backend() noexcept {
|
Backend get_backend() noexcept {
|
||||||
switch (gpu::g_backendType) {
|
switch (gpu::g_backendType) {
|
||||||
|
@ -392,7 +393,7 @@ Backend get_backend() noexcept {
|
||||||
std::string_view get_backend_string() noexcept { return magic_enum::enum_name(gpu::g_backendType); }
|
std::string_view get_backend_string() noexcept { return magic_enum::enum_name(gpu::g_backendType); }
|
||||||
|
|
||||||
void set_fullscreen(bool fullscreen) noexcept {
|
void set_fullscreen(bool fullscreen) noexcept {
|
||||||
SDL_SetWindowFullscreen(g_Window, fullscreen ? SDL_WINDOW_FULLSCREEN : 0);
|
SDL_SetWindowFullscreen(g_window, fullscreen ? SDL_WINDOW_FULLSCREEN : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t get_controller_player_index(uint32_t instance) noexcept { return input::player_index(instance); }
|
int32_t get_controller_player_index(uint32_t instance) noexcept { return input::player_index(instance); }
|
||||||
|
@ -409,5 +410,6 @@ void controller_rumble(uint32_t instance, uint16_t low_freq_intensity, uint16_t
|
||||||
uint32_t duration_ms) noexcept {
|
uint32_t duration_ms) noexcept {
|
||||||
input::controller_rumble(instance, low_freq_intensity, high_freq_intensity, duration_ms);
|
input::controller_rumble(instance, low_freq_intensity, high_freq_intensity, duration_ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string get_controller_name(uint32_t instance) noexcept { return input::controller_name(instance); }
|
std::string get_controller_name(uint32_t instance) noexcept { return input::controller_name(instance); }
|
||||||
} // namespace aurora
|
} // namespace aurora
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#include "gpu.hpp"
|
#include "gpu.hpp"
|
||||||
|
|
||||||
|
#include <SDL.h>
|
||||||
#include <dawn/native/DawnNative.h>
|
#include <dawn/native/DawnNative.h>
|
||||||
#include <dawn/webgpu_cpp.h>
|
#include <dawn/webgpu_cpp.h>
|
||||||
#include <logvisor/logvisor.hpp>
|
#include <logvisor/logvisor.hpp>
|
||||||
#include <magic_enum.hpp>
|
#include <magic_enum.hpp>
|
||||||
#include <SDL.h>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "dawn/BackendBinding.hpp"
|
#include "dawn/BackendBinding.hpp"
|
||||||
|
@ -168,7 +168,7 @@ void initialize(SDL_Window* window) {
|
||||||
{
|
{
|
||||||
int width = 0;
|
int width = 0;
|
||||||
int height = 0;
|
int height = 0;
|
||||||
SDL_GetWindowSize(window, &width, &height);
|
SDL_GL_GetDrawableSize(window, &width, &height);
|
||||||
g_graphicsConfig = GraphicsConfig{
|
g_graphicsConfig = GraphicsConfig{
|
||||||
.width = static_cast<uint32_t>(width),
|
.width = static_cast<uint32_t>(width),
|
||||||
.height = static_cast<uint32_t>(height),
|
.height = static_cast<uint32_t>(height),
|
||||||
|
|
|
@ -2,15 +2,20 @@
|
||||||
|
|
||||||
#include "gpu.hpp"
|
#include "gpu.hpp"
|
||||||
|
|
||||||
|
#include <SDL.h>
|
||||||
|
#include <aurora/aurora.hpp>
|
||||||
#include <aurora/imgui.hpp>
|
#include <aurora/imgui.hpp>
|
||||||
#include <backends/imgui_impl_sdl.h>
|
|
||||||
#include <backends/imgui_impl_wgpu.h>
|
|
||||||
#include <dawn/webgpu_cpp.h>
|
#include <dawn/webgpu_cpp.h>
|
||||||
|
|
||||||
|
#include "../extern/imgui/backends/imgui_impl_sdl.cpp"
|
||||||
|
#include "../extern/imgui/backends/imgui_impl_wgpu.cpp"
|
||||||
|
|
||||||
namespace aurora::imgui {
|
namespace aurora::imgui {
|
||||||
using gpu::g_device;
|
using gpu::g_device;
|
||||||
using gpu::g_queue;
|
using gpu::g_queue;
|
||||||
|
|
||||||
|
static float g_scale;
|
||||||
|
|
||||||
void create_context() noexcept {
|
void create_context() noexcept {
|
||||||
IMGUI_CHECKVERSION();
|
IMGUI_CHECKVERSION();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
|
@ -19,9 +24,11 @@ void create_context() noexcept {
|
||||||
}
|
}
|
||||||
|
|
||||||
void initialize(SDL_Window* window) noexcept {
|
void initialize(SDL_Window* window) noexcept {
|
||||||
// this just passes through to ImGui_ImplSDL2_Init (private)
|
ImGui_ImplSDL2_Init(window, nullptr);
|
||||||
// may need to change in the future
|
#ifdef __APPLE__
|
||||||
ImGui_ImplSDL2_InitForMetal(window);
|
// Disable MouseCanUseGlobalState for scaling purposes
|
||||||
|
ImGui_ImplSDL2_GetBackendData()->MouseCanUseGlobalState = false;
|
||||||
|
#endif
|
||||||
ImGui_ImplWGPU_Init(g_device.Get(), 1, static_cast<WGPUTextureFormat>(gpu::g_graphicsConfig.colorFormat));
|
ImGui_ImplWGPU_Init(g_device.Get(), 1, static_cast<WGPUTextureFormat>(gpu::g_graphicsConfig.colorFormat));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,17 +38,36 @@ void shutdown() noexcept {
|
||||||
ImGui::DestroyContext();
|
ImGui::DestroyContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_event(const SDL_Event& event) noexcept { ImGui_ImplSDL2_ProcessEvent(&event); }
|
void process_event(const SDL_Event& event) noexcept {
|
||||||
|
#ifdef __APPLE__
|
||||||
|
if (event.type == SDL_MOUSEMOTION) {
|
||||||
|
auto& io = ImGui::GetIO();
|
||||||
|
// Scale up mouse coordinates
|
||||||
|
io.AddMousePosEvent(static_cast<float>(event.motion.x) * g_scale,
|
||||||
|
static_cast<float>(event.motion.y) * g_scale);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
ImGui_ImplSDL2_ProcessEvent(&event);
|
||||||
|
}
|
||||||
|
|
||||||
void new_frame() noexcept {
|
void new_frame(const WindowSize& size) noexcept {
|
||||||
ImGui_ImplWGPU_NewFrame();
|
ImGui_ImplWGPU_NewFrame();
|
||||||
ImGui_ImplSDL2_NewFrame();
|
ImGui_ImplSDL2_NewFrame();
|
||||||
|
|
||||||
|
// Render at full DPI
|
||||||
|
g_scale = size.scale;
|
||||||
|
ImGui::GetIO().DisplaySize = ImVec2{static_cast<float>(size.fb_width), static_cast<float>(size.fb_height)};
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void render(const wgpu::RenderPassEncoder& pass) noexcept {
|
void render(const wgpu::RenderPassEncoder& pass) noexcept {
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
ImGui_ImplWGPU_RenderDrawData(ImGui::GetDrawData(), pass.Get());
|
|
||||||
|
auto* data = ImGui::GetDrawData();
|
||||||
|
// io.DisplayFramebufferScale is informational; we're rendering at full DPI
|
||||||
|
data->FramebufferScale = {1.f, 1.f};
|
||||||
|
ImGui_ImplWGPU_RenderDrawData(data, pass.Get());
|
||||||
}
|
}
|
||||||
|
|
||||||
ImTextureID add_texture(uint32_t width, uint32_t height, ArrayRef<uint8_t> data) noexcept {
|
ImTextureID add_texture(uint32_t width, uint32_t height, ArrayRef<uint8_t> data) noexcept {
|
||||||
|
|
|
@ -7,12 +7,16 @@ namespace wgpu {
|
||||||
class RenderPassEncoder;
|
class RenderPassEncoder;
|
||||||
} // namespace wgpu
|
} // namespace wgpu
|
||||||
|
|
||||||
|
namespace aurora {
|
||||||
|
struct WindowSize;
|
||||||
|
} // namespace aurora
|
||||||
|
|
||||||
namespace aurora::imgui {
|
namespace aurora::imgui {
|
||||||
void create_context() noexcept;
|
void create_context() noexcept;
|
||||||
void initialize(SDL_Window* window) noexcept;
|
void initialize(SDL_Window* window) noexcept;
|
||||||
void shutdown() noexcept;
|
void shutdown() noexcept;
|
||||||
|
|
||||||
void process_event(const SDL_Event& event) noexcept;
|
void process_event(const SDL_Event& event) noexcept;
|
||||||
void new_frame() noexcept;
|
void new_frame(const WindowSize& size) noexcept;
|
||||||
void render(const wgpu::RenderPassEncoder& pass) noexcept;
|
void render(const wgpu::RenderPassEncoder& pass) noexcept;
|
||||||
} // namespace aurora::imgui
|
} // namespace aurora::imgui
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 16612cae46c00bbd3e166896bd8125bb6a35b4f3
|
Subproject commit af40cb6f006ccdb46f6db1c3f7b0cf6e187f0f0d
|
|
@ -59,6 +59,7 @@ void ImGuiEngine_Initialize(float scale) {
|
||||||
ImGuiEngine::fontLarge = io.Fonts->AddFont(&fontConfig);
|
ImGuiEngine::fontLarge = io.Fonts->AddFont(&fontConfig);
|
||||||
|
|
||||||
auto& style = ImGui::GetStyle();
|
auto& style = ImGui::GetStyle();
|
||||||
|
style = {}; // Reset sizes
|
||||||
style.WindowPadding = ImVec2(15, 15);
|
style.WindowPadding = ImVec2(15, 15);
|
||||||
style.WindowRounding = 5.0f;
|
style.WindowRounding = 5.0f;
|
||||||
style.FrameBorderSize = 1.f;
|
style.FrameBorderSize = 1.f;
|
||||||
|
|
|
@ -12,7 +12,6 @@ public:
|
||||||
static ImTextureID metaforceIcon;
|
static ImTextureID metaforceIcon;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Called from Rust
|
|
||||||
void ImGuiEngine_Initialize(float scale);
|
void ImGuiEngine_Initialize(float scale);
|
||||||
void ImGuiEngine_AddTextures();
|
void ImGuiEngine_AddTextures();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
origin=$(git remote get-url origin)
|
||||||
|
origin_base=${origin%/*}
|
||||||
|
|
||||||
|
for sub in "extern/amuse" \
|
||||||
|
"extern/boo" \
|
||||||
|
"extern/jbus" \
|
||||||
|
"extern/kabufuda" \
|
||||||
|
"extern/libjpeg-turbo" \
|
||||||
|
"extern/libpng" \
|
||||||
|
"extern/libSquish" \
|
||||||
|
"extern/nod" \
|
||||||
|
"extern/tinyxml2" \
|
||||||
|
"extern/xxhash" \
|
||||||
|
"extern/zeus"; do
|
||||||
|
if [ -d $sub ]; then
|
||||||
|
pushd $sub > /dev/null
|
||||||
|
sub_name=$(basename $sub)
|
||||||
|
popd > /dev/null
|
||||||
|
echo "Changing url for submodule ${sub} to https://github.com/AxioDL/${sub_name}.git"
|
||||||
|
git config submodule.$sub.url https://github.com/AxioDL/$sub_name.git
|
||||||
|
git submodule init $sub
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo Updating submodules
|
||||||
|
git submodule update --init --recursive
|
||||||
|
echo Done
|
Loading…
Reference in New Issue