Browse Source

engine: fix build after lowmemory rebase

pull/2/head
Alibek Omarov 5 years ago
parent
commit
1f308a43c8
  1. 1
      engine/common/common.c
  2. 7
      engine/common/host.c
  3. 6
      engine/platform/sdl/events.c
  4. 35
      engine/platform/sdl/vid_sdl.c
  5. 2
      engine/wscript

1
engine/common/common.c

@ -19,6 +19,7 @@ GNU General Public License for more details.
#include "const.h" #include "const.h"
#include "client.h" #include "client.h"
#include "library.h" #include "library.h"
#include "sequence.h"
static const char *file_exts[] = static const char *file_exts[] =
{ {

7
engine/common/host.c

@ -323,7 +323,9 @@ void Host_MemStats_f( void )
void Host_Minimize_f( void ) void Host_Minimize_f( void )
{ {
#ifdef XASH_SDL
if( host.hWnd ) SDL_MinimizeWindow( host.hWnd ); if( host.hWnd ) SDL_MinimizeWindow( host.hWnd );
#endif
} }
/* /*
@ -812,14 +814,11 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha
#endif #endif
#ifdef XASH_SDL #ifdef XASH_SDL
// should work even if it failed
SDL_Init( SDL_INIT_TIMER );
#ifndef SDL_INIT_EVENTS #ifndef SDL_INIT_EVENTS
#define SDL_INIT_EVENTS 0 #define SDL_INIT_EVENTS 0
#endif #endif
if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_EVENTS ) ) if( SDL_Init( SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_EVENTS ) )
{ {
Sys_Warn( "SDL_Init failed: %s", SDL_GetError() ); Sys_Warn( "SDL_Init failed: %s", SDL_GetError() );
host.type = HOST_DEDICATED; host.type = HOST_DEDICATED;

6
engine/platform/sdl/events.c

@ -568,14 +568,12 @@ static void SDLash_EventFilter( SDL_Event *event )
SDLash_ActiveEvent( false ); SDLash_ActiveEvent( false );
break; break;
case SDL_WINDOWEVENT_RESIZED: case SDL_WINDOWEVENT_RESIZED:
case SDL_WINDOWEVENT_MAXIMIZED:
{ {
int w = VID_MIN_WIDTH, h = VID_MIN_HEIGHT; int w = VID_MIN_WIDTH, h = VID_MIN_HEIGHT;
if( vid_fullscreen->value ) if( vid_fullscreen->value )
break; break;
SDL_GL_GetDrawableSize( host.hWnd, &w, &h ); VID_SaveWindowSize( w, h );
R_SaveVideoMode( w, h );
SCR_VidInit(); // tell the client.dll that vid_mode has changed SCR_VidInit(); // tell the client.dll that vid_mode has changed
break; break;
} }
@ -584,7 +582,7 @@ static void SDLash_EventFilter( SDL_Event *event )
} }
#else #else
case SDL_VIDEORESIZE: case SDL_VIDEORESIZE:
R_SaveVideoMode( event->resize.w, event->resize.h ); VID_SaveWindowSize( event->resize.w, event->resize.h );
SCR_VidInit(); SCR_VidInit();
break; // tell the client.dll that vid_mode has changed break; // tell the client.dll that vid_mode has changed
case SDL_ACTIVEEVENT: case SDL_ACTIVEEVENT:

35
engine/platform/sdl/vid_sdl.c

@ -300,9 +300,11 @@ static void R_InitVideoModes( void )
num_vidmodes++; num_vidmodes++;
} }
#else // SDL_VERSION_ATLEAST( 2, 0, 0 ) #else // SDL_VERSION_ATLEAST( 2, 0, 0 )
SDL_Rect **modes = SDL_ListModes( NULL, SDL_FULLSCREEN ); SDL_Rect **modes;
int len = 0, i = 0, j; int len = 0, i = 0, j;
modes = SDL_ListModes( NULL, SDL_FULLSCREEN );
if( !modes || modes == (void*)-1 ) if( !modes || modes == (void*)-1 )
return; return;
@ -513,10 +515,12 @@ void VID_SaveWindowSize( int width, int height )
int render_w = width, render_h = height; int render_w = width, render_h = height;
uint rotate = vid_rotate->value; uint rotate = vid_rotate->value;
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
if( !glw_state.software ) if( !glw_state.software )
SDL_GL_GetDrawableSize( host.hWnd, &render_w, &render_h ); SDL_GL_GetDrawableSize( host.hWnd, &render_w, &render_h );
else else
SDL_RenderSetLogicalSize( sw.renderer, width, height ); SDL_RenderSetLogicalSize( sw.renderer, width, height );
#endif
if( ref.dllFuncs.R_SetDisplayTransform( rotate, 0, 0, vid_scale->value, vid_scale->value ) ) if( ref.dllFuncs.R_SetDisplayTransform( rotate, 0, 0, vid_scale->value, vid_scale->value ) )
{ {
@ -570,7 +574,7 @@ static qboolean VID_SetScreenResolution( int width, int height )
SDL_SetWindowGrab( host.hWnd, SDL_TRUE ); SDL_SetWindowGrab( host.hWnd, SDL_TRUE );
SDL_SetWindowSize( host.hWnd, got.w, got.h ); SDL_SetWindowSize( host.hWnd, got.w, got.h );
VID_SaveWindowSize( gow.w, got.h ); VID_SaveWindowSize( got.w, got.h );
#else #else
VID_SaveWindowSize( width, height ); VID_SaveWindowSize( width, height );
#endif #endif
@ -774,7 +778,7 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen )
if( fullscreen ) if( fullscreen )
{ {
// flags |= SDL_FULLSCREEN; flags |= SDL_FULLSCREEN|SDL_HWSURFACE;
} }
if( glw_state.software ) if( glw_state.software )
@ -788,7 +792,7 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen )
while( glw_state.safe >= SAFE_NO && glw_state.safe < SAFE_LAST ) while( glw_state.safe >= SAFE_NO && glw_state.safe < SAFE_LAST )
{ {
host.hWnd = sw.surf = SDL_SetVideoMode( width, height, 0, flags ); host.hWnd = sw.surf = SDL_SetVideoMode( width, height, 16, flags );
// we have window, exit loop // we have window, exit loop
if( host.hWnd ) if( host.hWnd )
@ -815,7 +819,7 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen )
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) #endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
VID_SaveVideoMode( width, height ); VID_SaveWindowSize( width, height );
return true; return true;
} }
@ -964,19 +968,13 @@ qboolean R_Init_Video( const int type )
SDL_GetCurrentDisplayMode(0, &displayMode); SDL_GetCurrentDisplayMode(0, &displayMode);
refState.desktopBitsPixel = SDL_BITSPERPIXEL( displayMode.format ); refState.desktopBitsPixel = SDL_BITSPERPIXEL( displayMode.format );
#else #else
refState.desktopBitsPixel = 32; refState.desktopBitsPixel = 16;
#endif #endif
#if ! SDL_VERSION_ATLEAST( 2, 0, 0 ) #if SDL_VERSION_ATLEAST( 2, 0, 0 ) && !defined(_WIN32)
SDL_VideoInit( "caca", 0 );
#else
#if !defined(_WIN32)
SDL_SetHint( "SDL_VIDEO_X11_XRANDR", "1" ); SDL_SetHint( "SDL_VIDEO_X11_XRANDR", "1" );
SDL_SetHint( "SDL_VIDEO_X11_XVIDMODE", "1" ); SDL_SetHint( "SDL_VIDEO_X11_XVIDMODE", "1" );
#endif #endif
#endif
R_InitVideoModes();
// must be initialized before creating window // must be initialized before creating window
#ifdef _WIN32 #ifdef _WIN32
@ -1022,6 +1020,8 @@ qboolean R_Init_Video( const int type )
break; break;
} }
R_InitVideoModes();
host.renderinfo_changed = false; host.renderinfo_changed = false;
return true; return true;
@ -1065,7 +1065,7 @@ rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen )
SDL_SetWindowSize( host.hWnd, width, height ); SDL_SetWindowSize( host.hWnd, width, height );
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) #endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
VID_SaveVideoMode( width, height ); VID_SaveWindowSize( width, height );
} }
return rserr_ok; return rserr_ok;
@ -1087,10 +1087,10 @@ qboolean VID_SetMode( void )
iScreenWidth = Cvar_VariableInteger( "width" ); iScreenWidth = Cvar_VariableInteger( "width" );
iScreenHeight = Cvar_VariableInteger( "height" ); iScreenHeight = Cvar_VariableInteger( "height" );
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
if( iScreenWidth < VID_MIN_WIDTH || if( iScreenWidth < VID_MIN_WIDTH ||
iScreenHeight < VID_MIN_HEIGHT ) // trying to get resolution automatically by default 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 ) #if !defined( DEFAULT_MODE_WIDTH ) || !defined( DEFAULT_MODE_HEIGHT )
SDL_DisplayMode mode; SDL_DisplayMode mode;
@ -1102,8 +1102,11 @@ qboolean VID_SetMode( void )
iScreenWidth = DEFAULT_MODE_WIDTH; iScreenWidth = DEFAULT_MODE_WIDTH;
iScreenHeight = DEFAULT_MODE_HEIGHT; iScreenHeight = DEFAULT_MODE_HEIGHT;
#endif #endif
} #else // SDL_VERSION_ATLEAST( 2, 0, 0 )
iScreenWidth = 320;
iScreenHeight = 240;
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 ) #endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
}
if( !FBitSet( vid_fullscreen->flags, FCVAR_CHANGED ) ) if( !FBitSet( vid_fullscreen->flags, FCVAR_CHANGED ) )
Cvar_SetValue( "fullscreen", DEFAULT_FULLSCREEN ); Cvar_SetValue( "fullscreen", DEFAULT_FULLSCREEN );

2
engine/wscript

@ -15,8 +15,10 @@ def options(opt):
grp.add_option('--fbdev', action = 'store_true', dest = 'FBDEV_SW', default = False, grp.add_option('--fbdev', action = 'store_true', dest = 'FBDEV_SW', default = False,
help = 'build fbdev-only software-only engine') help = 'build fbdev-only software-only engine')
grp.add_option('--disable-async-resolve', action = 'store_true', dest = 'NO_ASYNC_RESOLVE', default = False, grp.add_option('--disable-async-resolve', action = 'store_true', dest = 'NO_ASYNC_RESOLVE', default = False,
help = 'disable asynchronous name resolution') help = 'disable asynchronous name resolution')
grp.add_option('--enable-custom-swap', action = 'store_true', dest = 'CUSTOM_SWAP', default = False, grp.add_option('--enable-custom-swap', action = 'store_true', dest = 'CUSTOM_SWAP', default = False,
help = 'enable custom swap allocator. For devices with no swap support') help = 'enable custom swap allocator. For devices with no swap support')

Loading…
Cancel
Save