80 lines
2.1 KiB
C++
80 lines
2.1 KiB
C++
#pragma once
|
|
#include <ParallelRDPWrapper.hpp>
|
|
#include <SDL3/SDL.h>
|
|
#include <SDL3/SDL_vulkan.h>
|
|
|
|
struct InputSettings;
|
|
|
|
namespace n64 {
|
|
struct Core;
|
|
}
|
|
|
|
class SDLParallelRdpWindowInfo final : public ParallelRDP::WindowInfo {
|
|
public:
|
|
explicit SDLParallelRdpWindowInfo(SDL_Window* window) : window(window) {}
|
|
CoordinatePair get_window_size() override {
|
|
int w,h;
|
|
SDL_GetWindowSizeInPixels(window, &w, &h);
|
|
return CoordinatePair{static_cast<float>(w), static_cast<float>(h)};
|
|
}
|
|
|
|
private:
|
|
SDL_Window* window{};
|
|
};
|
|
|
|
class SDLWSIPlatform final : public Vulkan::WSIPlatform {
|
|
public:
|
|
explicit SDLWSIPlatform(SDL_Window* window) : window(window) {}
|
|
~SDLWSIPlatform() = default;
|
|
|
|
std::vector<const char *> get_instance_extensions() override {
|
|
auto vec = std::vector<const char *>();
|
|
u32 extCount;
|
|
const auto &extensions = SDL_Vulkan_GetInstanceExtensions(&extCount);
|
|
vec.resize(extCount);
|
|
|
|
for (u32 i = 0; i < extCount; i++) {
|
|
vec[i] = extensions[i];
|
|
}
|
|
|
|
return vec;
|
|
}
|
|
|
|
VkSurfaceKHR create_surface(VkInstance instance, VkPhysicalDevice pDevice) override {
|
|
SDL_Vulkan_CreateSurface(window, instance, nullptr, &surface);
|
|
return surface;
|
|
}
|
|
|
|
void destroy_surface(VkInstance instance, VkSurfaceKHR surface) override {
|
|
SDL_Vulkan_DestroySurface(instance, surface, nullptr);
|
|
}
|
|
|
|
uint32_t get_surface_width() override { return 640; }
|
|
|
|
uint32_t get_surface_height() override { return 480; }
|
|
|
|
bool alive(Vulkan::WSI &) override { return true; }
|
|
|
|
void poll_input() override {}
|
|
void poll_input_async(Granite::InputTrackerHandler *handler) override {}
|
|
|
|
void event_frame_tick(double frame, double elapsed) override {}
|
|
|
|
const VkApplicationInfo *get_application_info() override { return &appInfo; }
|
|
|
|
VkApplicationInfo appInfo{.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO, .apiVersion = VK_API_VERSION_1_3};
|
|
|
|
SDL_Window* window{};
|
|
VkSurfaceKHR surface;
|
|
private:
|
|
bool gamepadConnected = false;
|
|
};
|
|
|
|
class RenderWidget final {
|
|
public:
|
|
explicit RenderWidget(SDL_Window*);
|
|
|
|
std::shared_ptr<ParallelRDP::WindowInfo> windowInfo;
|
|
std::shared_ptr<SDLWSIPlatform> wsiPlatform;
|
|
};
|