mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 03:24:56 +08:00
engine: small refactorings in sdl2 support, enable messagebox and timer in sdl3 backend back
This commit is contained in:
@@ -56,7 +56,7 @@ SETUP BACKENDS DEFINITIONS
|
||||
// select messagebox implementation
|
||||
//
|
||||
#ifndef XASH_MESSAGEBOX
|
||||
#if XASH_SDL == 2 && !XASH_NSWITCH // SDL2 messageboxes are not available on NSW
|
||||
#if XASH_SDL >= 2 && !XASH_NSWITCH // SDL2 messageboxes are not available on NSW
|
||||
#define XASH_MESSAGEBOX MSGBOX_SDL
|
||||
#elif XASH_WIN32
|
||||
#define XASH_MESSAGEBOX MSGBOX_WIN32
|
||||
@@ -73,7 +73,7 @@ SETUP BACKENDS DEFINITIONS
|
||||
// no timer - no xash
|
||||
//
|
||||
#ifndef XASH_TIMER
|
||||
#if XASH_SDL == 2
|
||||
#if XASH_SDL >= 2
|
||||
#define XASH_TIMER TIMER_SDL
|
||||
#elif XASH_WIN32
|
||||
#define XASH_TIMER TIMER_WIN32
|
||||
|
||||
@@ -1,7 +1,22 @@
|
||||
#pragma once
|
||||
/*
|
||||
vid_common.h - common implementation of platform-specific vid component
|
||||
Copyright (C) 2025 Xash3D FWGS contributors
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
#ifndef VID_COMMON
|
||||
#define VID_COMMON
|
||||
|
||||
#include "ref_api.h"
|
||||
|
||||
typedef struct vidmode_s
|
||||
{
|
||||
const char *desc;
|
||||
@@ -12,8 +27,7 @@ typedef struct vidmode_s
|
||||
typedef struct
|
||||
{
|
||||
void *context; // handle to GL rendering context
|
||||
int safe;
|
||||
int desktopBitsPixel;
|
||||
ref_safegl_context_t safe;
|
||||
qboolean software;
|
||||
} glwstate_t;
|
||||
|
||||
|
||||
@@ -22,9 +22,6 @@ GNU General Public License for more details.
|
||||
|
||||
// window management
|
||||
void VID_RestoreScreenResolution( window_mode_t window_mode );
|
||||
qboolean VID_CreateWindow( int width, int height, window_mode_t window_mode );
|
||||
void VID_DestroyWindow( void );
|
||||
void GL_InitExtensions( void );
|
||||
void VID_SaveWindowSize( int width, int height );
|
||||
|
||||
//
|
||||
|
||||
@@ -15,8 +15,6 @@ GNU General Public License for more details.
|
||||
|
||||
#include "common.h"
|
||||
#include "platform.h"
|
||||
#if XASH_SOUND == SOUND_SDL
|
||||
|
||||
#include "sound.h"
|
||||
#include "voice.h"
|
||||
|
||||
@@ -344,5 +342,3 @@ void VoiceCapture_Shutdown( void )
|
||||
SDL_CloseAudioDevice( in_dev );
|
||||
in_dev = 0;
|
||||
}
|
||||
|
||||
#endif // XASH_SOUND == SOUND_SDL
|
||||
|
||||
@@ -488,7 +488,8 @@ static qboolean VID_GetDisplayBounds( int display_index, SDL_Window *hWnd, SDL_R
|
||||
|
||||
return true;
|
||||
}
|
||||
else if( SDL_GetDisplayBounds( display_index, rect ) == 0 )
|
||||
|
||||
if( SDL_GetDisplayBounds( display_index, rect ) == 0 )
|
||||
{
|
||||
rect->x += 100;
|
||||
rect->y += 100;
|
||||
@@ -566,7 +567,6 @@ static qboolean VID_SetScreenResolution( int width, int height, window_mode_t wi
|
||||
{
|
||||
int display_index = VID_GetDisplayIndex( __func__, NULL );
|
||||
SDL_Rect bounds;
|
||||
int xpos, ypos;
|
||||
|
||||
if( VID_GetDisplayBounds( display_index, host.hWnd, &bounds ))
|
||||
{
|
||||
@@ -721,7 +721,7 @@ static qboolean RectFitsInDisplay( const SDL_Rect *rect, const SDL_Rect *display
|
||||
VID_CreateWindow
|
||||
=================
|
||||
*/
|
||||
qboolean VID_CreateWindow( int input_width, int input_height, window_mode_t window_mode )
|
||||
static qboolean VID_CreateWindow( const int input_width, const int input_height, window_mode_t window_mode )
|
||||
{
|
||||
Uint32 flags = SDL_WINDOW_SHOWN | SDL_WINDOW_MOUSE_FOCUS;
|
||||
SDL_Rect rect = { window_xpos.value, window_ypos.value, input_width, input_height };
|
||||
@@ -1001,7 +1001,6 @@ R_Init_Video
|
||||
qboolean R_Init_Video( const int type )
|
||||
{
|
||||
string safe;
|
||||
qboolean retval;
|
||||
SDL_DisplayMode displayMode;
|
||||
const SDL_Point point = { window_xpos.value, window_ypos.value };
|
||||
|
||||
@@ -1048,10 +1047,8 @@ qboolean R_Init_Video( const int type )
|
||||
break;
|
||||
}
|
||||
|
||||
if( !(retval = VID_SetMode()) )
|
||||
{
|
||||
return retval;
|
||||
}
|
||||
if( !VID_SetMode( ))
|
||||
return false;
|
||||
|
||||
switch( type )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user