From 94301457929749e154d9725dd0ab067bff457861 Mon Sep 17 00:00:00 2001 From: Aurumaker72 Date: Wed, 18 Dec 2024 21:12:09 +0100 Subject: [PATCH] Implement mge_get_video_size Required for capture on legacy Mupen64, as it needs a way to request the video size in a thread and wgl context-agnostic way --- src/PluginAPI.h | 1 + src/ZilmarGFX_1_3.h | 10 ++++++++++ src/ZilmarPluginAPI.cpp | 5 +++++ src/common/CommonAPIImpl_common.cpp | 13 +++++++++++++ 4 files changed, 29 insertions(+) diff --git a/src/PluginAPI.h b/src/PluginAPI.h index 896c5a29c..42045eabf 100644 --- a/src/PluginAPI.h +++ b/src/PluginAPI.h @@ -63,6 +63,7 @@ class PluginAPI void DllConfig(HWND _hParent); void GetDllInfo (PLUGIN_INFO * PluginInfo); void ReadScreen(void **_dest, long *_width, long *_height); + void GetVideoSize(int32_t* width, int32_t* height); void DllAbout(/*HWND _hParent*/); diff --git a/src/ZilmarGFX_1_3.h b/src/ZilmarGFX_1_3.h index 12ca9febc..030c08d30 100644 --- a/src/ZilmarGFX_1_3.h +++ b/src/ZilmarGFX_1_3.h @@ -20,6 +20,7 @@ the plugin #define _GFX_H_INCLUDED__ #if defined(__cplusplus) +#include extern "C" { #endif @@ -285,6 +286,15 @@ EXPORT void CALL ReadScreen (void **dest, long *width, long *height); ******************************************************************/ EXPORT void CALL DllCrtFree(void* addr); +/****************************************************************** + Function: mge_get_video_size + Purpose: Gets the current video size. + Input: width - Pointer receiving the video width. Can be null. + height - Pointer receiving the video height. Can be null. + Output: none + ******************************************************************/ +EXPORT void CALL mge_get_video_size(int32_t* width, int32_t* height); + #if defined(__cplusplus) } #endif diff --git a/src/ZilmarPluginAPI.cpp b/src/ZilmarPluginAPI.cpp index f79aa1a68..7ae19f775 100644 --- a/src/ZilmarPluginAPI.cpp +++ b/src/ZilmarPluginAPI.cpp @@ -60,4 +60,9 @@ EXPORT void CALL DllCrtFree(void* addr) free(addr); } +void CALL mge_get_video_size(int32_t* width, int32_t* height) +{ + api().GetVideoSize(width, height); +} + } diff --git a/src/common/CommonAPIImpl_common.cpp b/src/common/CommonAPIImpl_common.cpp index 8e4f6728b..11ceec6af 100644 --- a/src/common/CommonAPIImpl_common.cpp +++ b/src/common/CommonAPIImpl_common.cpp @@ -312,4 +312,17 @@ void PluginAPI::ReadScreen(void **_dest, long *_width, long *_height) dwnd().readScreen(_dest, _width, _height); #endif } + +void PluginAPI::GetVideoSize(int32_t* width, int32_t* height) +{ + if (width) + { + *width = dwnd().getWidth(); + } + if (height) + { + *height = dwnd().getHeight(); + } +} + #endif