mirror of
https://github.com/mupen64plus/mupen64plus-core.git
synced 2025-04-02 10:21:45 -04:00
video extension API version is increased to v3.0. This adds a new Flags parameter to the VidExtSetVideoMode() function, and adds a new function VidExt_ResizeWindow. This is to support resizable output windows
This commit is contained in:
parent
f3b891f97c
commit
a557d213fd
9 changed files with 118 additions and 14 deletions
|
@ -294,7 +294,7 @@ These core parameters may be read and/or written using the M64CMD_CORE_STATE_QUE
|
|||
|The Mupen64Plus library must already be initialized before calling this function. This function cannot be called while the emulator is running.
|
||||
|-
|
||||
|Usage
|
||||
|This function overrides the core's internal SDL-based OpenGL functions which are called from the video plugin to perform various basic tasks like opening the video window, toggling between windowed and fullscreen modes, and swapping frame buffers after a frame has been rendered. This override functionality allows a front-end to define its own video extension functions to be used instead of the SDL functions, such as for the purpose of embedding the emulator display window inside of a Qt GUI window. If any of the function pointers in the structure are NULL, the override function will be disabled and the core's internal SDL functions will be used. The v2.0 core expects the <tt>Functions</tt> struct member to be equal to 9 or more.
|
||||
|This function overrides the core's internal SDL-based OpenGL functions which are called from the video plugin to perform various basic tasks like opening the video window, toggling between windowed and fullscreen modes, and swapping frame buffers after a frame has been rendered. This override functionality allows a front-end to define its own video extension functions to be used instead of the SDL functions, such as for the purpose of embedding the emulator display window inside of a Qt GUI window. If any of the function pointers in the structure are NULL, the override function will be disabled and the core's internal SDL functions will be used. The core library with a Video Extension API v3.0 expects the <tt>Functions</tt> struct member to be equal to 11 or more.
|
||||
|}
|
||||
<br />
|
||||
|
||||
|
|
|
@ -51,13 +51,14 @@ All of these functions should only be called from within the video plugin; they
|
|||
<br />
|
||||
{| border="1"
|
||||
|Prototype
|
||||
|'''<tt>m64p_error VidExt_SetVideoMode(int Width, int Height, int BitsPerPixel, m64p_video_mode ScreenMode)</tt>'''
|
||||
|'''<tt>m64p_error VidExt_SetVideoMode(int Width, int Height, int BitsPerPixel, m64p_video_mode ScreenMode, m64p_video_flags Flags)</tt>'''
|
||||
|-
|
||||
|Input Parameters
|
||||
|'''<tt>Width</tt>''' Horizontal resolution in pixels of desired video window<br />
|
||||
'''<tt>Height</tt>''' Vertical resolution in pixels of desired video window<br />
|
||||
'''<tt>BitsPerPixel</tt>''' Pixel color resolution of desired video window. This value must be 16, 24, or 32<br />
|
||||
'''<tt>ScreenMode</tt>''' Either <tt>M64VIDEO_WINDOWED</tt> or <tt>M64VIDEO_FULLSCREEN</tt>
|
||||
'''<tt>ScreenMode</tt>''' Either <tt>M64VIDEO_WINDOWED</tt> or <tt>M64VIDEO_FULLSCREEN</tt><br />
|
||||
'''<tt>Flags</tt>''' Logical-OR combination of flags which describes the video plugin's capabilities.
|
||||
|-
|
||||
|Requirements
|
||||
|The video extension must be initialized before calling this function.
|
||||
|
@ -94,6 +95,21 @@ All of these functions should only be called from within the video plugin; they
|
|||
|This function toggles between fullscreen and windowed rendering modes.
|
||||
|}
|
||||
<br />
|
||||
{| border="1"
|
||||
|Prototype
|
||||
|'''<tt>m64p_error VidExt_ResizeWindow(int Width, int Height)</tt>'''
|
||||
|-
|
||||
|Input Parameters
|
||||
|'''<tt>Width</tt>''' Horizontal resolution of resized window in pixels<br />
|
||||
'''<tt>Height</tt>''' Vertical resolution of resized window in pixels
|
||||
|-
|
||||
|Requirements
|
||||
|The video extension must be initialized before calling this function. The rendering window should already be created.
|
||||
|-
|
||||
|Usage
|
||||
|This function is called when the video plugin has resized its OpenGL output viewport in response to a ResizeVideoOutput() call, and requests that the window manager update the OpenGL rendering window size to match. If a front-end application does not support resizable windows and never sets the M64CORE_VIDEO_SIZE core variable with the M64CMD_CORE_STATE_SET command, then this function should not be called.
|
||||
|}
|
||||
<br />
|
||||
|
||||
== OpenGL Functions ==
|
||||
{| border="1"
|
||||
|
|
|
@ -94,6 +94,10 @@
|
|||
M64VIDEO_FULLSCREEN
|
||||
} m64p_video_mode;
|
||||
|
||||
typedef enum {
|
||||
M64VIDEOFLAG_SUPPORT_RESIZING = 1
|
||||
} m64p_video_flags;
|
||||
|
||||
typedef enum {
|
||||
M64CORE_EMU_STATE = 1,
|
||||
M64CORE_VIDEO_MODE,
|
||||
|
@ -311,12 +315,13 @@
|
|||
m64p_error (*VidExtFuncInit)(void);
|
||||
m64p_error (*VidExtFuncQuit)(void);
|
||||
m64p_error (*VidExtFuncListModes)(m64p_2d_size *, int *);
|
||||
m64p_error (*VidExtFuncSetMode)(int, int, int, int);
|
||||
m64p_error (*VidExtFuncSetMode)(int, int, int, int, int);
|
||||
void * (*VidExtFuncGLGetProc)(const char*);
|
||||
m64p_error (*VidExtFuncGLSetAttr)(m64p_GLattr, int);
|
||||
m64p_error (*VidExtFuncGLGetAttr)(m64p_GLattr, int *);
|
||||
m64p_error (*VidExtFuncGLSwapBuf)(void);
|
||||
m64p_error (*VidExtFuncSetCaption)(const char *);
|
||||
m64p_error (*VidExtFuncToggleFS)(void);
|
||||
m64p_error (*VidExtFuncResizeWindow)(int, int);
|
||||
} m64p_video_extension_functions;
|
||||
|
||||
|
|
|
@ -176,3 +176,13 @@ Changelog:
|
|||
- add (optional) ResizeVideoOutput function in video plugin. If this function is not present
|
||||
in video plugin, then resizing the output video window will not work.
|
||||
|
||||
- VIDEXT_API_VERSION version 3.0.0:
|
||||
- add VidExt_ResizeWindow() function in video extension. This function is called by the video
|
||||
plugin to notify the window manager (SDL if no video extension is registered by the front-end)
|
||||
that the OpenGL render window size should change.
|
||||
- add m64p_video_flags parameter to the VidExt_SetVideoMode() function. Currently the flags are
|
||||
only used to notify the window manager that resizing is supported by the video plugin, and it
|
||||
should create a resizable window if possible. This may be extended in the future to support
|
||||
other features.
|
||||
|
||||
|
||||
|
|
|
@ -65,4 +65,5 @@ VidExt_Quit;
|
|||
VidExt_SetCaption;
|
||||
VidExt_SetVideoMode;
|
||||
VidExt_ToggleFullScreen;
|
||||
VidExt_ResizeWindow;
|
||||
local: *; };
|
||||
|
|
|
@ -116,6 +116,10 @@ typedef enum {
|
|||
M64VIDEO_FULLSCREEN
|
||||
} m64p_video_mode;
|
||||
|
||||
typedef enum {
|
||||
M64VIDEOFLAG_SUPPORT_RESIZING = 1
|
||||
} m64p_video_flags;
|
||||
|
||||
typedef enum {
|
||||
M64CORE_EMU_STATE = 1,
|
||||
M64CORE_VIDEO_MODE,
|
||||
|
@ -333,13 +337,14 @@ typedef struct {
|
|||
m64p_error (*VidExtFuncInit)(void);
|
||||
m64p_error (*VidExtFuncQuit)(void);
|
||||
m64p_error (*VidExtFuncListModes)(m64p_2d_size *, int *);
|
||||
m64p_error (*VidExtFuncSetMode)(int, int, int, int);
|
||||
m64p_error (*VidExtFuncSetMode)(int, int, int, int, int);
|
||||
void * (*VidExtFuncGLGetProc)(const char*);
|
||||
m64p_error (*VidExtFuncGLSetAttr)(m64p_GLattr, int);
|
||||
m64p_error (*VidExtFuncGLGetAttr)(m64p_GLattr, int *);
|
||||
m64p_error (*VidExtFuncGLSwapBuf)(void);
|
||||
m64p_error (*VidExtFuncSetCaption)(const char *);
|
||||
m64p_error (*VidExtFuncToggleFS)(void);
|
||||
m64p_error (*VidExtFuncResizeWindow)(int, int);
|
||||
} m64p_video_extension_functions;
|
||||
|
||||
#endif /* define M64P_TYPES_H */
|
||||
|
|
|
@ -73,9 +73,18 @@ EXPORT m64p_error CALL VidExt_ListFullscreenModes(m64p_2d_size *, int *);
|
|||
* video mode. Any desired OpenGL attributes should be set before calling
|
||||
* this function.
|
||||
*/
|
||||
typedef m64p_error (*ptr_VidExt_SetVideoMode)(int, int, int, m64p_video_mode);
|
||||
typedef m64p_error (*ptr_VidExt_SetVideoMode)(int, int, int, m64p_video_mode, m64p_video_flags);
|
||||
#if defined(M64P_CORE_PROTOTYPES)
|
||||
EXPORT m64p_error CALL VidExt_SetVideoMode(int, int, int, m64p_video_mode);
|
||||
EXPORT m64p_error CALL VidExt_SetVideoMode(int, int, int, m64p_video_mode, m64p_video_flags);
|
||||
#endif
|
||||
|
||||
/* VidExt_ResizeWindow()
|
||||
*
|
||||
* This function resizes the opengl rendering window to match the given size.
|
||||
*/
|
||||
typedef m64p_error (*ptr_VidExt_ResizeWindow)(int, int);
|
||||
#if defined(M64P_CORE_PROTOTYPES)
|
||||
EXPORT m64p_error CALL VidExt_ResizeWindow(int, int);
|
||||
#endif
|
||||
|
||||
/* VidExt_SetCaption()
|
||||
|
|
|
@ -50,7 +50,7 @@ m64p_error OverrideVideoFunctions(m64p_video_extension_functions *VideoFunctionS
|
|||
/* check input data */
|
||||
if (VideoFunctionStruct == NULL)
|
||||
return M64ERR_INPUT_ASSERT;
|
||||
if (VideoFunctionStruct->Functions < 10)
|
||||
if (VideoFunctionStruct->Functions < 11)
|
||||
return M64ERR_INPUT_INVALID;
|
||||
|
||||
/* disable video extension if any of the function pointers are NULL */
|
||||
|
@ -63,10 +63,11 @@ m64p_error OverrideVideoFunctions(m64p_video_extension_functions *VideoFunctionS
|
|||
VideoFunctionStruct->VidExtFuncGLGetAttr == NULL ||
|
||||
VideoFunctionStruct->VidExtFuncGLSwapBuf == NULL ||
|
||||
VideoFunctionStruct->VidExtFuncSetCaption == NULL ||
|
||||
VideoFunctionStruct->VidExtFuncToggleFS == NULL)
|
||||
VideoFunctionStruct->VidExtFuncToggleFS == NULL ||
|
||||
VideoFunctionStruct->VidExtFuncResizeWindow == NULL)
|
||||
{
|
||||
l_ExternalVideoFuncTable.Functions = 10;
|
||||
memset(&l_ExternalVideoFuncTable.VidExtFuncInit, 0, 10 * sizeof(void *));
|
||||
l_ExternalVideoFuncTable.Functions = 11;
|
||||
memset(&l_ExternalVideoFuncTable.VidExtFuncInit, 0, 11 * sizeof(void *));
|
||||
l_VideoExtensionActive = 0;
|
||||
return M64ERR_SUCCESS;
|
||||
}
|
||||
|
@ -179,7 +180,7 @@ EXPORT m64p_error CALL VidExt_ListFullscreenModes(m64p_2d_size *SizeArray, int *
|
|||
return M64ERR_SUCCESS;
|
||||
}
|
||||
|
||||
EXPORT m64p_error CALL VidExt_SetVideoMode(int Width, int Height, int BitsPerPixel, m64p_video_mode ScreenMode)
|
||||
EXPORT m64p_error CALL VidExt_SetVideoMode(int Width, int Height, int BitsPerPixel, m64p_video_mode ScreenMode, m64p_video_flags Flags)
|
||||
{
|
||||
const SDL_VideoInfo *videoInfo;
|
||||
int videoFlags = 0;
|
||||
|
@ -187,7 +188,7 @@ EXPORT m64p_error CALL VidExt_SetVideoMode(int Width, int Height, int BitsPerPix
|
|||
/* call video extension override if necessary */
|
||||
if (l_VideoExtensionActive)
|
||||
{
|
||||
m64p_error rval = (*l_ExternalVideoFuncTable.VidExtFuncSetMode)(Width, Height, BitsPerPixel, ScreenMode);
|
||||
m64p_error rval = (*l_ExternalVideoFuncTable.VidExtFuncSetMode)(Width, Height, BitsPerPixel, ScreenMode, Flags);
|
||||
l_Fullscreen = (rval == M64ERR_SUCCESS && ScreenMode == M64VIDEO_FULLSCREEN);
|
||||
l_VideoOutputActive = (rval == M64ERR_SUCCESS);
|
||||
if (l_VideoOutputActive)
|
||||
|
@ -203,11 +204,19 @@ EXPORT m64p_error CALL VidExt_SetVideoMode(int Width, int Height, int BitsPerPix
|
|||
|
||||
/* Get SDL video flags to use */
|
||||
if (ScreenMode == M64VIDEO_WINDOWED)
|
||||
{
|
||||
videoFlags = SDL_OPENGL;
|
||||
if (Flags & M64VIDEOFLAG_SUPPORT_RESIZING)
|
||||
videoFlags |= SDL_RESIZABLE;
|
||||
}
|
||||
else if (ScreenMode == M64VIDEO_FULLSCREEN)
|
||||
{
|
||||
videoFlags = SDL_OPENGL | SDL_FULLSCREEN;
|
||||
}
|
||||
else
|
||||
{
|
||||
return M64ERR_INPUT_INVALID;
|
||||
}
|
||||
|
||||
if ((videoInfo = SDL_GetVideoInfo()) == NULL)
|
||||
{
|
||||
|
@ -241,6 +250,55 @@ EXPORT m64p_error CALL VidExt_SetVideoMode(int Width, int Height, int BitsPerPix
|
|||
return M64ERR_SUCCESS;
|
||||
}
|
||||
|
||||
EXPORT m64p_error CALL VidExt_ResizeWindow(int Width, int Height)
|
||||
{
|
||||
const SDL_VideoInfo *videoInfo;
|
||||
int videoFlags = 0;
|
||||
|
||||
/* call video extension override if necessary */
|
||||
if (l_VideoExtensionActive)
|
||||
{
|
||||
m64p_error rval = (*l_ExternalVideoFuncTable.VidExtFuncResizeWindow)(Width, Height);
|
||||
if (rval == M64ERR_SUCCESS)
|
||||
{
|
||||
StateChanged(M64CORE_VIDEO_SIZE, (Width << 16) | Height);
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
if (!l_VideoOutputActive || !SDL_WasInit(SDL_INIT_VIDEO))
|
||||
return M64ERR_NOT_INIT;
|
||||
|
||||
if (l_Fullscreen)
|
||||
{
|
||||
DebugMessage(M64MSG_ERROR, "VidExt_ResizeWindow() called in fullscreen mode.");
|
||||
return M64ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
/* Get SDL video flags to use */
|
||||
videoFlags = SDL_OPENGL | SDL_RESIZABLE;
|
||||
if ((videoInfo = SDL_GetVideoInfo()) == NULL)
|
||||
{
|
||||
DebugMessage(M64MSG_ERROR, "SDL_GetVideoInfo query failed: %s", SDL_GetError());
|
||||
return M64ERR_SYSTEM_FAIL;
|
||||
}
|
||||
if (videoInfo->hw_available)
|
||||
videoFlags |= SDL_HWSURFACE;
|
||||
else
|
||||
videoFlags |= SDL_SWSURFACE;
|
||||
|
||||
/* set the mode */
|
||||
l_pScreen = SDL_SetVideoMode(Width, Height, 0, videoFlags);
|
||||
if (l_pScreen == NULL)
|
||||
{
|
||||
DebugMessage(M64MSG_ERROR, "SDL_SetVideoMode failed: %s", SDL_GetError());
|
||||
return M64ERR_SYSTEM_FAIL;
|
||||
}
|
||||
|
||||
StateChanged(M64CORE_VIDEO_SIZE, (Width << 16) | Height);
|
||||
return M64ERR_SUCCESS;
|
||||
|
||||
}
|
||||
EXPORT m64p_error CALL VidExt_SetCaption(const char *Title)
|
||||
{
|
||||
/* call video extension override if necessary */
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#define FRONTEND_API_VERSION 0x020100
|
||||
#define CONFIG_API_VERSION 0x020200
|
||||
#define DEBUG_API_VERSION 0x020000
|
||||
#define VIDEXT_API_VERSION 0x020000
|
||||
#define VIDEXT_API_VERSION 0x030000
|
||||
|
||||
#define VERSION_PRINTF_SPLIT(x) (((x) >> 16) & 0xffff), (((x) >> 8) & 0xff), ((x) & 0xff)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue