mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-09-01 00:32:20 +00:00
engine: platform: allow querying window type through R_GetWindowHandle
This commit is contained in:
parent
735f4e2bcb
commit
694472f4c1
@ -543,9 +543,9 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint *
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
qboolean R_GetWindowHandle( void **handle, int type )
|
ref_window_type_t R_GetWindowHandle( void **handle, ref_window_type_t type )
|
||||||
{
|
{
|
||||||
return FALSE;
|
return REF_WINDOW_TYPE_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -246,9 +246,9 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint *
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
qboolean R_GetWindowHandle( void **handle, int type )
|
ref_window_type_t R_GetWindowHandle( void **handle, ref_window_type_t type )
|
||||||
{
|
{
|
||||||
return FALSE;
|
return REF_WINDOW_TYPE_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -314,6 +314,8 @@ typedef enum
|
|||||||
|
|
||||||
struct vidmode_s;
|
struct vidmode_s;
|
||||||
typedef enum window_mode_e window_mode_t;
|
typedef enum window_mode_e window_mode_t;
|
||||||
|
typedef enum ref_window_type_e ref_window_type_t;
|
||||||
|
|
||||||
// Window
|
// Window
|
||||||
qboolean R_Init_Video( const int type );
|
qboolean R_Init_Video( const int type );
|
||||||
void R_Free_Video( void );
|
void R_Free_Video( void );
|
||||||
@ -330,7 +332,7 @@ void *SW_LockBuffer( void );
|
|||||||
void SW_UnlockBuffer( void );
|
void SW_UnlockBuffer( void );
|
||||||
qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint *r, uint *g, uint *b );
|
qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint *r, uint *g, uint *b );
|
||||||
void Platform_Minimize_f( void );
|
void Platform_Minimize_f( void );
|
||||||
qboolean R_GetWindowHandle( void **handle, int type );
|
ref_window_type_t R_GetWindowHandle( void **handle, ref_window_type_t type );
|
||||||
|
|
||||||
//
|
//
|
||||||
// in_evdev.c
|
// in_evdev.c
|
||||||
|
@ -513,9 +513,9 @@ qboolean VID_SetMode( void )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
qboolean R_GetWindowHandle( void **handle, int type )
|
ref_window_type_t R_GetWindowHandle( void **handle, ref_window_type_t type )
|
||||||
{
|
{
|
||||||
return FALSE;
|
return REF_WINDOW_TYPE_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -19,6 +19,9 @@ GNU General Public License for more details.
|
|||||||
#include "vid_common.h"
|
#include "vid_common.h"
|
||||||
#include "platform_sdl2.h"
|
#include "platform_sdl2.h"
|
||||||
|
|
||||||
|
// include it after because it breaks definitions in net_api.h wtf
|
||||||
|
#include <SDL_syswm.h>
|
||||||
|
|
||||||
static vidmode_t *vidmodes = NULL;
|
static vidmode_t *vidmodes = NULL;
|
||||||
static int num_vidmodes = 0;
|
static int num_vidmodes = 0;
|
||||||
static void GL_SetupAttributes( void );
|
static void GL_SetupAttributes( void );
|
||||||
@ -367,14 +370,13 @@ static void WIN_SetDPIAwareness( void )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <SDL_syswm.h>
|
|
||||||
static qboolean WIN_SetWindowIcon( HICON ico )
|
static qboolean WIN_SetWindowIcon( HICON ico )
|
||||||
{
|
{
|
||||||
SDL_SysWMinfo wminfo;
|
SDL_SysWMinfo wminfo;
|
||||||
|
|
||||||
SDL_VERSION( &wminfo.version );
|
SDL_VERSION( &wminfo.version );
|
||||||
|
|
||||||
if( SDL_GetWindowWMInfo( host.hWnd, &wminfo ) == SDL_TRUE )
|
if( SDL_GetWindowWMInfo( host.hWnd, &wminfo ) == SDL_TRUE && wminfo.subsystem == SDL_SYSWM_WINDOWS )
|
||||||
{
|
{
|
||||||
SendMessage( wminfo.info.win.window, WM_SETICON, ICON_SMALL, (LONG_PTR)ico );
|
SendMessage( wminfo.info.win.window, WM_SETICON, ICON_SMALL, (LONG_PTR)ico );
|
||||||
SendMessage( wminfo.info.win.window, WM_SETICON, ICON_BIG, (LONG_PTR)ico );
|
SendMessage( wminfo.info.win.window, WM_SETICON, ICON_BIG, (LONG_PTR)ico );
|
||||||
@ -1165,52 +1167,67 @@ qboolean VID_SetMode( void )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
qboolean R_GetWindowHandle( void **handle, int type )
|
ref_window_type_t R_GetWindowHandle( void **handle, ref_window_type_t type )
|
||||||
{
|
{
|
||||||
SDL_SysWMinfo wmInfo;
|
SDL_SysWMinfo wmInfo;
|
||||||
|
|
||||||
|
if( type == REF_WINDOW_TYPE_SDL )
|
||||||
|
{
|
||||||
|
if( handle )
|
||||||
|
*handle = (void *)host.hWnd;
|
||||||
|
return REF_WINDOW_TYPE_SDL;
|
||||||
|
}
|
||||||
|
|
||||||
SDL_VERSION( &wmInfo.version );
|
SDL_VERSION( &wmInfo.version );
|
||||||
|
|
||||||
if ( SDL_GetWindowWMInfo( host.hWnd, &wmInfo ) != SDL_TRUE )
|
if( SDL_GetWindowWMInfo( host.hWnd, &wmInfo ))
|
||||||
{
|
return REF_WINDOW_TYPE_NULL;
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch( type )
|
switch( wmInfo.subsystem )
|
||||||
{
|
{
|
||||||
case REF_WINDOW_TYPE_WIN32:
|
case SDL_SYSWM_WINDOWS:
|
||||||
|
if( !type || type == REF_WINDOW_TYPE_WIN32 )
|
||||||
|
{
|
||||||
#ifdef SDL_VIDEO_DRIVER_WINDOWS
|
#ifdef SDL_VIDEO_DRIVER_WINDOWS
|
||||||
*handle = (void*)wmInfo.info.win.window; // HWND
|
if( handle )
|
||||||
return TRUE;
|
*handle = (void *)wmInfo.info.win.window;
|
||||||
#else
|
return REF_WINDOW_TYPE_WIN32;
|
||||||
return FALSE;
|
#endif // SDL_VIDEO_DRIVER_WINDOWS
|
||||||
#endif
|
}
|
||||||
case REF_WINDOW_TYPE_MACOS:
|
break;
|
||||||
#ifdef SDL_VIDEO_DRIVER_COCOA
|
case SDL_SYSWM_X11:
|
||||||
*handle = (void*)wmInfo.info.cocoa.window; // NSWindow*
|
if( !type || type == REF_WINDOW_TYPE_X11 )
|
||||||
return TRUE;
|
{
|
||||||
#else
|
|
||||||
return FALSE;
|
|
||||||
#endif
|
|
||||||
case REF_WINDOW_TYPE_X11:
|
|
||||||
#ifdef SDL_VIDEO_DRIVER_X11
|
#ifdef SDL_VIDEO_DRIVER_X11
|
||||||
*handle = (void*)(uintptr_t)wmInfo.info.x11.window; // X11 Window
|
if( handle )
|
||||||
return TRUE;
|
*handle = (void *)(uintptr_t)wmInfo.info.x11.window;
|
||||||
#else
|
return REF_WINDOW_TYPE_X11;
|
||||||
return FALSE;
|
#endif // SDL_VIDEO_DRIVER_X11
|
||||||
#endif
|
}
|
||||||
case REF_WINDOW_TYPE_WAYLAND:
|
break;
|
||||||
|
case SDL_SYSWM_COCOA:
|
||||||
|
if( !type || type == REF_WINDOW_TYPE_MACOS )
|
||||||
|
{
|
||||||
|
#ifdef SDL_VIDEO_DRIVER_COCOA
|
||||||
|
if( handle )
|
||||||
|
*handle = (void *)wmInfo.info.cocoa.window;
|
||||||
|
return REF_WINDOW_TYPE_MACOS;
|
||||||
|
#endif // SDL_VIDEO_DRIVER_COCOA
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SDL_SYSWM_WAYLAND:
|
||||||
|
if( !type || type == REF_WINDOW_TYPE_WAYLAND )
|
||||||
|
{
|
||||||
#ifdef SDL_VIDEO_DRIVER_WAYLAND
|
#ifdef SDL_VIDEO_DRIVER_WAYLAND
|
||||||
*handle = (void*)wmInfo.info.wl.surface; // wl_surface*
|
if( handle )
|
||||||
return TRUE;
|
*handle = (void *)wmInfo.info.wl.surface;
|
||||||
#else
|
return REF_WINDOW_TYPE_WAYLAND;
|
||||||
return FALSE;
|
#endif // SDL_VIDEO_DRIVER_WAYLAND
|
||||||
#endif
|
}
|
||||||
case REF_WINDOW_TYPE_SDL:
|
break;
|
||||||
*handle = (void*)host.hWnd; // SDL_Window*
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return REF_WINDOW_TYPE_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -57,8 +57,8 @@ GNU General Public License for more details.
|
|||||||
// CL_RunLightStyles now accepts lightstyles array.
|
// CL_RunLightStyles now accepts lightstyles array.
|
||||||
// Removed R_DrawTileClear and Mod_LoadMapSprite, as they're implemented on engine side
|
// Removed R_DrawTileClear and Mod_LoadMapSprite, as they're implemented on engine side
|
||||||
// Removed FillRGBABlend. Now FillRGBA accepts rendermode parameter.
|
// Removed FillRGBABlend. Now FillRGBA accepts rendermode parameter.
|
||||||
// 10. Added R_GetWindowHandle.
|
// 10. Added R_GetWindowHandle to retrieve platform-specific window object.
|
||||||
#define REF_API_VERSION 9
|
#define REF_API_VERSION 10
|
||||||
|
|
||||||
#define TF_SKY (TF_SKYSIDE|TF_NOMIPMAP|TF_ALLOW_NEAREST)
|
#define TF_SKY (TF_SKYSIDE|TF_NOMIPMAP|TF_ALLOW_NEAREST)
|
||||||
#define TF_FONT (TF_NOMIPMAP|TF_CLAMP|TF_ALLOW_NEAREST)
|
#define TF_FONT (TF_NOMIPMAP|TF_CLAMP|TF_ALLOW_NEAREST)
|
||||||
@ -104,14 +104,15 @@ typedef enum
|
|||||||
DEMO_QUAKE1
|
DEMO_QUAKE1
|
||||||
} demo_mode;
|
} demo_mode;
|
||||||
|
|
||||||
enum
|
typedef enum ref_window_type_e
|
||||||
{
|
{
|
||||||
REF_WINDOW_TYPE_WIN32 = 1, // HWND
|
REF_WINDOW_TYPE_NULL = 0,
|
||||||
REF_WINDOW_TYPE_X11 = 2, // Display*
|
REF_WINDOW_TYPE_WIN32, // HWND
|
||||||
REF_WINDOW_TYPE_WAYLAND = 3, // wl_display*
|
REF_WINDOW_TYPE_X11, // Display*
|
||||||
REF_WINDOW_TYPE_MACOS = 4, // NSWindow*
|
REF_WINDOW_TYPE_WAYLAND, // wl_display*
|
||||||
REF_WINDOW_TYPE_SDL = 5, // SDL_Window*
|
REF_WINDOW_TYPE_MACOS, // NSWindow*
|
||||||
};
|
REF_WINDOW_TYPE_SDL, // SDL_Window*
|
||||||
|
} ref_window_type_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@ -479,7 +480,7 @@ typedef struct ref_api_s
|
|||||||
fs_api_t *fsapi;
|
fs_api_t *fsapi;
|
||||||
|
|
||||||
// for abstracting the engine's rendering
|
// for abstracting the engine's rendering
|
||||||
qboolean (*R_GetWindowHandle)( void **handle, int type );
|
ref_window_type_t (*R_GetWindowHandle)( void **handle, ref_window_type_t type );
|
||||||
} ref_api_t;
|
} ref_api_t;
|
||||||
|
|
||||||
struct mip_s;
|
struct mip_s;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user