From 968b469872b265fa06decf3c371d7c11cc44e2bc Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Sun, 18 Dec 2011 16:27:14 +0000 Subject: [PATCH] gl_vidsdl.c: comment out the rest of vid_refreshrate usage which isn't supported. (VID_SetMode): check whether SDL_SetVideoMode() actually succeeded. otherwise we just segfault. noticed by Sander. git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@530 af15c1b1-3010-417e-b628-4374ebc0bcbd --- Quake/gl_vidsdl.c | 87 ++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 46 deletions(-) diff --git a/Quake/gl_vidsdl.c b/Quake/gl_vidsdl.c index 726ae954..d1502bfe 100644 --- a/Quake/gl_vidsdl.c +++ b/Quake/gl_vidsdl.c @@ -20,7 +20,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// gl_vidnt.c -- NT GL vid component +// gl_vidsdl.c -- SDL GL vid component #include "quakedef.h" #include "bgmusic.h" @@ -138,7 +138,7 @@ cvar_t vid_fullscreen = {"vid_fullscreen", "0", true}; // QuakeSpasm, was "1" cvar_t vid_width = {"vid_width", "800", true}; // QuakeSpasm, was 640 cvar_t vid_height = {"vid_height", "600", true}; // QuakeSpasm, was 480 cvar_t vid_bpp = {"vid_bpp", "16", true}; -cvar_t vid_refreshrate = {"vid_refreshrate", "60", true}; +//cvar_t vid_refreshrate = {"vid_refreshrate", "60", true}; cvar_t vid_vsync = {"vid_vsync", "0", true}; //johnfitz @@ -210,7 +210,7 @@ void VID_Gamma_f (void) oldgamma = vid_gamma.value; - for (i=0; i<256; i++) + for (i = 0; i < 256; i++) { vid_gamma_red[i] = CLAMP(0, (int) (255 * pow ((i+0.5)/255.5, vid_gamma.value) + 0.5), 255) << 8; @@ -244,7 +244,6 @@ VID_SetMode int VID_SetMode (int modenum) { int temp; - qboolean stat = false; Uint32 flags = SDL_DEFAULT_FLAGS; char caption[50]; @@ -285,17 +284,14 @@ int VID_SetMode (int modenum) draw_context = SDL_SetVideoMode(modelist[modenum].width, modelist[modenum].height, modelist[modenum].bpp, flags); - stat = true; } else { draw_context = SDL_SetVideoMode(modelist[modenum].width, modelist[modenum].height, modelist[modenum].bpp, flags); - stat = true; } modestate = MODE_WINDOWED; - // TODO set icon and title } else if (modelist[modenum].type == MODE_FULLSCREEN_DEFAULT) { @@ -303,7 +299,6 @@ int VID_SetMode (int modenum) draw_context = SDL_SetVideoMode(modelist[modenum].width, modelist[modenum].height, modelist[modenum].bpp, flags); - stat = true; modestate = MODE_FULLSCREEN_DEFAULT; } else @@ -311,12 +306,11 @@ int VID_SetMode (int modenum) Sys_Error ("VID_SetMode: Bad mode type in modelist"); } - if (!stat) + if (!draw_context) { Sys_Error ("Couldn't set video mode"); } - //kristian -- set window caption sprintf(caption, "QuakeSpasm %1.2f.%d", (float)FITZQUAKE_VERSION, QUAKESPASM_VER_PATCH); SDL_WM_SetCaption(caption, caption); @@ -379,7 +373,7 @@ void VID_Restart (void) // if (vid_fullscreen.value) { - for (i=1; iwidth || lastheight != pv->height || lastbpp != pv->bpp) { - if (count>0) + if (count > 0) Con_SafePrintf ("\n"); Con_SafePrintf (" %4i x %4i x %i", pv->width, pv->height, pv->bpp); lastwidth = pv->width; @@ -1297,7 +1291,7 @@ void VID_Init (void) { height = Q_atoi(com_argv[p+1]); - for (i=1, vid_default=0 ; i=vid_menu_nummodes) + i += dir; + if (i >= vid_menu_nummodes) i = 0; - else if (i<0) + else if (i < 0) i = vid_menu_nummodes-1; } @@ -1602,22 +1596,22 @@ void VID_Menu_ChooseNextBpp (int dir) { int i; - for (i=0;i=vid_menu_numbpps) + i += dir; + if (i >= vid_menu_numbpps) i = 0; - else if (i<0) + else if (i < 0) i = vid_menu_numbpps-1; } @@ -1636,22 +1630,22 @@ void VID_Menu_ChooseNextRate (int dir) #if 0 /* not implemented for SDL */ int i; - for (i=0;i=vid_menu_numrates) + i += dir; + if (i >= vid_menu_numrates) i = 0; - else if (i<0) + else if (i < 0) i = vid_menu_numrates-1; } @@ -1858,3 +1852,4 @@ void VID_Menu_f (void) //set up bpp and rate lists based on current cvars VID_Menu_RebuildBppList (); } +