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

ImGui panel that streams live screenshots from a running Mesen2 emulator via socket and displays them as a GPU texture preview. More...

#include <mesen_screenshot_panel.h>

Public Member Functions

 MesenScreenshotPanel ()
 
 ~MesenScreenshotPanel ()
 
 MesenScreenshotPanel (const MesenScreenshotPanel &)=delete
 
MesenScreenshotPaneloperator= (const MesenScreenshotPanel &)=delete
 
void Draw ()
 
void SetClient (std::shared_ptr< emu::mesen::MesenSocketClient > client)
 
bool IsConnected () const
 
void Connect ()
 
void ConnectToPath (const std::string &socket_path)
 
void Disconnect ()
 

Private Member Functions

void DrawConnectionHeader ()
 
void DrawControlsToolbar ()
 
void DrawPreviewArea ()
 
void DrawStatusBar ()
 
void RefreshSocketList ()
 
void CaptureScreenshot ()
 
void UpdateTexture (const std::vector< uint8_t > &rgba, int width, int height)
 
void EnsureTexture (int width, int height)
 
void DestroyTexture ()
 

Static Private Member Functions

static std::vector< uint8_t > DecodeBase64 (const std::string &encoded)
 
static bool DecodePngToRgba (const std::vector< uint8_t > &png_data, std::vector< uint8_t > &rgba_out, int &width_out, int &height_out)
 

Private Attributes

std::shared_ptr< emu::mesen::MesenSocketClientclient_
 
SDL_Texture * texture_ = nullptr
 
int texture_width_ = 0
 
int texture_height_ = 0
 
int frame_width_ = 0
 
int frame_height_ = 0
 
uint64_t frame_counter_ = 0
 
float last_capture_latency_ms_ = 0.0f
 
bool frame_stale_ = false
 
bool streaming_ = false
 
float target_fps_ = 10.0f
 
float time_accumulator_ = 0.0f
 
std::string connection_error_
 
std::vector< std::string > socket_paths_
 
int selected_socket_index_ = -1
 
char socket_path_buffer_ [256] = {}
 
std::string status_message_
 

Detailed Description

ImGui panel that streams live screenshots from a running Mesen2 emulator via socket and displays them as a GPU texture preview.

The panel polls the Mesen2 Screenshot() API at a configurable rate, decodes the base64-encoded PNG response to RGBA pixels, uploads them to an SDL texture, and renders the result with ImGui::Image().

Definition at line 22 of file mesen_screenshot_panel.h.

Constructor & Destructor Documentation

◆ MesenScreenshotPanel() [1/2]

yaze::editor::MesenScreenshotPanel::MesenScreenshotPanel ( )

◆ ~MesenScreenshotPanel()

yaze::editor::MesenScreenshotPanel::~MesenScreenshotPanel ( )

Definition at line 188 of file mesen_screenshot_panel.cc.

References DestroyTexture().

Here is the call graph for this function:

◆ MesenScreenshotPanel() [2/2]

yaze::editor::MesenScreenshotPanel::MesenScreenshotPanel ( const MesenScreenshotPanel & )
delete

Member Function Documentation

◆ operator=()

MesenScreenshotPanel & yaze::editor::MesenScreenshotPanel::operator= ( const MesenScreenshotPanel & )
delete

◆ Draw()

◆ SetClient()

void yaze::editor::MesenScreenshotPanel::SetClient ( std::shared_ptr< emu::mesen::MesenSocketClient > client)

Definition at line 194 of file mesen_screenshot_panel.cc.

References client_, and yaze::emu::mesen::MesenClientRegistry::SetClient().

Here is the call graph for this function:

◆ IsConnected()

bool yaze::editor::MesenScreenshotPanel::IsConnected ( ) const

Definition at line 200 of file mesen_screenshot_panel.cc.

References client_.

Referenced by CaptureScreenshot(), Draw(), DrawConnectionHeader(), and DrawStatusBar().

◆ Connect()

void yaze::editor::MesenScreenshotPanel::Connect ( )

◆ ConnectToPath()

void yaze::editor::MesenScreenshotPanel::ConnectToPath ( const std::string & socket_path)

◆ Disconnect()

void yaze::editor::MesenScreenshotPanel::Disconnect ( )

Definition at line 230 of file mesen_screenshot_panel.cc.

References client_, and streaming_.

Referenced by DrawConnectionHeader().

◆ DrawConnectionHeader()

◆ DrawControlsToolbar()

void yaze::editor::MesenScreenshotPanel::DrawControlsToolbar ( )
private

Definition at line 480 of file mesen_screenshot_panel.cc.

References CaptureScreenshot(), ICON_MD_PAUSE, ICON_MD_PHOTO_CAMERA, ICON_MD_PLAY_ARROW, streaming_, target_fps_, and time_accumulator_.

Referenced by Draw().

Here is the call graph for this function:

◆ DrawPreviewArea()

void yaze::editor::MesenScreenshotPanel::DrawPreviewArea ( )
private

Definition at line 511 of file mesen_screenshot_panel.cc.

References frame_counter_, frame_height_, frame_stale_, frame_width_, yaze::editor::AgentUI::GetTheme(), last_capture_latency_ms_, and texture_.

Referenced by Draw().

Here is the call graph for this function:

◆ DrawStatusBar()

void yaze::editor::MesenScreenshotPanel::DrawStatusBar ( )
private

Definition at line 568 of file mesen_screenshot_panel.cc.

References yaze::editor::AgentUI::GetTheme(), ICON_MD_FIBER_MANUAL_RECORD, IsConnected(), socket_path_buffer_, status_message_, streaming_, and target_fps_.

Referenced by Draw().

Here is the call graph for this function:

◆ RefreshSocketList()

void yaze::editor::MesenScreenshotPanel::RefreshSocketList ( )
private

◆ CaptureScreenshot()

void yaze::editor::MesenScreenshotPanel::CaptureScreenshot ( )
private

◆ UpdateTexture()

void yaze::editor::MesenScreenshotPanel::UpdateTexture ( const std::vector< uint8_t > & rgba,
int width,
int height )
private

Definition at line 290 of file mesen_screenshot_panel.cc.

References EnsureTexture(), and texture_.

Referenced by CaptureScreenshot().

Here is the call graph for this function:

◆ EnsureTexture()

void yaze::editor::MesenScreenshotPanel::EnsureTexture ( int width,
int height )
private

Definition at line 257 of file mesen_screenshot_panel.cc.

References DestroyTexture(), texture_, texture_height_, and texture_width_.

Referenced by UpdateTexture().

Here is the call graph for this function:

◆ DestroyTexture()

void yaze::editor::MesenScreenshotPanel::DestroyTexture ( )
private

Definition at line 300 of file mesen_screenshot_panel.cc.

References texture_, texture_height_, and texture_width_.

Referenced by EnsureTexture(), and ~MesenScreenshotPanel().

◆ DecodeBase64()

std::vector< uint8_t > yaze::editor::MesenScreenshotPanel::DecodeBase64 ( const std::string & encoded)
staticprivate

Definition at line 51 of file mesen_screenshot_panel.cc.

Referenced by CaptureScreenshot().

◆ DecodePngToRgba()

bool yaze::editor::MesenScreenshotPanel::DecodePngToRgba ( const std::vector< uint8_t > & png_data,
std::vector< uint8_t > & rgba_out,
int & width_out,
int & height_out )
staticprivate

Definition at line 98 of file mesen_screenshot_panel.cc.

Referenced by CaptureScreenshot().

Member Data Documentation

◆ client_

std::shared_ptr<emu::mesen::MesenSocketClient> yaze::editor::MesenScreenshotPanel::client_
private

◆ texture_

SDL_Texture* yaze::editor::MesenScreenshotPanel::texture_ = nullptr
private

◆ texture_width_

int yaze::editor::MesenScreenshotPanel::texture_width_ = 0
private

Definition at line 61 of file mesen_screenshot_panel.h.

Referenced by DestroyTexture(), and EnsureTexture().

◆ texture_height_

int yaze::editor::MesenScreenshotPanel::texture_height_ = 0
private

Definition at line 62 of file mesen_screenshot_panel.h.

Referenced by DestroyTexture(), and EnsureTexture().

◆ frame_width_

int yaze::editor::MesenScreenshotPanel::frame_width_ = 0
private

Definition at line 65 of file mesen_screenshot_panel.h.

Referenced by CaptureScreenshot(), and DrawPreviewArea().

◆ frame_height_

int yaze::editor::MesenScreenshotPanel::frame_height_ = 0
private

Definition at line 66 of file mesen_screenshot_panel.h.

Referenced by CaptureScreenshot(), and DrawPreviewArea().

◆ frame_counter_

uint64_t yaze::editor::MesenScreenshotPanel::frame_counter_ = 0
private

Definition at line 67 of file mesen_screenshot_panel.h.

Referenced by CaptureScreenshot(), and DrawPreviewArea().

◆ last_capture_latency_ms_

float yaze::editor::MesenScreenshotPanel::last_capture_latency_ms_ = 0.0f
private

Definition at line 68 of file mesen_screenshot_panel.h.

Referenced by CaptureScreenshot(), and DrawPreviewArea().

◆ frame_stale_

bool yaze::editor::MesenScreenshotPanel::frame_stale_ = false
private

Definition at line 69 of file mesen_screenshot_panel.h.

Referenced by CaptureScreenshot(), and DrawPreviewArea().

◆ streaming_

bool yaze::editor::MesenScreenshotPanel::streaming_ = false
private

Definition at line 72 of file mesen_screenshot_panel.h.

Referenced by Disconnect(), Draw(), DrawControlsToolbar(), and DrawStatusBar().

◆ target_fps_

float yaze::editor::MesenScreenshotPanel::target_fps_ = 10.0f
private

Definition at line 73 of file mesen_screenshot_panel.h.

Referenced by Draw(), DrawControlsToolbar(), and DrawStatusBar().

◆ time_accumulator_

float yaze::editor::MesenScreenshotPanel::time_accumulator_ = 0.0f
private

Definition at line 74 of file mesen_screenshot_panel.h.

Referenced by Draw(), and DrawControlsToolbar().

◆ connection_error_

std::string yaze::editor::MesenScreenshotPanel::connection_error_
private

Definition at line 77 of file mesen_screenshot_panel.h.

Referenced by Connect(), ConnectToPath(), and DrawConnectionHeader().

◆ socket_paths_

std::vector<std::string> yaze::editor::MesenScreenshotPanel::socket_paths_
private

◆ selected_socket_index_

int yaze::editor::MesenScreenshotPanel::selected_socket_index_ = -1
private

◆ socket_path_buffer_

char yaze::editor::MesenScreenshotPanel::socket_path_buffer_[256] = {}
private

◆ status_message_

std::string yaze::editor::MesenScreenshotPanel::status_message_
private

Definition at line 81 of file mesen_screenshot_panel.h.

Referenced by CaptureScreenshot(), and DrawStatusBar().


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