mirror of
https://github.com/ioquake/ioq3.git
synced 2024-11-10 07:11:46 +00:00
- implement r_noborder, inspired by patch from ensiform (#4289)
- Add Sys_SetEnv for portable setting of environment variables - Default ioquake3 to appear on the center of the screen if running in windowed mode.
This commit is contained in:
parent
c90eae4de5
commit
bd2ab9bffd
6 changed files with 48 additions and 7 deletions
2
README
2
README
|
@ -192,6 +192,8 @@ New cvars
|
|||
intend to use this.
|
||||
r_sdlDriver - read only, indicates the SDL driver
|
||||
backend being used
|
||||
r_noborder - Remove window decoration from window
|
||||
managers, like borders and titlebar.
|
||||
|
||||
New commands
|
||||
video [filename] - start video capture (use with demo command)
|
||||
|
|
|
@ -135,6 +135,7 @@ cvar_t *r_subdivisions;
|
|||
cvar_t *r_lodCurveError;
|
||||
|
||||
cvar_t *r_fullscreen;
|
||||
cvar_t *r_noborder;
|
||||
|
||||
cvar_t *r_customwidth;
|
||||
cvar_t *r_customheight;
|
||||
|
@ -909,6 +910,7 @@ void R_Register( void )
|
|||
r_ignorehwgamma = ri.Cvar_Get( "r_ignorehwgamma", "0", CVAR_ARCHIVE | CVAR_LATCH);
|
||||
r_mode = ri.Cvar_Get( "r_mode", "3", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_fullscreen = ri.Cvar_Get( "r_fullscreen", "1", CVAR_ARCHIVE );
|
||||
r_noborder = Cvar_Get("r_noborder", "0", CVAR_ARCHIVE);
|
||||
r_customwidth = ri.Cvar_Get( "r_customwidth", "1600", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_customheight = ri.Cvar_Get( "r_customheight", "1024", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_customPixelAspect = ri.Cvar_Get( "r_customPixelAspect", "1", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
|
|
|
@ -1043,6 +1043,7 @@ extern cvar_t *r_showcluster;
|
|||
|
||||
extern cvar_t *r_mode; // video mode
|
||||
extern cvar_t *r_fullscreen;
|
||||
extern cvar_t *r_noborder;
|
||||
extern cvar_t *r_gamma;
|
||||
extern cvar_t *r_displayRefresh; // optional display refresh option
|
||||
extern cvar_t *r_ignorehwgamma; // overrides hardware gamma capabilities
|
||||
|
|
|
@ -188,7 +188,7 @@ static void GLimp_DetectAvailableModes(void)
|
|||
GLimp_SetMode
|
||||
===============
|
||||
*/
|
||||
static int GLimp_SetMode( int mode, qboolean fullscreen )
|
||||
static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder)
|
||||
{
|
||||
const char* glstring;
|
||||
int sdlcolorbits;
|
||||
|
@ -249,7 +249,12 @@ static int GLimp_SetMode( int mode, qboolean fullscreen )
|
|||
glConfig.isFullscreen = qtrue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (noborder)
|
||||
flags |= SDL_NOFRAME;
|
||||
|
||||
glConfig.isFullscreen = qfalse;
|
||||
}
|
||||
|
||||
colorbits = r_colorbits->value;
|
||||
if ((!colorbits) || (colorbits >= 32))
|
||||
|
@ -428,7 +433,7 @@ static int GLimp_SetMode( int mode, qboolean fullscreen )
|
|||
GLimp_StartDriverAndSetMode
|
||||
===============
|
||||
*/
|
||||
static qboolean GLimp_StartDriverAndSetMode( int mode, qboolean fullscreen )
|
||||
static qboolean GLimp_StartDriverAndSetMode(int mode, qboolean fullscreen, qboolean noborder)
|
||||
{
|
||||
rserr_t err;
|
||||
|
||||
|
@ -456,7 +461,7 @@ static qboolean GLimp_StartDriverAndSetMode( int mode, qboolean fullscreen )
|
|||
fullscreen = qfalse;
|
||||
}
|
||||
|
||||
err = GLimp_SetMode( mode, fullscreen );
|
||||
err = GLimp_SetMode(mode, fullscreen, noborder);
|
||||
|
||||
switch ( err )
|
||||
{
|
||||
|
@ -666,16 +671,18 @@ void GLimp_Init( void )
|
|||
r_sdlDriver = ri.Cvar_Get( "r_sdlDriver", "", CVAR_ROM );
|
||||
r_allowResize = ri.Cvar_Get( "r_allowResize", "0", CVAR_ARCHIVE );
|
||||
|
||||
Sys_SetEnv("SDL_VIDEO_CENTERED", "1");
|
||||
|
||||
Sys_GLimpInit( );
|
||||
|
||||
// Create the window and set up the context
|
||||
if( GLimp_StartDriverAndSetMode( r_mode->integer, r_fullscreen->integer ) )
|
||||
if(GLimp_StartDriverAndSetMode(r_mode->integer, r_fullscreen->integer, r_noborder->integer))
|
||||
goto success;
|
||||
|
||||
// Try again, this time in a platform specific "safe mode"
|
||||
Sys_GLimpSafeInit( );
|
||||
|
||||
if( GLimp_StartDriverAndSetMode( r_mode->integer, r_fullscreen->integer ) )
|
||||
if(GLimp_StartDriverAndSetMode(r_mode->integer, r_fullscreen->integer, qfalse))
|
||||
goto success;
|
||||
|
||||
// Finally, try the default screen resolution
|
||||
|
@ -684,7 +691,7 @@ void GLimp_Init( void )
|
|||
ri.Printf( PRINT_ALL, "Setting r_mode %d failed, falling back on r_mode %d\n",
|
||||
r_mode->integer, R_MODE_FALLBACK );
|
||||
|
||||
if( GLimp_StartDriverAndSetMode( R_MODE_FALLBACK, r_fullscreen->integer ) )
|
||||
if(GLimp_StartDriverAndSetMode(R_MODE_FALLBACK, r_fullscreen->integer, qfalse))
|
||||
goto success;
|
||||
}
|
||||
|
||||
|
|
|
@ -583,3 +583,19 @@ void Sys_PlatformInit( void )
|
|||
signal( SIGIOT, Sys_SigHandler );
|
||||
signal( SIGBUS, Sys_SigHandler );
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
Sys_SetEnv
|
||||
|
||||
set/unset environment variables (empty value removes it)
|
||||
==============
|
||||
*/
|
||||
|
||||
void Sys_SetEnv(const char *name, const char *value)
|
||||
{
|
||||
if(value && *value)
|
||||
setenv(name, value, 1);
|
||||
else
|
||||
unsetenv(name);
|
||||
}
|
||||
|
|
|
@ -652,3 +652,16 @@ void Sys_PlatformInit( void )
|
|||
SDL_VIDEODRIVER_externallySet = qfalse;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
Sys_SetEnv
|
||||
|
||||
set/unset environment variables (empty value removes it)
|
||||
==============
|
||||
*/
|
||||
|
||||
void Sys_SetEnv(const char *name, const char *value)
|
||||
{
|
||||
_putenv(va("%s=%s", name, value);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue