3#ifndef YAZE_APP_PLATFORM_SDL3_WINDOW_BACKEND_H_
4#define YAZE_APP_PLATFORM_SDL3_WINDOW_BACKEND_H_
14#include "absl/status/status.h"
21struct SDL3WindowDeleter {
22 void operator()(SDL_Window* p)
const {
23 if (p) SDL_DestroyWindow(p);
36class SDL3WindowBackend :
public IWindowBackend {
38 SDL3WindowBackend() =
default;
39 ~SDL3WindowBackend()
override;
45 absl::Status Initialize(
const WindowConfig& config)
override;
46 absl::Status Shutdown()
override;
47 bool IsInitialized()
const override {
return initialized_; }
49 bool PollEvent(WindowEvent& out_event)
override;
50 void ProcessNativeEvent(
void* native_event)
override;
52 WindowStatus GetStatus()
const override;
53 bool IsActive()
const override {
return active_; }
54 void SetActive(
bool active)
override { active_ = active; }
56 void GetSize(
int* width,
int* height)
const override;
57 void SetSize(
int width,
int height)
override;
58 std::string GetTitle()
const override;
59 void SetTitle(
const std::string& title)
override;
61 bool InitializeRenderer(gfx::IRenderer* renderer)
override;
62 SDL_Window* GetNativeWindow()
override {
return window_.get(); }
64 absl::Status InitializeImGui(gfx::IRenderer* renderer)
override;
65 void ShutdownImGui()
override;
66 void NewImGuiFrame()
override;
67 void RenderImGui(gfx::IRenderer* renderer)
override;
69 uint32_t GetAudioDevice()
const override {
return 0; }
70 std::shared_ptr<int16_t> GetAudioBuffer()
const override {
74 std::string GetBackendName()
const override {
return "SDL3"; }
75 int GetSDLVersion()
const override {
return 3; }
79 WindowEvent ConvertSDL3Event(
const SDL_Event& sdl_event);
82 void UpdateModifierState();
84 std::unique_ptr<SDL_Window, SDL3WindowDeleter> window_;
85 bool initialized_ =
false;
87 bool is_resizing_ =
false;
88 bool imgui_initialized_ =
false;
91 bool key_shift_ =
false;
92 bool key_ctrl_ =
false;
93 bool key_alt_ =
false;
94 bool key_super_ =
false;
97 std::shared_ptr<int16_t> audio_buffer_;