engine: platform: refactor R_GetWindowHandle to return a struct instead of a pointer

This commit is contained in:
TheEVolk
2025-05-22 10:19:49 +03:00
committed by Alibek Omarov
parent dd52840a97
commit 9ebeb520fa
6 changed files with 33 additions and 20 deletions

View File

@@ -543,9 +543,12 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint *
return true;
}
window_handle_t *R_GetWindowHandle( void )
window_handle_t R_GetWindowHandle( void )
{
return NULL;
window_handle_t handle;
handle.type = REF_WINDOW_TYPE_NONE;
handle.handle = NULL;
return handle;
}
#endif

View File

@@ -246,9 +246,12 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint *
return true;
}
window_handle_t *R_GetWindowHandle( void )
window_handle_t R_GetWindowHandle( void )
{
return NULL;
window_handle_t handle;
handle.type = REF_WINDOW_TYPE_NONE;
handle.handle = NULL;
return handle;
}
#endif

View File

@@ -314,6 +314,7 @@ typedef enum
enum
{
REF_WINDOW_TYPE_NONE = 0, // NULL
REF_WINDOW_TYPE_WIN32 = 1, // HWND
REF_WINDOW_TYPE_X11 = 2, // Display*
REF_WINDOW_TYPE_WAYLAND = 3, // wl_display*
@@ -344,7 +345,7 @@ void *SW_LockBuffer( void );
void SW_UnlockBuffer( void );
qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint *r, uint *g, uint *b );
void Platform_Minimize_f( void );
window_handle_t *R_GetWindowHandle( void );
window_handle_t R_GetWindowHandle( void );
//
// in_evdev.c

View File

@@ -513,9 +513,12 @@ qboolean VID_SetMode( void )
return true;
}
window_handle_t *R_GetWindowHandle( void )
window_handle_t R_GetWindowHandle( void )
{
return NULL;
window_handle_t handle;
handle.type = REF_WINDOW_TYPE_NONE;
handle.handle = NULL;
return handle;
}
/*

View File

@@ -1165,30 +1165,33 @@ qboolean VID_SetMode( void )
return true;
}
window_handle_t *R_GetWindowHandle( void )
window_handle_t R_GetWindowHandle( void )
{
window_handle_t handle;
handle.type = REF_WINDOW_TYPE_NONE;
handle.handle = NULL;
SDL_SysWMinfo wmInfo;
SDL_VERSION(&wmInfo.version);
if (SDL_GetWindowWMInfo(host.hWnd, &wmInfo) != SDL_TRUE) {
return NULL;
return handle;
}
window_handle_t *handle = malloc( sizeof( window_handle_t ) );
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
handle->type = REF_WINDOW_TYPE_WIN32;
handle->handle = (void*)wmInfo.info.win.window; // HWND
handle.type = REF_WINDOW_TYPE_WIN32;
handle.handle = (void*)wmInfo.info.win.window; // HWND
#elif defined(SDL_VIDEO_DRIVER_COCOA)
handle->type = REF_WINDOW_TYPE_MACOS;
handle->handle = (void*)wmInfo.info.cocoa.window; // NSWindow*
handle.type = REF_WINDOW_TYPE_MACOS;
handle.handle = (void*)wmInfo.info.cocoa.window; // NSWindow*
#elif defined(SDL_VIDEO_DRIVER_X11)
handle->type = REF_WINDOW_TYPE_X11;
handle->handle = (void*)(uintptr_t)wmInfo.info.x11.window; // X11 Window
handle.type = REF_WINDOW_TYPE_X11;
handle.handle = (void*)(uintptr_t)wmInfo.info.x11.window; // X11 Window
#elif defined(SDL_VIDEO_DRIVER_WAYLAND)
handle->type = REF_WINDOW_TYPE_WAYLAND;
handle->handle = (void*)wmInfo.info.wl.surface; // wl_surface*
handle.type = REF_WINDOW_TYPE_WAYLAND;
handle.handle = (void*)wmInfo.info.wl.surface; // wl_surface*
#else
return NULL;
return handle;
#endif
return handle;

View File

@@ -470,7 +470,7 @@ typedef struct ref_api_s
fs_api_t *fsapi;
// for abstracting the engine's rendering
struct window_handle_t *(*R_GetWindowHandle)( void );
struct window_handle_t (*R_GetWindowHandle)( void );
} ref_api_t;
struct mip_s;