- 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:
Thilo Schulz 2009-11-03 20:29:43 +00:00
parent c90eae4de5
commit bd2ab9bffd
6 changed files with 48 additions and 7 deletions

2
README
View file

@ -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)

View file

@ -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 );

View file

@ -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

View file

@ -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;
@ -455,8 +460,8 @@ static qboolean GLimp_StartDriverAndSetMode( int mode, qboolean fullscreen )
r_fullscreen->modified = qfalse;
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;
}

View file

@ -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);
}

View file

@ -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);
}