yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::platform::SDL2WindowBackend Class Reference

SDL2 implementation of the window backend interface. More...

#include <sdl2_window_backend.h>

Inheritance diagram for yaze::platform::SDL2WindowBackend:
Collaboration diagram for yaze::platform::SDL2WindowBackend:

Public Member Functions

 SDL2WindowBackend ()=default
 
 ~SDL2WindowBackend () override
 
absl::Status Initialize (const WindowConfig &config) override
 Initialize the window backend with configuration.
 
absl::Status Shutdown () override
 Shutdown the window backend and release resources.
 
bool IsInitialized () const override
 Check if the backend is initialized.
 
bool PollEvent (WindowEvent &out_event) override
 Poll and process pending events.
 
void ProcessNativeEvent (void *native_event) override
 Process a native SDL event (for ImGui integration)
 
WindowStatus GetStatus () const override
 Get current window status.
 
bool IsActive () const override
 Check if window is still active (not closed)
 
void SetActive (bool active) override
 Set window active state.
 
void GetSize (int *width, int *height) const override
 Get window dimensions.
 
void SetSize (int width, int height) override
 Set window dimensions.
 
std::string GetTitle () const override
 Get window title.
 
void SetTitle (const std::string &title) override
 Set window title.
 
bool InitializeRenderer (gfx::IRenderer *renderer) override
 Initialize renderer for this window.
 
SDL_Window * GetNativeWindow () override
 Get the underlying SDL_Window pointer for ImGui integration.
 
absl::Status InitializeImGui (gfx::IRenderer *renderer) override
 Initialize ImGui backends for this window/renderer combo.
 
void ShutdownImGui () override
 Shutdown ImGui backends.
 
void NewImGuiFrame () override
 Start a new ImGui frame.
 
void RenderImGui (gfx::IRenderer *renderer) override
 Render ImGui draw data (and viewports if enabled)
 
uint32_t GetAudioDevice () const override
 Get audio device ID (for legacy audio buffer management)
 
std::shared_ptr< int16_t > GetAudioBuffer () const override
 Get audio buffer (for legacy audio management)
 
std::string GetBackendName () const override
 Get backend name for debugging/logging.
 
int GetSDLVersion () const override
 Get SDL version being used.
 
- Public Member Functions inherited from yaze::platform::IWindowBackend
virtual ~IWindowBackend ()=default
 

Private Member Functions

WindowEvent ConvertSDL2Event (const SDL_Event &sdl_event)
 
void UpdateModifierState ()
 

Private Attributes

std::unique_ptr< SDL_Window, util::SDL_Deleterwindow_
 
bool initialized_ = false
 
bool active_ = true
 
bool is_resizing_ = false
 
bool imgui_initialized_ = false
 
bool key_shift_ = false
 
bool key_ctrl_ = false
 
bool key_alt_ = false
 
bool key_super_ = false
 
SDL_AudioDeviceID audio_device_ = 0
 
std::shared_ptr< int16_t > audio_buffer_
 

Detailed Description

SDL2 implementation of the window backend interface.

Wraps SDL2 window management, event handling, and ImGui integration for the main YAZE application window.

Definition at line 24 of file sdl2_window_backend.h.

Constructor & Destructor Documentation

◆ SDL2WindowBackend()

yaze::platform::SDL2WindowBackend::SDL2WindowBackend ( )
default

◆ ~SDL2WindowBackend()

yaze::platform::SDL2WindowBackend::~SDL2WindowBackend ( )
override

Definition at line 31 of file sdl2_window_backend.cc.

References initialized_, and Shutdown().

Here is the call graph for this function:

Member Function Documentation

◆ Initialize()

absl::Status yaze::platform::SDL2WindowBackend::Initialize ( const WindowConfig & config)
overridevirtual

◆ Shutdown()

absl::Status yaze::platform::SDL2WindowBackend::Shutdown ( )
overridevirtual

Shutdown the window backend and release resources.

Returns
Status indicating success or failure

Implements yaze::platform::IWindowBackend.

Definition at line 112 of file sdl2_window_backend.cc.

References audio_device_, yaze::gfx::Arena::Get(), imgui_initialized_, initialized_, LOG_INFO, yaze::gfx::Arena::Shutdown(), ShutdownImGui(), and window_.

Referenced by Initialize(), and ~SDL2WindowBackend().

Here is the call graph for this function:

◆ IsInitialized()

bool yaze::platform::SDL2WindowBackend::IsInitialized ( ) const
inlineoverridevirtual

Check if the backend is initialized.

Implements yaze::platform::IWindowBackend.

Definition at line 35 of file sdl2_window_backend.h.

References initialized_.

◆ PollEvent()

bool yaze::platform::SDL2WindowBackend::PollEvent ( WindowEvent & out_event)
overridevirtual

Poll and process pending events.

Parameters
out_eventOutput parameter for the next event
Returns
True if an event was available, false otherwise

Implements yaze::platform::IWindowBackend.

Definition at line 148 of file sdl2_window_backend.cc.

References ConvertSDL2Event(), yaze::platform::WindowEvent::has_native_event, imgui_initialized_, and yaze::platform::WindowEvent::native_event.

Here is the call graph for this function:

◆ ProcessNativeEvent()

void yaze::platform::SDL2WindowBackend::ProcessNativeEvent ( void * native_event)
overridevirtual

Process a native SDL event (for ImGui integration)

Parameters
native_eventPointer to native SDL_Event

Implements yaze::platform::IWindowBackend.

Definition at line 165 of file sdl2_window_backend.cc.

References imgui_initialized_.

◆ GetStatus()

◆ IsActive()

bool yaze::platform::SDL2WindowBackend::IsActive ( ) const
inlineoverridevirtual

Check if window is still active (not closed)

Implements yaze::platform::IWindowBackend.

Definition at line 41 of file sdl2_window_backend.h.

References active_.

◆ SetActive()

void yaze::platform::SDL2WindowBackend::SetActive ( bool active)
inlineoverridevirtual

Set window active state.

Implements yaze::platform::IWindowBackend.

Definition at line 42 of file sdl2_window_backend.h.

References active_.

◆ GetSize()

void yaze::platform::SDL2WindowBackend::GetSize ( int * width,
int * height ) const
overridevirtual

Get window dimensions.

Implements yaze::platform::IWindowBackend.

Definition at line 328 of file sdl2_window_backend.cc.

References window_.

◆ SetSize()

void yaze::platform::SDL2WindowBackend::SetSize ( int width,
int height )
overridevirtual

Set window dimensions.

Implements yaze::platform::IWindowBackend.

Definition at line 337 of file sdl2_window_backend.cc.

References window_.

◆ GetTitle()

std::string yaze::platform::SDL2WindowBackend::GetTitle ( ) const
overridevirtual

Get window title.

Implements yaze::platform::IWindowBackend.

Definition at line 343 of file sdl2_window_backend.cc.

References window_.

◆ SetTitle()

void yaze::platform::SDL2WindowBackend::SetTitle ( const std::string & title)
overridevirtual

Set window title.

Implements yaze::platform::IWindowBackend.

Definition at line 351 of file sdl2_window_backend.cc.

References window_.

◆ InitializeRenderer()

bool yaze::platform::SDL2WindowBackend::InitializeRenderer ( gfx::IRenderer * renderer)
overridevirtual

Initialize renderer for this window.

Parameters
rendererThe renderer to initialize
Returns
True if successful

Implements yaze::platform::IWindowBackend.

Definition at line 357 of file sdl2_window_backend.cc.

References yaze::gfx::IRenderer::GetBackendRenderer(), yaze::gfx::IRenderer::Initialize(), and window_.

Here is the call graph for this function:

◆ GetNativeWindow()

SDL_Window * yaze::platform::SDL2WindowBackend::GetNativeWindow ( )
inlineoverridevirtual

Get the underlying SDL_Window pointer for ImGui integration.

Returns
Native window handle (SDL_Window*)

Implements yaze::platform::IWindowBackend.

Definition at line 50 of file sdl2_window_backend.h.

References window_.

◆ InitializeImGui()

absl::Status yaze::platform::SDL2WindowBackend::InitializeImGui ( gfx::IRenderer * renderer)
overridevirtual

Initialize ImGui backends for this window/renderer combo.

Parameters
rendererThe renderer (for backend-specific init)
Returns
Status indicating success or failure

Implements yaze::platform::IWindowBackend.

Definition at line 370 of file sdl2_window_backend.cc.

References yaze::gui::ColorsYaze(), yaze::gfx::IRenderer::GetBackendRenderer(), imgui_initialized_, yaze::LoadPackageFonts(), LOG_INFO, RETURN_IF_ERROR, and window_.

Here is the call graph for this function:

◆ ShutdownImGui()

void yaze::platform::SDL2WindowBackend::ShutdownImGui ( )
overridevirtual

Shutdown ImGui backends.

Implements yaze::platform::IWindowBackend.

Definition at line 423 of file sdl2_window_backend.cc.

References imgui_initialized_, and LOG_INFO.

Referenced by Shutdown().

◆ NewImGuiFrame()

void yaze::platform::SDL2WindowBackend::NewImGuiFrame ( )
overridevirtual

Start a new ImGui frame.

Implements yaze::platform::IWindowBackend.

Definition at line 438 of file sdl2_window_backend.cc.

References imgui_initialized_.

◆ RenderImGui()

void yaze::platform::SDL2WindowBackend::RenderImGui ( gfx::IRenderer * renderer)
overridevirtual

Render ImGui draw data (and viewports if enabled)

Parameters
rendererThe renderer to use for drawing (needed to get backend renderer)

Implements yaze::platform::IWindowBackend.

Definition at line 450 of file sdl2_window_backend.cc.

References yaze::gfx::IRenderer::GetBackendRenderer(), and imgui_initialized_.

Here is the call graph for this function:

◆ GetAudioDevice()

uint32_t yaze::platform::SDL2WindowBackend::GetAudioDevice ( ) const
inlineoverridevirtual

Get audio device ID (for legacy audio buffer management)

Implements yaze::platform::IWindowBackend.

Definition at line 57 of file sdl2_window_backend.h.

References audio_device_.

◆ GetAudioBuffer()

std::shared_ptr< int16_t > yaze::platform::SDL2WindowBackend::GetAudioBuffer ( ) const
inlineoverridevirtual

Get audio buffer (for legacy audio management)

Implements yaze::platform::IWindowBackend.

Definition at line 58 of file sdl2_window_backend.h.

References audio_buffer_.

◆ GetBackendName()

std::string yaze::platform::SDL2WindowBackend::GetBackendName ( ) const
inlineoverridevirtual

Get backend name for debugging/logging.

Implements yaze::platform::IWindowBackend.

Definition at line 62 of file sdl2_window_backend.h.

◆ GetSDLVersion()

int yaze::platform::SDL2WindowBackend::GetSDLVersion ( ) const
inlineoverridevirtual

Get SDL version being used.

Implements yaze::platform::IWindowBackend.

Definition at line 63 of file sdl2_window_backend.h.

◆ ConvertSDL2Event()

◆ UpdateModifierState()

void yaze::platform::SDL2WindowBackend::UpdateModifierState ( )
private

Definition at line 301 of file sdl2_window_backend.cc.

References key_alt_, key_ctrl_, key_shift_, and key_super_.

Referenced by ConvertSDL2Event().

Member Data Documentation

◆ window_

std::unique_ptr<SDL_Window, util::SDL_Deleter> yaze::platform::SDL2WindowBackend::window_
private

◆ initialized_

bool yaze::platform::SDL2WindowBackend::initialized_ = false
private

Definition at line 73 of file sdl2_window_backend.h.

Referenced by Initialize(), IsInitialized(), Shutdown(), and ~SDL2WindowBackend().

◆ active_

bool yaze::platform::SDL2WindowBackend::active_ = true
private

Definition at line 74 of file sdl2_window_backend.h.

Referenced by ConvertSDL2Event(), GetStatus(), Initialize(), IsActive(), and SetActive().

◆ is_resizing_

bool yaze::platform::SDL2WindowBackend::is_resizing_ = false
private

Definition at line 75 of file sdl2_window_backend.h.

Referenced by ConvertSDL2Event(), and GetStatus().

◆ imgui_initialized_

bool yaze::platform::SDL2WindowBackend::imgui_initialized_ = false
private

◆ key_shift_

bool yaze::platform::SDL2WindowBackend::key_shift_ = false
private

Definition at line 79 of file sdl2_window_backend.h.

Referenced by ConvertSDL2Event(), and UpdateModifierState().

◆ key_ctrl_

bool yaze::platform::SDL2WindowBackend::key_ctrl_ = false
private

Definition at line 80 of file sdl2_window_backend.h.

Referenced by ConvertSDL2Event(), and UpdateModifierState().

◆ key_alt_

bool yaze::platform::SDL2WindowBackend::key_alt_ = false
private

Definition at line 81 of file sdl2_window_backend.h.

Referenced by ConvertSDL2Event(), and UpdateModifierState().

◆ key_super_

bool yaze::platform::SDL2WindowBackend::key_super_ = false
private

Definition at line 82 of file sdl2_window_backend.h.

Referenced by ConvertSDL2Event(), and UpdateModifierState().

◆ audio_device_

SDL_AudioDeviceID yaze::platform::SDL2WindowBackend::audio_device_ = 0
private

Definition at line 85 of file sdl2_window_backend.h.

Referenced by GetAudioDevice(), and Shutdown().

◆ audio_buffer_

std::shared_ptr<int16_t> yaze::platform::SDL2WindowBackend::audio_buffer_
private

Definition at line 86 of file sdl2_window_backend.h.

Referenced by GetAudioBuffer(), and Initialize().


The documentation for this class was generated from the following files: