From 7fda58561f6a0c249f7ffb5ab3ff739dbf67b1be Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 5 May 2025 05:56:23 +0300 Subject: [PATCH] engine: platform: sdl2: remove SDL1.2 code, as it's now moved into it's own separate directory --- engine/platform/platform.h | 4 - engine/platform/sdl2/host_sdl2.c | 108 ------------------------ engine/platform/sdl2/in_sdl2.c | 32 ------- engine/platform/sdl2/joy_sdl2.c | 17 ---- engine/platform/sdl2/s_sdl2.c | 18 ---- engine/platform/sdl2/vid_sdl2.c | 139 ++----------------------------- 6 files changed, 8 insertions(+), 310 deletions(-) diff --git a/engine/platform/platform.h b/engine/platform/platform.h index 2e5eedcf..f2a4bfd5 100644 --- a/engine/platform/platform.h +++ b/engine/platform/platform.h @@ -261,10 +261,6 @@ void Platform_SetClipboardText( const char *buffer ); #define SDL_IsTextInputActive() host.textmode #endif -#if !XASH_SDL -#define SDL_VERSION_ATLEAST( x, y, z ) 0 -#endif - static inline void Platform_SetTimer( float time ) { #if XASH_LINUX diff --git a/engine/platform/sdl2/host_sdl2.c b/engine/platform/sdl2/host_sdl2.c index 8ec11c7f..8c67fea8 100644 --- a/engine/platform/sdl2/host_sdl2.c +++ b/engine/platform/sdl2/host_sdl2.c @@ -12,7 +12,6 @@ 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. */ -#if defined( XASH_SDL ) && !XASH_DEDICATED #include #include @@ -25,71 +24,6 @@ GNU General Public License for more details. #include "sound.h" #include "vid_common.h" -#if !SDL_VERSION_ATLEAST( 2, 0, 0 ) -#define SDL_SCANCODE_A SDLK_a -#define SDL_SCANCODE_Z SDLK_z -#define SDL_SCANCODE_1 SDLK_1 -#define SDL_SCANCODE_9 SDLK_9 -#define SDL_SCANCODE_F1 SDLK_F1 -#define SDL_SCANCODE_F12 SDLK_F12 -#define SDL_SCANCODE_GRAVE SDLK_BACKQUOTE -#define SDL_SCANCODE_0 SDLK_0 -#define SDL_SCANCODE_BACKSLASH SDLK_BACKSLASH -#define SDL_SCANCODE_LEFTBRACKET SDLK_LEFTBRACKET -#define SDL_SCANCODE_RIGHTBRACKET SDLK_RIGHTBRACKET -#define SDL_SCANCODE_EQUALS SDLK_EQUALS -#define SDL_SCANCODE_MINUS SDLK_MINUS -#define SDL_SCANCODE_TAB SDLK_TAB -#define SDL_SCANCODE_RETURN SDLK_RETURN -#define SDL_SCANCODE_ESCAPE SDLK_ESCAPE -#define SDL_SCANCODE_SPACE SDLK_SPACE -#define SDL_SCANCODE_BACKSPACE SDLK_BACKSPACE -#define SDL_SCANCODE_UP SDLK_UP -#define SDL_SCANCODE_LEFT SDLK_LEFT -#define SDL_SCANCODE_DOWN SDLK_DOWN -#define SDL_SCANCODE_RIGHT SDLK_RIGHT -#define SDL_SCANCODE_LALT SDLK_LALT -#define SDL_SCANCODE_RALT SDLK_RALT -#define SDL_SCANCODE_LCTRL SDLK_LCTRL -#define SDL_SCANCODE_RCTRL SDLK_RCTRL -#define SDL_SCANCODE_LSHIFT SDLK_LSHIFT -#define SDL_SCANCODE_RSHIFT SDLK_RSHIFT -#define SDL_SCANCODE_LGUI SDLK_LMETA -#define SDL_SCANCODE_RGUI SDLK_RMETA -#define SDL_SCANCODE_INSERT SDLK_INSERT -#define SDL_SCANCODE_DELETE SDLK_DELETE -#define SDL_SCANCODE_PAGEDOWN SDLK_PAGEDOWN -#define SDL_SCANCODE_PAGEUP SDLK_PAGEUP -#define SDL_SCANCODE_HOME SDLK_HOME -#define SDL_SCANCODE_END SDLK_END -#define SDL_SCANCODE_KP_1 SDLK_KP1 -#define SDL_SCANCODE_KP_2 SDLK_KP2 -#define SDL_SCANCODE_KP_3 SDLK_KP3 -#define SDL_SCANCODE_KP_4 SDLK_KP4 -#define SDL_SCANCODE_KP_5 SDLK_KP5 -#define SDL_SCANCODE_KP_6 SDLK_KP6 -#define SDL_SCANCODE_KP_7 SDLK_KP7 -#define SDL_SCANCODE_KP_8 SDLK_KP8 -#define SDL_SCANCODE_KP_9 SDLK_KP9 -#define SDL_SCANCODE_KP_0 SDLK_KP0 -#define SDL_SCANCODE_KP_PERIOD SDLK_KP_PERIOD -#define SDL_SCANCODE_KP_ENTER SDLK_KP_ENTER -#define SDL_SCANCODE_KP_PLUS SDLK_KP_PLUS -#define SDL_SCANCODE_KP_MINUS SDLK_KP_MINUS -#define SDL_SCANCODE_KP_DIVIDE SDLK_KP_DIVIDE -#define SDL_SCANCODE_KP_MULTIPLY SDLK_KP_MULTIPLY -#define SDL_SCANCODE_NUMLOCKCLEAR SDLK_NUMLOCK -#define SDL_SCANCODE_CAPSLOCK SDLK_CAPSLOCK -#define SDL_SCANCODE_SLASH SDLK_SLASH -#define SDL_SCANCODE_PERIOD SDLK_PERIOD -#define SDL_SCANCODE_SEMICOLON SDLK_SEMICOLON -#define SDL_SCANCODE_APOSTROPHE SDLK_QUOTE -#define SDL_SCANCODE_COMMA SDLK_COMMA -#define SDL_SCANCODE_PRINTSCREEN SDLK_PRINT -#define SDL_SCANCODE_UNKNOWN SDLK_UNKNOWN -#define SDL_GetScancodeName( x ) "unknown" -#endif - /* ============= SDLash_KeyEvent @@ -99,11 +33,7 @@ SDLash_KeyEvent static void SDLash_KeyEvent( SDL_KeyboardEvent key ) { int down = key.state != SDL_RELEASED; -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) int keynum = key.keysym.scancode; -#else - int keynum = key.keysym.sym; -#endif #if XASH_ANDROID if( keynum == SDL_SCANCODE_VOLUMEUP || keynum == SDL_SCANCODE_VOLUMEDOWN ) @@ -126,24 +56,11 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) return; } -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) // ignore printable keys, they are coming through SDL_TEXTINPUT if(( keynum >= SDL_SCANCODE_A && keynum <= SDL_SCANCODE_Z ) || ( keynum >= SDL_SCANCODE_1 && keynum <= SDL_SCANCODE_0 ) || ( keynum >= SDL_SCANCODE_KP_1 && keynum <= SDL_SCANCODE_KP_0 )) return; -#else - if( keynum >= SDLK_KP0 && keynum <= SDLK_KP9 ) - keynum -= SDLK_KP0 + '0'; - - if( isprint( keynum )) - { - if( FBitSet( SDL_GetModState(), KMOD_SHIFT )) - keynum = Key_ToUpper( keynum ); - - CL_CharEvent( keynum ); - } -#endif } #define DECLARE_KEY_RANGE( min, max, repl ) \ @@ -222,7 +139,6 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) } case SDL_SCANCODE_PAUSE: keynum = K_PAUSE; break; case SDL_SCANCODE_SCROLLLOCK: keynum = K_SCROLLLOCK; break; -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) case SDL_SCANCODE_APPLICATION: keynum = K_WIN; break; // (compose key) ??? // don't console spam on known functional buttons, not used in engine case SDL_SCANCODE_MUTE: @@ -232,7 +148,6 @@ static void SDLash_KeyEvent( SDL_KeyboardEvent key ) case SDL_SCANCODE_BRIGHTNESSUP: case SDL_SCANCODE_SELECT: return; -#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) case SDL_SCANCODE_UNKNOWN: { if( down ) Con_Reportf( "%s: Unknown scancode\n", __func__ ); @@ -259,10 +174,8 @@ static void SDLash_MouseEvent( SDL_MouseButtonEvent button ) { int down; -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) if( button.which == SDL_TOUCH_MOUSEID ) return; -#endif if( button.state == SDL_RELEASED ) down = 0; @@ -288,14 +201,6 @@ static void SDLash_MouseEvent( SDL_MouseButtonEvent button ) case SDL_BUTTON_X2: IN_MouseEvent( 4, down ); break; -#if ! SDL_VERSION_ATLEAST( 2, 0, 0 ) - case SDL_BUTTON_WHEELUP: - IN_MWheelEvent( -1 ); - break; - case SDL_BUTTON_WHEELDOWN: - IN_MWheelEvent( 1 ); - break; -#endif // ! SDL_VERSION_ATLEAST( 2, 0, 0 ) default: Con_Printf( "Unknown mouse button ID: %d\n", button.button ); } @@ -307,7 +212,6 @@ SDLash_InputEvent ============= */ -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) static void SDLash_InputEvent( SDL_TextInputEvent input ) { const char *text; @@ -328,7 +232,6 @@ static void SDLash_InputEvent( SDL_TextInputEvent input ) CL_CharEvent( ch ); } } -#endif // SDL_VERSION_AT_LEAST( 2, 0, 0 ) static void SDLash_ActiveEvent( int gain ) { @@ -394,7 +297,6 @@ static void SDLash_EventHandler( SDL_Event *event ) case SDL_QUIT: Sys_Quit( "caught SDL_QUIT" ); break; -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) case SDL_MOUSEWHEEL: IN_MWheelEvent( event->wheel.y ); break; @@ -530,14 +432,6 @@ static void SDLash_EventHandler( SDL_Event *event ) default: break; } -#else - case SDL_VIDEORESIZE: - VID_SaveWindowSize( event->resize.w, event->resize.h ); - break; - case SDL_ACTIVEEVENT: - SDLash_ActiveEvent( event->active.gain ); - break; -#endif } } @@ -575,5 +469,3 @@ void Platform_PreCreateMove( void ) SDL_ShowCursor( SDL_TRUE ); } } - -#endif // defined( XASH_SDL ) && !XASH_DEDICATED diff --git a/engine/platform/sdl2/in_sdl2.c b/engine/platform/sdl2/in_sdl2.c index e2e9564f..28e8487a 100644 --- a/engine/platform/sdl2/in_sdl2.c +++ b/engine/platform/sdl2/in_sdl2.c @@ -23,15 +23,11 @@ GNU General Public License for more details. #include "sound.h" #include "vid_common.h" -#if !SDL_VERSION_ATLEAST( 2, 0, 0 ) -#define SDL_WarpMouseInWindow( win, x, y ) SDL_WarpMouse( ( x ), ( y ) ) -#else static struct { qboolean initialized; SDL_Cursor *cursors[dc_last]; } cursors; -#endif static struct { @@ -95,7 +91,6 @@ Platform_GetClipobardText */ int Platform_GetClipboardText( char *buffer, size_t size ) { -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) int textLength; char *sdlbuffer = SDL_GetClipboardText(); @@ -111,10 +106,6 @@ int Platform_GetClipboardText( char *buffer, size_t size ) } SDL_free( sdlbuffer ); return textLength; -#else // SDL_VERSION_ATLEAST( 2, 0, 0 ) - buffer[0] = 0; -#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) - return 0; } /* @@ -125,9 +116,7 @@ Platform_SetClipobardText */ void Platform_SetClipboardText( const char *buffer ) { -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) SDL_SetClipboardText( buffer ); -#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) } #if !XASH_PSVITA @@ -140,9 +129,7 @@ SDLash_EnableTextInput */ void Platform_EnableTextInput( qboolean enable ) { -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) enable ? SDL_StartTextInput() : SDL_StopTextInput(); -#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) } #endif // !XASH_PSVITA @@ -155,7 +142,6 @@ SDLash_InitCursors */ void SDLash_InitCursors( void ) { -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) if( cursors.initialized ) SDLash_FreeCursors(); @@ -174,7 +160,6 @@ void SDLash_InitCursors( void ) cursors.cursors[dc_no] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NO); cursors.cursors[dc_hand] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND); cursors.initialized = true; -#endif } /* @@ -185,7 +170,6 @@ SDLash_FreeCursors */ void SDLash_FreeCursors( void ) { -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) int i = 0; for( ; i < ARRAYSIZE( cursors.cursors ); i++ ) @@ -196,7 +180,6 @@ void SDLash_FreeCursors( void ) } cursors.initialized = false; -#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) } /* @@ -227,7 +210,6 @@ void Platform_SetCursorType( VGUI_DefaultCursor type ) host.mouse_visible = visible; VGui_UpdateInternalCursorState( type ); -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) if( host.mouse_visible ) { if( cursors.initialized ) @@ -254,16 +236,6 @@ void Platform_SetCursorType( VGUI_DefaultCursor type ) SDL_ShowCursor( false ); } -#else - if( host.mouse_visible ) - { - SDL_ShowCursor( true ); - } - else - { - SDL_ShowCursor( false ); - } -#endif } /* @@ -274,7 +246,6 @@ Platform_GetKeyModifiers */ key_modifier_t Platform_GetKeyModifiers( void ) { -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) SDL_Keymod modFlags; key_modifier_t resultFlags; @@ -302,7 +273,4 @@ key_modifier_t Platform_GetKeyModifiers( void ) SetBits( resultFlags, KeyModifier_LeftSuper ); return resultFlags; -#else - return KeyModifier_None; -#endif } diff --git a/engine/platform/sdl2/joy_sdl2.c b/engine/platform/sdl2/joy_sdl2.c index 3bd63a46..f8fb28fd 100644 --- a/engine/platform/sdl2/joy_sdl2.c +++ b/engine/platform/sdl2/joy_sdl2.c @@ -14,7 +14,6 @@ GNU General Public License for more details. */ #include -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) #include "common.h" #include "keydefs.h" #include "input.h" @@ -385,19 +384,3 @@ void Platform_JoyShutdown( void ) SDL_QuitSubSystem( SDL_INIT_GAMECONTROLLER ); } -#else // SDL_VERSION_ATLEAST( 2, 0, 0 ) -void Platform_Vibrate( float time, char flags ) -{ - -} - -int Platform_JoyInit( void ) -{ - return 0; -} - -void Platform_JoyShutdown( void ) -{ - -} -#endif diff --git a/engine/platform/sdl2/s_sdl2.c b/engine/platform/sdl2/s_sdl2.c index f47e0eed..3041aff1 100644 --- a/engine/platform/sdl2/s_sdl2.c +++ b/engine/platform/sdl2/s_sdl2.c @@ -26,17 +26,7 @@ GNU General Public License for more details. #define SAMPLE_16BIT_SHIFT 1 #define SECONDARY_BUFFER_SIZE 0x10000 -#if ! SDL_VERSION_ATLEAST( 2, 0, 0 ) -#define SDL_GetCurrentAudioDriver() "legacysdl" -#define SDL_OpenAudioDevice( a, b, c, d, e ) SDL_OpenAudio( ( c ), ( d ) ) -#define SDL_CloseAudioDevice( a ) SDL_CloseAudio() -#define SDL_PauseAudioDevice( a, b ) SDL_PauseAudio( ( b ) ) -#define SDL_LockAudioDevice( x ) SDL_LockAudio() -#define SDL_UnlockAudioDevice( x ) SDL_UnlockAudio() -#define SDLash_IsAudioError( x ) (( x ) != 0) -#else #define SDLash_IsAudioError( x ) (( x ) == 0) -#endif /* ======================================================================= @@ -55,14 +45,6 @@ static void SDL_SoundCallback( void *userdata, Uint8 *stream, int len ) int pos; int wrapped; -#if ! SDL_VERSION_ATLEAST( 2, 0, 0 ) - if( !dma.buffer ) - { - memset( stream, 0, len ); - return; - } -#endif - pos = dma.samplepos << 1; if( pos >= size ) pos = dma.samplepos = 0; diff --git a/engine/platform/sdl2/vid_sdl2.c b/engine/platform/sdl2/vid_sdl2.c index 4b3ae841..31cc6262 100644 --- a/engine/platform/sdl2/vid_sdl2.c +++ b/engine/platform/sdl2/vid_sdl2.c @@ -12,7 +12,6 @@ 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. */ -#if !XASH_DEDICATED #include #include "common.h" #include "client.h" @@ -29,10 +28,8 @@ struct struct { -#if SDL_VERSION_ATLEAST(2, 0, 0) SDL_Renderer *renderer; SDL_Texture *tex; -#endif int width, height; SDL_Surface *surf; SDL_Surface *win; @@ -43,7 +40,6 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint * sw.width = width; sw.height = height; -#if SDL_VERSION_ATLEAST(2, 0, 0) if( sw.renderer ) { unsigned int format = SDL_GetWindowPixelFormat( host.hWnd ); @@ -111,16 +107,10 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint * sw.renderer = NULL; } } -#endif -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) if( !sw.renderer ) { sw.win = SDL_GetWindowSurface( host.hWnd ); -#else // SDL_VERSION_ATLEAST( 2, 0, 0 ) - { - sw.win = SDL_GetVideoSurface(); -#endif // sdl will create renderer if hw framebuffer unavailiable, so cannot fallback here // if it is failed, it is not possible to draw with SDL in REF_SOFTWARE mode @@ -153,7 +143,6 @@ qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint * void *SW_LockBuffer( void ) { -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) if( sw.renderer ) { void *pixels; @@ -168,22 +157,17 @@ void *SW_LockBuffer( void ) sw.win = SDL_GetWindowSurface( host.hWnd ); //if( !sw.win ) //SDL_GetWindowSurface( host.hWnd ); -#else // SDL_VERSION_ATLEAST( 2, 0, 0 ) - sw.win = SDL_GetVideoSurface(); -#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) // prevent buffer overrun if( !sw.win || sw.win->w < sw.width || sw.win->h < sw.height ) return NULL; -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) if( sw.surf ) { SDL_LockSurface( sw.surf ); return sw.surf->pixels; } else -#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) { // real window pixels (x11 shm region, dma buffer, etc) // or SDL_Renderer texture if not supported @@ -194,7 +178,6 @@ void *SW_LockBuffer( void ) void SW_UnlockBuffer( void ) { -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) if( sw.renderer ) { SDL_Rect src, dst; @@ -226,16 +209,11 @@ void SW_UnlockBuffer( void ) SDL_BlitSurface( sw.surf, &src, sw.win, &dst ); return; } -#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) // already blitted SDL_UnlockSurface( sw.win ); -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) SDL_UpdateWindowSurface( host.hWnd ); -#else // SDL_VERSION_ATLEAST( 2, 0, 0 ) - SDL_Flip( host.hWnd ); -#endif } int R_MaxVideoModes( void ) @@ -256,7 +234,6 @@ vidmode_t *R_GetVideoMode( int num ) static void R_InitVideoModes( void ) { char buf[MAX_VA_STRING]; -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) #if SDL_VERSION_ATLEAST( 2, 24, 0 ) SDL_Point point = { window_xpos.value, window_ypos.value }; int displayIndex = SDL_GetPointDisplayIndex( &point ); @@ -305,43 +282,6 @@ static void R_InitVideoModes( void ) num_vidmodes++; } -#else // SDL_VERSION_ATLEAST( 2, 0, 0 ) - SDL_Rect **modes; - int len = 0, i = 0, j; - - modes = SDL_ListModes( NULL, SDL_FULLSCREEN ); - - if( !modes || modes == (void*)-1 ) - return; - - for( len = 0; modes[len]; len++ ); - - vidmodes = Mem_Malloc( host.mempool, len * sizeof( vidmode_t ) ); - - // from smallest to largest - for( ; i < len; i++ ) - { - SDL_Rect *mode = modes[len - i - 1]; - - for( j = 0; j < num_vidmodes; j++ ) - { - if( mode->w == vidmodes[j].width && - mode->h == vidmodes[j].height ) - { - break; - } - } - if( j != num_vidmodes ) - continue; - - vidmodes[num_vidmodes].width = mode->w; - vidmodes[num_vidmodes].height = mode->h; - Q_snprintf( buf, sizeof( buf ), "%ix%i", mode->w, mode->h ); - vidmodes[num_vidmodes].desc = copystring( buf ); - - num_vidmodes++; - } -#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) } @@ -491,7 +431,6 @@ GL_UpdateSwapInterval */ void GL_UpdateSwapInterval( void ) { -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) if( FBitSet( gl_vsync.flags, FCVAR_CHANGED )) { ClearBits( gl_vsync.flags, FCVAR_CHANGED ); @@ -499,7 +438,6 @@ void GL_UpdateSwapInterval( void ) if( SDL_GL_SetSwapInterval( gl_vsync.value ) < 0 ) Con_Reportf( S_ERROR "SDL_GL_SetSwapInterval: %s\n", SDL_GetError( )); } -#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) } /* @@ -511,13 +449,11 @@ always return false */ qboolean GL_DeleteContext( void ) { -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) if( glw_state.context ) { SDL_GL_DeleteContext(glw_state.context); glw_state.context = NULL; } -#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) return false; } @@ -528,13 +464,11 @@ GL_CreateContext */ static qboolean GL_CreateContext( void ) { -#if SDL_VERSION_ATLEAST(2, 0, 0) if( ( glw_state.context = SDL_GL_CreateContext( host.hWnd ) ) == NULL) { Con_Reportf( S_ERROR "%s: %s\n", __func__, SDL_GetError( )); return GL_DeleteContext(); } -#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) return true; } @@ -545,13 +479,11 @@ GL_UpdateContext */ static qboolean GL_UpdateContext( void ) { -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) if( SDL_GL_MakeCurrent( host.hWnd, glw_state.context ) < 0 ) { Con_Reportf( S_ERROR "%s: %s\n", __func__, SDL_GetError( )); return GL_DeleteContext(); } -#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) return true; } @@ -559,12 +491,10 @@ void VID_SaveWindowSize( int width, int height, qboolean maximized ) { int render_w = width, render_h = height; -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) if( !glw_state.software ) SDL_GL_GetDrawableSize( host.hWnd, &render_w, &render_h ); else SDL_RenderSetLogicalSize( sw.renderer, width, height ); -#endif VID_SetDisplayTransform( &render_w, &render_h ); R_SaveVideoMode( width, height, render_w, render_h, maximized ); @@ -572,7 +502,6 @@ void VID_SaveWindowSize( int width, int height, qboolean maximized ) static qboolean VID_SetScreenResolution( int width, int height, window_mode_t window_mode ) { -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) SDL_DisplayMode got; Uint32 wndFlags = 0; @@ -625,9 +554,6 @@ static qboolean VID_SetScreenResolution( int width, int height, window_mode_t wi SDL_SetWindowSize( host.hWnd, got.w, got.h ); VID_SaveWindowSize( got.w, got.h, true ); -#else - VID_SaveWindowSize( width, height, true ); -#endif return true; } @@ -636,7 +562,7 @@ void VID_RestoreScreenResolution( void ) // on mobile platform fullscreen is designed to be always on // and code below minimizes our window if we're in full screen // don't do that on mobile devices -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) && !XASH_MOBILE_PLATFORM +#if !XASH_MOBILE_PLATFORM switch((window_mode_t)vid_fullscreen.value ) { case WINDOW_MODE_WINDOWED: @@ -655,10 +581,9 @@ void VID_RestoreScreenResolution( void ) SDL_SetWindowFullscreen( host.hWnd, 0 ); break; } -#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) +#endif // !XASH_MOBILE_PLATFORM } -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) static void VID_SetWindowIcon( SDL_Window *hWnd ) { rgbdata_t *icon = NULL; @@ -710,17 +635,13 @@ static void VID_SetWindowIcon( SDL_Window *hWnd ) WIN_SetWindowIcon( LoadIcon( GetModuleHandle( NULL ), MAKEINTRESOURCE( 101 ))); #endif } -#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) static qboolean VID_CreateWindowWithSafeGL( const char *wndname, int xpos, int ypos, int w, int h, uint32_t flags ) { while( glw_state.safe >= SAFE_NO && glw_state.safe < SAFE_LAST ) { -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) host.hWnd = SDL_CreateWindow( wndname, xpos, ypos, w, h, flags ); -#else - host.hWnd = sw.surf = SDL_SetVideoMode( width, height, 16, flags ); -#endif + // we have window, exit loop if( host.hWnd ) break; @@ -770,7 +691,6 @@ VID_CreateWindow qboolean VID_CreateWindow( int width, int height, window_mode_t window_mode ) { string wndname; -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) qboolean maximized = vid_maximized.value != 0.0f; Uint32 wndFlags = SDL_WINDOW_SHOWN | SDL_WINDOW_MOUSE_FOCUS; int xpos, ypos; @@ -787,7 +707,7 @@ qboolean VID_CreateWindow( int width, int height, window_mode_t window_mode ) if( window_mode == WINDOW_MODE_WINDOWED ) { SDL_Rect *display_rects = ( SDL_Rect * )malloc( num_displays * sizeof( SDL_Rect )); - + SetBits( wndFlags, SDL_WINDOW_RESIZABLE ); if( maximized ) SetBits( wndFlags, SDL_WINDOW_MAXIMIZED ); @@ -899,21 +819,6 @@ qboolean VID_CreateWindow( int width, int height, window_mode_t window_mode ) return false; } -#else // SDL_VERSION_ATLEAST( 2, 0, 0 ) - Uint32 flags = 0; - - Q_strncpy( wndname, GI->title, sizeof( wndname )); - - if( window_mode != WINDOW_MODE_WINDOWED ) - SetBits( flags, SDL_FULLSCREEN|SDL_HWSURFACE ); - - if( !glw_state.software ) - SetBits( flags, SDL_OPENGL ); - - if( !VID_CreateWindowWithSafeGL( wndname, xpos, ypos, width, height, wndFlags )) - return false; -#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) - VID_SaveWindowSize( width, height, maximized ); return true; @@ -931,9 +836,7 @@ void VID_DestroyWindow( void ) VID_RestoreScreenResolution(); if( host.hWnd ) { -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) SDL_DestroyWindow ( host.hWnd ); -#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) host.hWnd = NULL; } @@ -950,20 +853,14 @@ GL_SetupAttributes */ static void GL_SetupAttributes( void ) { -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) SDL_GL_ResetAttributes(); -#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) ref.dllFuncs.GL_SetupAttributes( glw_state.safe ); } void GL_SwapBuffers( void ) { -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) SDL_GL_SwapWindow( host.hWnd ); -#else // SDL_VERSION_ATLEAST( 2, 0, 0 ) - SDL_Flip( host.hWnd ); -#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) } int GL_SetAttribute( int attr, int val ) @@ -981,7 +878,6 @@ int GL_SetAttribute( int attr, int val ) MAP_REF_API_ATTRIBUTE_TO_SDL( GL_MULTISAMPLEBUFFERS ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_MULTISAMPLESAMPLES ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_ACCELERATED_VISUAL ); -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_MAJOR_VERSION ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_MINOR_VERSION ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_EGL ); @@ -992,12 +888,11 @@ int GL_SetAttribute( int attr, int val ) #ifdef SDL_HINT_OPENGL_ES_DRIVER if( val == REF_GL_CONTEXT_PROFILE_ES ) { - SDL_SetHint(SDL_HINT_OPENGL_ES_DRIVER, "1"); + SDL_SetHint( SDL_HINT_OPENGL_ES_DRIVER, "1" ); SDL_SetHint( "SDL_VIDEO_X11_FORCE_EGL", "1" ); } #endif // SDL_HINT_OPENGL_ES_DRIVER return SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, val ); -#endif #if SDL_VERSION_ATLEAST( 2, 0, 4 ) MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_RELEASE_BEHAVIOR ); #endif @@ -1026,7 +921,6 @@ int GL_GetAttribute( int attr, int *val ) MAP_REF_API_ATTRIBUTE_TO_SDL( GL_MULTISAMPLEBUFFERS ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_MULTISAMPLESAMPLES ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_ACCELERATED_VISUAL ); -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_MAJOR_VERSION ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_MINOR_VERSION ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_EGL ); @@ -1034,7 +928,6 @@ int GL_GetAttribute( int attr, int *val ) MAP_REF_API_ATTRIBUTE_TO_SDL( GL_SHARE_WITH_CURRENT_CONTEXT ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_FRAMEBUFFER_SRGB_CAPABLE ); MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_PROFILE_MASK ); -#endif #if SDL_VERSION_ATLEAST( 2, 0, 4 ) MAP_REF_API_ATTRIBUTE_TO_SDL( GL_CONTEXT_RELEASE_BEHAVIOR ); #endif @@ -1061,21 +954,16 @@ qboolean R_Init_Video( const int type ) { string safe; qboolean retval; - -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) SDL_DisplayMode displayMode; #if SDL_VERSION_ATLEAST( 2, 24, 0 ) SDL_Point point = { window_xpos.value, window_ypos.value }; int displayIndex = SDL_GetPointDisplayIndex( &point ); #else int displayIndex = 0; + SDL_GetCurrentDisplayMode( displayIndex, &displayMode ); #endif - SDL_GetCurrentDisplayMode( displayIndex, &displayMode ); refState.desktopBitsPixel = SDL_BITSPERPIXEL( displayMode.format ); -#else - refState.desktopBitsPixel = 16; -#endif #ifdef SDL_HINT_QTWAYLAND_WINDOW_FLAGS SDL_SetHint( SDL_HINT_QTWAYLAND_WINDOW_FLAGS, "OverridesSystemGestures" ); @@ -1084,12 +972,12 @@ qboolean R_Init_Video( const int type ) SDL_SetHint( SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION, "landscape" ); #endif -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) && !XASH_WIN32 +#if !XASH_WIN32 SDL_SetHint( "SDL_VIDEO_X11_XRANDR", "1" ); SDL_SetHint( "SDL_VIDEO_X11_XVIDMODE", "1" ); if( Sys_CheckParm( "-egl" ) ) SDL_SetHint( "SDL_VIDEO_X11_FORCE_EGL", "1" ); -#endif +#endif // !XASH_WIN32 // must be initialized before creating window #if XASH_WIN32 @@ -1144,7 +1032,6 @@ qboolean R_Init_Video( const int type ) rserr_t R_ChangeDisplaySettings( int width, int height, window_mode_t window_mode ) { -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) SDL_DisplayMode displayMode; if( SDL_GetCurrentDisplayMode( 0, &displayMode ) < 0 ) @@ -1160,7 +1047,6 @@ rserr_t R_ChangeDisplaySettings( int width, int height, window_mode_t window_mod width = displayMode.w; height = displayMode.h; } -#endif refState.fullScreen = window_mode != WINDOW_MODE_WINDOWED; Con_Reportf( "%s: Setting video mode to %dx%d %s\n", __func__, width, height, refState.fullScreen ? "fullscreen" : "windowed" ); @@ -1179,7 +1065,6 @@ rserr_t R_ChangeDisplaySettings( int width, int height, window_mode_t window_mod { VID_RestoreScreenResolution(); -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) if( SDL_SetWindowFullscreen( host.hWnd, 0 ) < 0 ) { Con_Printf( S_ERROR "SDL_SetWindowFullscreen: %s", SDL_GetError( )); @@ -1190,7 +1075,6 @@ rserr_t R_ChangeDisplaySettings( int width, int height, window_mode_t window_mod #endif SDL_SetWindowBordered( host.hWnd, SDL_TRUE ); SDL_SetWindowSize( host.hWnd, width, height ); -#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) VID_SaveWindowSize( width, height, true ); } @@ -1217,7 +1101,6 @@ qboolean VID_SetMode( void ) if( iScreenWidth < VID_MIN_WIDTH || iScreenHeight < VID_MIN_HEIGHT ) // trying to get resolution automatically by default { -#if SDL_VERSION_ATLEAST( 2, 0, 0 ) #if !defined( DEFAULT_MODE_WIDTH ) || !defined( DEFAULT_MODE_HEIGHT ) SDL_DisplayMode mode; @@ -1229,10 +1112,6 @@ qboolean VID_SetMode( void ) iScreenWidth = DEFAULT_MODE_WIDTH; iScreenHeight = DEFAULT_MODE_HEIGHT; #endif -#else // SDL_VERSION_ATLEAST( 2, 0, 0 ) - iScreenWidth = 320; - iScreenHeight = 240; -#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) } #if XASH_MOBILE_PLATFORM @@ -1294,5 +1173,3 @@ void R_Free_Video( void ) ref.dllFuncs.GL_ClearExtensions(); } - -#endif // XASH_DEDICATED