mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-23 04:52:07 +00:00
Add resolution autodetect
This commit is contained in:
parent
0ab41ee0df
commit
fbe42511c1
8 changed files with 152 additions and 20 deletions
|
@ -140,6 +140,9 @@ ResetDefaults(void *unused)
|
|||
VID_MenuInit();
|
||||
}
|
||||
|
||||
#define CUSTOM_MODE_NAME "[Custom ]"
|
||||
#define AUTO_MODE_NAME "[Auto ]"
|
||||
|
||||
static void
|
||||
ApplyChanges(void *unused)
|
||||
{
|
||||
|
@ -168,16 +171,23 @@ ApplyChanges(void *unused)
|
|||
}
|
||||
}
|
||||
|
||||
/* custom mode */
|
||||
if (s_mode_list.curvalue != GetCustomValue(&s_mode_list))
|
||||
/* auto mode */
|
||||
if (!strcmp(s_mode_list.itemnames[s_mode_list.curvalue],
|
||||
AUTO_MODE_NAME))
|
||||
{
|
||||
/* Restarts automatically */
|
||||
Cvar_SetValue("r_mode", s_mode_list.curvalue);
|
||||
Cvar_SetValue("r_mode", -2);
|
||||
}
|
||||
else if (!strcmp(s_mode_list.itemnames[s_mode_list.curvalue],
|
||||
CUSTOM_MODE_NAME))
|
||||
{
|
||||
/* Restarts automatically */
|
||||
Cvar_SetValue("r_mode", -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Restarts automatically */
|
||||
Cvar_SetValue("r_mode", -1);
|
||||
Cvar_SetValue("r_mode", s_mode_list.curvalue);
|
||||
}
|
||||
|
||||
/* UI scaling */
|
||||
|
@ -242,7 +252,7 @@ VID_MenuInit(void)
|
|||
"[OpenGL 1.4]",
|
||||
"[OpenGL 3.2]",
|
||||
"[Software ]",
|
||||
"[Custom ]",
|
||||
CUSTOM_MODE_NAME,
|
||||
0
|
||||
};
|
||||
|
||||
|
@ -279,7 +289,8 @@ VID_MenuInit(void)
|
|||
"[3840 2160 ]",
|
||||
"[4096 2160 ]",
|
||||
"[5120 2880 ]",
|
||||
"[custom ]",
|
||||
AUTO_MODE_NAME,
|
||||
CUSTOM_MODE_NAME,
|
||||
0
|
||||
};
|
||||
|
||||
|
@ -392,8 +403,14 @@ VID_MenuInit(void)
|
|||
{
|
||||
s_mode_list.curvalue = r_mode->value;
|
||||
}
|
||||
else if (r_mode->value == -2)
|
||||
{
|
||||
// 'auto' is before 'custom'
|
||||
s_mode_list.curvalue = GetCustomValue(&s_mode_list) - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 'custom'
|
||||
s_mode_list.curvalue = GetCustomValue(&s_mode_list);
|
||||
}
|
||||
|
||||
|
|
|
@ -425,7 +425,7 @@ R_DrawParticles2(int num_particles, const particle_t particles[],
|
|||
vec3_t up, right;
|
||||
float scale;
|
||||
byte color[4];
|
||||
|
||||
|
||||
GLfloat vtx[3*num_particles*3];
|
||||
GLfloat tex[2*num_particles*3];
|
||||
GLfloat clr[4*num_particles*3];
|
||||
|
@ -433,7 +433,7 @@ R_DrawParticles2(int num_particles, const particle_t particles[],
|
|||
unsigned int index_tex = 0;
|
||||
unsigned int index_clr = 0;
|
||||
unsigned int j;
|
||||
|
||||
|
||||
R_Bind(r_particletexture->texnum);
|
||||
glDepthMask(GL_FALSE); /* no z buffering */
|
||||
glEnable(GL_BLEND);
|
||||
|
@ -505,7 +505,7 @@ R_DrawParticles2(int num_particles, const particle_t particles[],
|
|||
glDisableClientState( GL_VERTEX_ARRAY );
|
||||
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
glDisableClientState( GL_COLOR_ARRAY );
|
||||
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
glColor4f(1, 1, 1, 1);
|
||||
glDepthMask(1); /* back to normal Z buffering */
|
||||
|
@ -523,12 +523,12 @@ R_DrawParticles(void)
|
|||
int i;
|
||||
unsigned char color[4];
|
||||
const particle_t *p;
|
||||
|
||||
|
||||
GLfloat vtx[3*r_newrefdef.num_particles];
|
||||
GLfloat clr[4*r_newrefdef.num_particles];
|
||||
unsigned int index_vtx = 0;
|
||||
unsigned int index_clr = 0;
|
||||
|
||||
|
||||
glDepthMask(GL_FALSE);
|
||||
glEnable(GL_BLEND);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
@ -1285,13 +1285,25 @@ SetMode_impl(int *pwidth, int *pheight, int mode, int fullscreen)
|
|||
|
||||
/* mode -1 is not in the vid mode table - so we keep the values in pwidth
|
||||
and pheight and don't even try to look up the mode info */
|
||||
if ((mode != -1) && !ri.Vid_GetModeInfo(pwidth, pheight, mode))
|
||||
if ((mode >= 0) && !ri.Vid_GetModeInfo(pwidth, pheight, mode))
|
||||
{
|
||||
R_Printf(PRINT_ALL, " invalid mode\n");
|
||||
return rserr_invalid_mode;
|
||||
}
|
||||
|
||||
R_Printf(PRINT_ALL, " %d %d\n", *pwidth, *pheight);
|
||||
/* We trying to get resolution from desktop */
|
||||
if (mode == -2)
|
||||
{
|
||||
if(!RI_GetDesktopMode(pwidth, pheight))
|
||||
{
|
||||
R_Printf( PRINT_ALL, " can't detect mode\n" );
|
||||
return rserr_invalid_mode;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
R_Printf(PRINT_ALL, " %d %d\n", *pwidth, *pheight);
|
||||
}
|
||||
|
||||
if (!ri.GLimp_InitGraphics(fullscreen, pwidth, pheight))
|
||||
{
|
||||
|
@ -1751,11 +1763,11 @@ R_DrawBeam(entity_t *e)
|
|||
vec3_t direction, normalized_direction;
|
||||
vec3_t start_points[NUM_BEAM_SEGS], end_points[NUM_BEAM_SEGS];
|
||||
vec3_t oldorigin, origin;
|
||||
|
||||
|
||||
GLfloat vtx[3*NUM_BEAM_SEGS*4];
|
||||
unsigned int index_vtx = 0;
|
||||
unsigned int pointb;
|
||||
|
||||
|
||||
oldorigin[0] = e->oldorigin[0];
|
||||
oldorigin[1] = e->oldorigin[1];
|
||||
oldorigin[2] = e->oldorigin[2];
|
||||
|
|
|
@ -124,7 +124,7 @@ int RI_PrepareForWindow(void)
|
|||
|
||||
return SDL_WINDOW_OPENGL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Enables or disabes the vsync.
|
||||
*/
|
||||
|
@ -242,3 +242,27 @@ RI_ShutdownContext(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Detect default desktop mode
|
||||
*/
|
||||
qboolean
|
||||
RI_GetDesktopMode(int *pwidth, int *pheight)
|
||||
{
|
||||
// Declare display mode structure to be filled in.
|
||||
SDL_DisplayMode current;
|
||||
|
||||
// We can't get desktop where we start, so use first desktop
|
||||
if(SDL_GetDesktopDisplayMode(0, ¤t) != 0)
|
||||
{
|
||||
// In case of error...
|
||||
R_Printf(PRINT_ALL, "Can't detect default desktop mode: %s\n",
|
||||
SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
*pwidth = current.w;
|
||||
*pheight = current.h;
|
||||
R_Printf(PRINT_ALL, " %dx%dpx @ %dhz.\n",
|
||||
current.w, current.h, current.refresh_rate);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -392,4 +392,9 @@ void RI_ShutdownContext(void);
|
|||
*/
|
||||
void *RI_GetProcAddress (const char* proc);
|
||||
|
||||
/*
|
||||
* Detect default desktop mode
|
||||
*/
|
||||
qboolean RI_GetDesktopMode(int *pwidth, int *pheight);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -331,13 +331,26 @@ SetMode_impl(int *pwidth, int *pheight, int mode, int fullscreen)
|
|||
|
||||
/* mode -1 is not in the vid mode table - so we keep the values in pwidth
|
||||
and pheight and don't even try to look up the mode info */
|
||||
if ((mode != -1) && !ri.Vid_GetModeInfo(pwidth, pheight, mode))
|
||||
if ((mode >= 0) && !ri.Vid_GetModeInfo(pwidth, pheight, mode))
|
||||
{
|
||||
R_Printf(PRINT_ALL, " invalid mode\n");
|
||||
return rserr_invalid_mode;
|
||||
}
|
||||
|
||||
R_Printf(PRINT_ALL, " %d %d\n", *pwidth, *pheight);
|
||||
/* We trying to get resolution from desktop */
|
||||
if (mode == -2)
|
||||
{
|
||||
if(!GL3_GetDesktopMode(pwidth, pheight))
|
||||
{
|
||||
R_Printf( PRINT_ALL, " can't detect mode\n" );
|
||||
return rserr_invalid_mode;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
R_Printf(PRINT_ALL, " %d %d\n", *pwidth, *pheight);
|
||||
}
|
||||
|
||||
|
||||
if (!ri.GLimp_InitGraphics(fullscreen, pwidth, pheight))
|
||||
{
|
||||
|
|
|
@ -341,3 +341,27 @@ void GL3_ShutdownContext()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Detect default desktop mode
|
||||
*/
|
||||
qboolean
|
||||
GL3_GetDesktopMode(int *pwidth, int *pheight)
|
||||
{
|
||||
// Declare display mode structure to be filled in.
|
||||
SDL_DisplayMode current;
|
||||
|
||||
// We can't get desktop where we start, so use first desktop
|
||||
if(SDL_GetDesktopDisplayMode(0, ¤t) != 0)
|
||||
{
|
||||
// In case of error...
|
||||
R_Printf(PRINT_ALL, "Can't detect default desktop mode: %s\n",
|
||||
SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
*pwidth = current.w;
|
||||
*pheight = current.h;
|
||||
R_Printf(PRINT_ALL, " %dx%dpx @ %dhz.\n",
|
||||
current.w, current.h, current.refresh_rate);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -360,6 +360,7 @@ extern qboolean GL3_IsVsyncActive(void);
|
|||
extern void GL3_EndFrame(void);
|
||||
extern void GL3_SetVsync(void);
|
||||
extern void GL3_ShutdownContext(void);
|
||||
extern qboolean GL3_GetDesktopMode(int *pwidth, int *pheight);
|
||||
|
||||
// gl3_misc.c
|
||||
extern void GL3_InitParticleTexture(void);
|
||||
|
|
|
@ -1766,6 +1766,30 @@ RE_EndFrame (void)
|
|||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Detect current Mode
|
||||
*/
|
||||
qboolean
|
||||
SWimp_GetDesktopMode(int *pwidth, int *pheight)
|
||||
{
|
||||
// Declare display mode structure to be filled in.
|
||||
SDL_DisplayMode current;
|
||||
|
||||
// We can't get desktop where we start, so use first desktop
|
||||
if(SDL_GetDesktopDisplayMode(0, ¤t) != 0)
|
||||
{
|
||||
// In case of error...
|
||||
R_Printf(PRINT_ALL, "Can't detect default desktop mode: %s\n",
|
||||
SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
*pwidth = current.w;
|
||||
*pheight = current.h;
|
||||
R_Printf(PRINT_ALL, " %dx%dpx @ %dhz.\n",
|
||||
current.w, current.h, current.refresh_rate);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
** SWimp_SetMode
|
||||
*/
|
||||
|
@ -1776,13 +1800,25 @@ SWimp_SetMode(int *pwidth, int *pheight, int mode, int fullscreen )
|
|||
|
||||
R_Printf (PRINT_ALL, "setting mode %d:", mode );
|
||||
|
||||
if ((mode != -1) && !ri.Vid_GetModeInfo( pwidth, pheight, mode ) )
|
||||
if ((mode >= 0) && !ri.Vid_GetModeInfo( pwidth, pheight, mode ) )
|
||||
{
|
||||
R_Printf( PRINT_ALL, " invalid mode\n" );
|
||||
return rserr_invalid_mode;
|
||||
}
|
||||
|
||||
R_Printf( PRINT_ALL, " %d %d\n", *pwidth, *pheight);
|
||||
/* We trying to get resolution from desktop */
|
||||
if (mode == -2)
|
||||
{
|
||||
if(!SWimp_GetDesktopMode(pwidth, pheight))
|
||||
{
|
||||
R_Printf( PRINT_ALL, " can't detect mode\n" );
|
||||
return rserr_invalid_mode;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
R_Printf(PRINT_ALL, " %d %d\n", *pwidth, *pheight);
|
||||
}
|
||||
|
||||
if (!ri.GLimp_InitGraphics(fullscreen, pwidth, pheight))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue