gl_vidsdl.c: make VID_SetMode independent from "modelist"

git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@809 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
Sander van Dijk 2013-02-18 19:19:32 +00:00
parent 083c27abce
commit dd40be29eb

View file

@ -201,21 +201,19 @@ static void VID_Gamma_Init (void)
VID_SetMode VID_SetMode
================ ================
*/ */
static int VID_SetMode (int modenum) static int VID_SetMode (int width, int height, int bpp, qboolean fullscreen)
{ {
int temp; int temp;
Uint32 flags = SDL_DEFAULT_FLAGS; Uint32 flags = SDL_DEFAULT_FLAGS;
char caption[50]; char caption[50];
// TODO: check if video mode is supported using SDL_VideoModeOk if (fullscreen)
if ((windowed && (modenum != 0)) || flags |= SDL_FULLSCREEN;
(!windowed && (modenum < 1)) ||
(!windowed && (modenum >= nummodes)))
{
Sys_Error ("Bad video mode\n");
}
// so Con_Printfs don't mess us up by forcing vid and snd updates if (!SDL_VideoModeOK(width, height, bpp, flags))
Sys_Error ("Bad video mode\n");
// so Con_Printfs don't mess us up by forcing vid and snd updates
temp = scr_disabled_for_loading; temp = scr_disabled_for_loading;
scr_disabled_for_loading = true; scr_disabled_for_loading = true;
@ -227,41 +225,23 @@ static int VID_SetMode (int modenum)
// //
gl_swap_control = true; gl_swap_control = true;
if (SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, (vid_vsync.value) ? 1 : 0) == -1) if (SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, (vid_vsync.value) ? 1 : 0) == -1)
{
gl_swap_control = false; gl_swap_control = false;
}
if (modelist[modenum].type == MS_WINDOWED) draw_context = SDL_SetVideoMode(width, height, bpp, flags);
{
modestate = MS_WINDOWED;
}
else if (modelist[modenum].type == MS_FULLSCREEN)
{
flags |= SDL_FULLSCREEN;
modestate = MS_FULLSCREEN;
}
else
{
Sys_Error ("VID_SetMode: Bad mode type in modelist");
}
draw_context = SDL_SetVideoMode(modelist[modenum].width,
modelist[modenum].height,
modelist[modenum].bpp, flags);
if (!draw_context) if (!draw_context)
{
Sys_Error ("Couldn't set video mode"); Sys_Error ("Couldn't set video mode");
}
sprintf(caption, "QuakeSpasm %1.2f.%d", (float)FITZQUAKE_VERSION, QUAKESPASM_VER_PATCH); sprintf(caption, "QuakeSpasm %1.2f.%d", (float)FITZQUAKE_VERSION, QUAKESPASM_VER_PATCH);
SDL_WM_SetCaption(caption, caption); SDL_WM_SetCaption(caption, caption);
vid.width = modelist[modenum].width; vid.width = draw_context->w;
vid.height = modelist[modenum].height; vid.height = draw_context->h;
vid.conwidth = vid.width & 0xFFFFFFF8; vid.conwidth = vid.width & 0xFFFFFFF8;
vid.conheight = vid.conwidth * vid.height / vid.width; vid.conheight = vid.conwidth * vid.height / vid.width;
vid.numpages = 2; vid.numpages = 2;
modestate = draw_context->flags & SDL_FULLSCREEN ? MS_FULLSCREEN : MS_WINDOWED;
CDAudio_Resume (); CDAudio_Resume ();
BGM_Resume (); BGM_Resume ();
scr_disabled_for_loading = temp; scr_disabled_for_loading = temp;
@ -270,9 +250,9 @@ static int VID_SetMode (int modenum)
ClearAllStates (); ClearAllStates ();
Con_SafePrintf ("Video mode %dx%dx%d initialized\n", Con_SafePrintf ("Video mode %dx%dx%d initialized\n",
modelist[modenum].width, draw_context->w,
modelist[modenum].height, draw_context->h,
modelist[modenum].bpp); draw_context->format->BitsPerPixel);
vid.recalc_refdef = 1; vid.recalc_refdef = 1;
@ -354,7 +334,10 @@ static void VID_Restart (void)
// //
// set new mode // set new mode
// //
VID_SetMode (vid_default); VID_SetMode (modelist[vid_default].width,
modelist[vid_default].height,
modelist[vid_default].bpp,
modelist[vid_default].type == MS_FULLSCREEN);
GL_Init (); GL_Init ();
TexMgr_ReloadImages (); TexMgr_ReloadImages ();
@ -1136,7 +1119,10 @@ void VID_Init (void)
// set window icon // set window icon
PL_SetWindowIcon(); PL_SetWindowIcon();
VID_SetMode (vid_default); VID_SetMode (modelist[vid_default].width,
modelist[vid_default].height,
modelist[vid_default].bpp,
modelist[vid_default].type == MS_FULLSCREEN);
GL_Init (); GL_Init ();
GL_SetupState (); GL_SetupState ();