mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-10 06:02:10 +08:00
engine: move vid cvars to static allocation
This commit is contained in:
@@ -122,7 +122,6 @@ qboolean VID_SetMode( void )
|
||||
rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen )
|
||||
{
|
||||
int render_w, render_h;
|
||||
uint rotate = vid_rotate->value;
|
||||
|
||||
FB_GetScreenRes( &width, &height );
|
||||
|
||||
@@ -131,23 +130,7 @@ rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen )
|
||||
|
||||
Con_Reportf( "R_ChangeDisplaySettings: forced resolution to %dx%d)\n", width, height );
|
||||
|
||||
if( ref.dllFuncs.R_SetDisplayTransform( rotate, 0, 0, vid_scale->value, vid_scale->value ) )
|
||||
{
|
||||
if( rotate & 1 )
|
||||
{
|
||||
int swap = render_w;
|
||||
|
||||
render_w = render_h;
|
||||
render_h = swap;
|
||||
}
|
||||
|
||||
render_h /= vid_scale->value;
|
||||
render_w /= vid_scale->value;
|
||||
}
|
||||
else
|
||||
{
|
||||
Con_Printf( S_WARN "failed to setup screen transform\n" );
|
||||
}
|
||||
VID_SetDisplayTransform( &render_w, &render_h );
|
||||
R_SaveVideoMode( width, height, render_w, render_h );
|
||||
|
||||
return rserr_ok;
|
||||
|
||||
@@ -374,7 +374,7 @@ static void SDLash_ActiveEvent( int gain )
|
||||
SNDDMA_Activate( true );
|
||||
}
|
||||
host.force_draw_version_time = host.realtime + FORCE_DRAW_VERSION_TIME;
|
||||
if( vid_fullscreen->value )
|
||||
if( vid_fullscreen.value )
|
||||
VID_SetMode();
|
||||
}
|
||||
else
|
||||
@@ -611,10 +611,15 @@ static void SDLash_EventFilter( SDL_Event *event )
|
||||
switch( event->window.event )
|
||||
{
|
||||
case SDL_WINDOWEVENT_MOVED:
|
||||
if( !vid_fullscreen->value )
|
||||
if( !vid_fullscreen.value )
|
||||
{
|
||||
Cvar_SetValue( "_window_xpos", (float)event->window.data1 );
|
||||
Cvar_SetValue( "_window_ypos", (float)event->window.data2 );
|
||||
char val[32];
|
||||
|
||||
Q_snprintf( val, sizeof( val ), "%d", event->window.data1 );
|
||||
Cvar_DirectSet( &window_xpos, val );
|
||||
|
||||
Q_snprintf( val, sizeof( val ), "%d", event->window.data2 );
|
||||
Cvar_DirectSet( &window_ypos, val );
|
||||
}
|
||||
break;
|
||||
case SDL_WINDOWEVENT_MINIMIZED:
|
||||
@@ -624,7 +629,7 @@ static void SDLash_EventFilter( SDL_Event *event )
|
||||
case SDL_WINDOWEVENT_RESTORED:
|
||||
host.status = HOST_FRAME;
|
||||
host.force_draw_version_time = host.realtime + FORCE_DRAW_VERSION_TIME;
|
||||
if( vid_fullscreen->value )
|
||||
if( vid_fullscreen.value )
|
||||
VID_SetMode();
|
||||
break;
|
||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||
@@ -635,7 +640,7 @@ static void SDLash_EventFilter( SDL_Event *event )
|
||||
break;
|
||||
case SDL_WINDOWEVENT_RESIZED:
|
||||
{
|
||||
if( vid_fullscreen->value )
|
||||
if( vid_fullscreen.value )
|
||||
break;
|
||||
|
||||
VID_SaveWindowSize( event->window.data1, event->window.data2 );
|
||||
|
||||
@@ -523,7 +523,6 @@ static qboolean GL_UpdateContext( void )
|
||||
void VID_SaveWindowSize( int width, int height )
|
||||
{
|
||||
int render_w = width, render_h = height;
|
||||
uint rotate = vid_rotate->value;
|
||||
|
||||
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
|
||||
if( !glw_state.software )
|
||||
@@ -532,24 +531,7 @@ void VID_SaveWindowSize( int width, int height )
|
||||
SDL_RenderSetLogicalSize( sw.renderer, width, height );
|
||||
#endif
|
||||
|
||||
if( ref.dllFuncs.R_SetDisplayTransform( rotate, 0, 0, vid_scale->value, vid_scale->value ) )
|
||||
{
|
||||
if( rotate & 1 )
|
||||
{
|
||||
int swap = render_w;
|
||||
|
||||
render_w = render_h;
|
||||
render_h = swap;
|
||||
}
|
||||
|
||||
render_h /= vid_scale->value;
|
||||
render_w /= vid_scale->value;
|
||||
}
|
||||
else
|
||||
{
|
||||
Con_Printf( S_WARN "failed to setup screen transform\n" );
|
||||
}
|
||||
|
||||
VID_SetDisplayTransform( &render_w, &render_h );
|
||||
R_SaveVideoMode( width, height, render_w, render_h );
|
||||
}
|
||||
|
||||
@@ -561,7 +543,7 @@ static qboolean VID_SetScreenResolution( int width, int height )
|
||||
static string wndname;
|
||||
|
||||
#if !XASH_APPLE
|
||||
if( vid_highdpi->value ) wndFlags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
||||
if( vid_highdpi.value ) wndFlags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
||||
#endif
|
||||
Q_strncpy( wndname, GI->title, sizeof( wndname ));
|
||||
|
||||
@@ -596,7 +578,7 @@ static qboolean VID_SetScreenResolution( int width, int height )
|
||||
void VID_RestoreScreenResolution( void )
|
||||
{
|
||||
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
|
||||
if( !vid_fullscreen->value )
|
||||
if( !vid_fullscreen.value )
|
||||
{
|
||||
SDL_SetWindowBordered( host.hWnd, SDL_TRUE );
|
||||
}
|
||||
@@ -641,7 +623,7 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen )
|
||||
int xpos, ypos;
|
||||
const char *localIcoPath;
|
||||
|
||||
if( vid_highdpi->value ) wndFlags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
||||
if( vid_highdpi.value ) wndFlags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
||||
Q_strncpy( wndname, GI->title, sizeof( wndname ));
|
||||
if( glw_state.software )
|
||||
wndFlags &= ~SDL_WINDOW_OPENGL;
|
||||
@@ -665,8 +647,8 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen )
|
||||
}
|
||||
else
|
||||
{
|
||||
xpos = Cvar_VariableInteger( "_window_xpos" );
|
||||
ypos = Cvar_VariableInteger( "_window_ypos" );
|
||||
xpos = window_xpos.value;
|
||||
ypos = window_ypos.value;
|
||||
|
||||
// don't create window outside of usable display space
|
||||
if( xpos < r.x || xpos + width > r.x + r.w )
|
||||
@@ -1144,14 +1126,14 @@ qboolean VID_SetMode( void )
|
||||
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
|
||||
}
|
||||
|
||||
if( !FBitSet( vid_fullscreen->flags, FCVAR_CHANGED ) )
|
||||
Cvar_DirectSet( vid_fullscreen, DEFAULT_FULLSCREEN );
|
||||
if( !FBitSet( vid_fullscreen.flags, FCVAR_CHANGED ) )
|
||||
Cvar_DirectSet( &vid_fullscreen, DEFAULT_FULLSCREEN );
|
||||
else
|
||||
ClearBits( vid_fullscreen->flags, FCVAR_CHANGED );
|
||||
ClearBits( vid_fullscreen.flags, FCVAR_CHANGED );
|
||||
|
||||
SetBits( gl_vsync->flags, FCVAR_CHANGED );
|
||||
|
||||
if(( err = R_ChangeDisplaySettings( iScreenWidth, iScreenHeight, vid_fullscreen->value )) == rserr_ok )
|
||||
if(( err = R_ChangeDisplaySettings( iScreenWidth, iScreenHeight, vid_fullscreen.value )) == rserr_ok )
|
||||
{
|
||||
sdlState.prev_width = iScreenWidth;
|
||||
sdlState.prev_height = iScreenHeight;
|
||||
@@ -1160,7 +1142,7 @@ qboolean VID_SetMode( void )
|
||||
{
|
||||
if( err == rserr_invalid_fullscreen )
|
||||
{
|
||||
Cvar_DirectSet( vid_fullscreen, "0" );
|
||||
Cvar_DirectSet( &vid_fullscreen, "0" );
|
||||
Con_Reportf( S_ERROR "VID_SetMode: fullscreen unavailable in this mode\n" );
|
||||
Sys_Warn("fullscreen unavailable in this mode!");
|
||||
if(( err = R_ChangeDisplaySettings( iScreenWidth, iScreenHeight, false )) == rserr_ok )
|
||||
|
||||
Reference in New Issue
Block a user