mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-01-19 07:51:03 +00:00
commit
40b5fbe87a
3 changed files with 114 additions and 1 deletions
|
@ -32,6 +32,7 @@
|
|||
extern void M_ForceMenuOff(void);
|
||||
|
||||
static cvar_t *r_mode;
|
||||
static cvar_t *vid_displayindex;
|
||||
static cvar_t *r_hudscale;
|
||||
static cvar_t *r_consolescale;
|
||||
static cvar_t *r_menuscale;
|
||||
|
@ -49,6 +50,7 @@ static menuframework_s s_opengl_menu;
|
|||
|
||||
static menulist_s s_renderer_list;
|
||||
static menulist_s s_mode_list;
|
||||
static menulist_s s_display_list;
|
||||
static menulist_s s_uiscale_list;
|
||||
static menuslider_s s_brightness_slider;
|
||||
static menuslider_s s_fov_slider;
|
||||
|
@ -190,6 +192,12 @@ ApplyChanges(void *unused)
|
|||
Cvar_SetValue("r_mode", s_mode_list.curvalue);
|
||||
}
|
||||
|
||||
if (s_display_list.curvalue != GLimp_GetWindowDisplayIndex() )
|
||||
{
|
||||
Cvar_SetValue( "vid_displayindex", s_display_list.curvalue );
|
||||
restart = true;
|
||||
}
|
||||
|
||||
/* UI scaling */
|
||||
if (s_uiscale_list.curvalue == 0)
|
||||
{
|
||||
|
@ -333,6 +341,11 @@ VID_MenuInit(void)
|
|||
r_mode = Cvar_Get("r_mode", "4", 0);
|
||||
}
|
||||
|
||||
if (!vid_displayindex)
|
||||
{
|
||||
vid_displayindex = Cvar_Get("vid_displayindex", "0", CVAR_ARCHIVE);
|
||||
}
|
||||
|
||||
if (!r_hudscale)
|
||||
{
|
||||
r_hudscale = Cvar_Get("r_hudscale", "-1", CVAR_ARCHIVE);
|
||||
|
@ -414,6 +427,16 @@ VID_MenuInit(void)
|
|||
s_mode_list.curvalue = GetCustomValue(&s_mode_list);
|
||||
}
|
||||
|
||||
if (GLimp_GetNumVideoDisplays() > 1)
|
||||
{
|
||||
s_display_list.generic.type = MTYPE_SPINCONTROL;
|
||||
s_display_list.generic.name = "display index";
|
||||
s_display_list.generic.x = 0;
|
||||
s_display_list.generic.y = (y += 10);
|
||||
s_display_list.itemnames = GLimp_GetDisplayIndices();
|
||||
s_display_list.curvalue = GLimp_GetWindowDisplayIndex();
|
||||
}
|
||||
|
||||
s_brightness_slider.generic.type = MTYPE_SLIDER;
|
||||
s_brightness_slider.generic.name = "brightness";
|
||||
s_brightness_slider.generic.x = 0;
|
||||
|
@ -519,6 +542,13 @@ VID_MenuInit(void)
|
|||
|
||||
Menu_AddItem(&s_opengl_menu, (void *)&s_renderer_list);
|
||||
Menu_AddItem(&s_opengl_menu, (void *)&s_mode_list);
|
||||
|
||||
// only show this option if we have multiple displays
|
||||
if (GLimp_GetNumVideoDisplays() > 1)
|
||||
{
|
||||
Menu_AddItem(&s_opengl_menu, (void *)&s_display_list);
|
||||
}
|
||||
|
||||
Menu_AddItem(&s_opengl_menu, (void *)&s_brightness_slider);
|
||||
Menu_AddItem(&s_opengl_menu, (void *)&s_fov_slider);
|
||||
Menu_AddItem(&s_opengl_menu, (void *)&s_uiscale_list);
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <SDL2/SDL_video.h>
|
||||
|
||||
cvar_t *vid_displayrefreshrate;
|
||||
static cvar_t *vid_displayindex;
|
||||
int glimp_refreshRate = -1;
|
||||
|
||||
static int last_flags = 0;
|
||||
|
@ -42,12 +43,73 @@ static int last_position_x = SDL_WINDOWPOS_UNDEFINED;
|
|||
static int last_position_y = SDL_WINDOWPOS_UNDEFINED;
|
||||
static SDL_Window* window = NULL;
|
||||
static qboolean initSuccessful = false;
|
||||
static char **displayindices = NULL;
|
||||
static int num_displays = 0;
|
||||
|
||||
const char**
|
||||
GLimp_GetDisplayIndices(void)
|
||||
{
|
||||
return (const char**)displayindices;
|
||||
}
|
||||
|
||||
int
|
||||
GLimp_GetWindowDisplayIndex(void)
|
||||
{
|
||||
return last_display;
|
||||
}
|
||||
|
||||
int
|
||||
GLimp_GetNumVideoDisplays(void)
|
||||
{
|
||||
return num_displays;
|
||||
}
|
||||
|
||||
/*
|
||||
* Resets the display index Cvar if out of bounds
|
||||
*/
|
||||
static void
|
||||
ClampDisplayIndexCvar(void)
|
||||
{
|
||||
if (vid_displayindex->value < 0 || vid_displayindex->value >= num_displays)
|
||||
Cvar_SetValue("vid_displayindex", 0);
|
||||
}
|
||||
|
||||
static void
|
||||
ClearDisplayIndices(void)
|
||||
{
|
||||
if ( displayindices )
|
||||
{
|
||||
for ( int i = 0; i < num_displays; i++ )
|
||||
free( displayindices[ i ] );
|
||||
|
||||
free( displayindices );
|
||||
displayindices = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
InitDisplayIndices()
|
||||
{
|
||||
displayindices = malloc( ( num_displays + 1 ) * sizeof( char* ) );
|
||||
for ( int i = 0; i < num_displays; i++ )
|
||||
{
|
||||
displayindices[ i ] = malloc( 11 * sizeof( char ) ); // There are a maximum of 10 digits in 32 bit int + 1 for the NULL terminator
|
||||
snprintf( displayindices[ i ], 11, "%d", i );
|
||||
}
|
||||
|
||||
// The last entry is NULL to indicate the list of strings ends
|
||||
displayindices[ num_displays ] = 0;
|
||||
}
|
||||
|
||||
// --------
|
||||
|
||||
static qboolean
|
||||
CreateSDLWindow(int flags, int w, int h)
|
||||
{
|
||||
if (SDL_WINDOWPOS_ISUNDEFINED(last_position_x) || SDL_WINDOWPOS_ISUNDEFINED(last_position_y)) {
|
||||
last_position_x = last_position_y = SDL_WINDOWPOS_UNDEFINED_DISPLAY((int)vid_displayindex->value);
|
||||
}
|
||||
|
||||
window = SDL_CreateWindow("Yamagi Quake II",
|
||||
last_position_x, last_position_y,
|
||||
w, h, flags);
|
||||
|
@ -144,12 +206,23 @@ void GLimp_GrabInput(qboolean grab);
|
|||
static void
|
||||
ShutdownGraphics(void)
|
||||
{
|
||||
ClampDisplayIndexCvar();
|
||||
|
||||
if (window)
|
||||
{
|
||||
/* save current display as default */
|
||||
last_display = SDL_GetWindowDisplayIndex(window);
|
||||
SDL_GetWindowPosition(window,
|
||||
|
||||
/* or if current display isn't the desired default */
|
||||
if (last_display != vid_displayindex->value) {
|
||||
last_position_x = last_position_y = SDL_WINDOWPOS_UNDEFINED;
|
||||
last_display = vid_displayindex->value;
|
||||
}
|
||||
else {
|
||||
SDL_GetWindowPosition(window,
|
||||
&last_position_x, &last_position_y);
|
||||
}
|
||||
|
||||
/* cleanly ungrab input (needs window) */
|
||||
GLimp_GrabInput(false);
|
||||
SDL_DestroyWindow(window);
|
||||
|
@ -172,6 +245,7 @@ qboolean
|
|||
GLimp_Init(void)
|
||||
{
|
||||
vid_displayrefreshrate = Cvar_Get("vid_displayrefreshrate", "-1", CVAR_ARCHIVE);
|
||||
vid_displayindex = Cvar_Get("vid_displayindex", "0", CVAR_ARCHIVE);
|
||||
|
||||
if (!SDL_WasInit(SDL_INIT_VIDEO))
|
||||
{
|
||||
|
@ -187,6 +261,10 @@ GLimp_Init(void)
|
|||
SDL_GetVersion(&version);
|
||||
Com_Printf("SDL version is: %i.%i.%i\n", (int)version.major, (int)version.minor, (int)version.patch);
|
||||
Com_Printf("SDL video driver is \"%s\".\n", SDL_GetCurrentVideoDriver());
|
||||
|
||||
num_displays = SDL_GetNumVideoDisplays();
|
||||
InitDisplayIndices();
|
||||
ClampDisplayIndexCvar();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -210,6 +288,8 @@ GLimp_Shutdown(void)
|
|||
{
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
}
|
||||
|
||||
ClearDisplayIndices();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -55,6 +55,9 @@ const char *VID_MenuKey(int);
|
|||
// Stuff provided by platform backend.
|
||||
extern int glimp_refreshRate;
|
||||
|
||||
const char **GLimp_GetDisplayIndices(void);
|
||||
int GLimp_GetWindowDisplayIndex(void);
|
||||
int GLimp_GetNumVideoDisplays(void);
|
||||
qboolean GLimp_Init(void);
|
||||
void GLimp_Shutdown(void);
|
||||
qboolean GLimp_InitGraphics(int fullscreen, int *pwidth, int *pheight);
|
||||
|
|
Loading…
Reference in a new issue