From: divverent Date: Fri, 9 Nov 2007 21:36:54 +0000 (+0000) Subject: update Blub's SDL patch X-Git-Tag: xonotic-v0.1.0preview~2804 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=commitdiff_plain;h=32ad538b7b2fb3349717631863dfdfe61358fe6c update Blub's SDL patch git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7677 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/vid.h b/vid.h index 10bf2bf1..1a236640 100644 --- a/vid.h +++ b/vid.h @@ -54,6 +54,8 @@ extern cvar_t vid_refreshrate; extern cvar_t vid_vsync; extern cvar_t vid_mouse; extern cvar_t vid_grabkeyboard; +extern cvar_t vid_stick_mouse; +extern cvar_t vid_resizable; extern cvar_t vid_minwidth; extern cvar_t vid_minheight; diff --git a/vid_sdl.c b/vid_sdl.c index 43096f39..39755e52 100644 --- a/vid_sdl.c +++ b/vid_sdl.c @@ -49,7 +49,6 @@ cvar_t joy_sensitivitypitch = {0, "joy_sensitivitypitch", "1", "movement multipl cvar_t joy_sensitivityyaw = {0, "joy_sensitivityyaw", "-1", "movement multiplier"}; cvar_t joy_sensitivityroll = {0, "joy_sensitivityroll", "1", "movement multiplier"}; - static qboolean vid_usingmouse; static qboolean vid_isfullscreen; static int vid_numjoysticks = 0; @@ -58,8 +57,7 @@ static SDL_Joystick *vid_joysticks[MAX_JOYSTICKS]; static int win_half_width = 50; static int win_half_height = 50; -static int stick_mouse = 0; -static int grab_input = 1; +static int video_bpp, video_flags; static SDL_Surface *screen; @@ -244,7 +242,7 @@ static void IN_Activate( qboolean grab ) { vid_usingmouse = true; cl_ignoremousemove = true; - if(grab_input) { + if(vid_grabkeyboard.integer) { SDL_WM_GrabInput( SDL_GRAB_ON ); } SDL_ShowCursor( SDL_DISABLE ); @@ -256,7 +254,7 @@ static void IN_Activate( qboolean grab ) { vid_usingmouse = false; cl_ignoremousemove = true; - if(grab_input) { + if(vid_grabkeyboard.integer) { SDL_WM_GrabInput( SDL_GRAB_OFF ); } SDL_ShowCursor( SDL_ENABLE ); @@ -284,7 +282,7 @@ void IN_Move( void ) int x, y; if( vid_usingmouse ) { - if(stick_mouse) + if(vid_stick_mouse.integer) { // have the mouse stuck in the middle, example use: prevent expose effect of beryl during the game when not using // window grabbing. --blub @@ -404,6 +402,14 @@ void Sys_SendKeyEvents( void ) if (event.jbutton.button < 48) Key_Event( event.jbutton.button + (event.jbutton.button < 16 ? K_JOY1 : K_AUX1 - 16), 0, (event.jbutton.state == SDL_PRESSED) ); break; + case SDL_VIDEORESIZE: + if(vid_resizable.integer < 2) + { + vid.width = event.resize.w; + vid.height = event.resize.h; + SDL_SetVideoMode(vid.width, vid.height, video_bpp, video_flags); + } + break; } // enable/disable sound on focus gain/loss @@ -522,6 +528,9 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate win_half_width = width>>1; win_half_height = height>>1; + if(vid_resizable.integer) + flags |= SDL_RESIZABLE; + VID_OutputVersion(); /* @@ -545,18 +554,6 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate Con_Printf("Unable to load GL driver \"%s\": %s\n", drivername, SDL_GetError()); return false; } - - - if(COM_CheckParm("-resizable")) { - flags |= SDL_RESIZABLE; - } - - stick_mouse = COM_CheckParm("-stick_mouse"); - if(COM_CheckParm("-no_input_grabbing")) { - grab_input = 0; - } else { - grab_input = 1; - } if ((qglGetString = (const GLubyte* (GLAPIENTRY *)(GLenum name))GL_GetProcAddress("glGetString")) == NULL) { @@ -594,6 +591,8 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate if (stereobuffer) SDL_GL_SetAttribute (SDL_GL_STEREO, 1); + video_bpp = bpp; + video_flags = flags; screen = SDL_SetVideoMode(width, height, bpp, flags); if (screen == NULL) @@ -645,7 +644,7 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate vid_activewindow = false; vid_usingmouse = false; - if(!grab_input) + if(!vid_grabkeyboard.integer) SDL_WM_GrabInput(SDL_GRAB_OFF); return true; } diff --git a/vid_shared.c b/vid_shared.c index 539ff146..3ea646e7 100644 --- a/vid_shared.c +++ b/vid_shared.c @@ -93,6 +93,9 @@ cvar_t vid_minheight = {0, "vid_minheight", "0", "minimum vid_height that is acc cvar_t gl_combine = {0, "gl_combine", "1", "faster rendering by using GL_ARB_texture_env_combine extension (part of OpenGL 1.3 and above)"}; cvar_t gl_finish = {0, "gl_finish", "0", "make the cpu wait for the graphics processor at the end of each rendered frame (can help with strange input or video lag problems on some machines)"}; +cvar_t vid_stick_mouse = {CVAR_SAVE, "vid_stick_mouse", "0", "have the mouse stuck in the center of the screen" }; +cvar_t vid_resizable = {CVAR_SAVE, "vid_resizable", "0", "0: window not resizable, 1: resizable, 2: window can be resized but the framebuffer isn't adjusted" }; + cvar_t v_gamma = {CVAR_SAVE, "v_gamma", "1", "inverse gamma correction value, a brightness effect that does not affect white or black, and tends to make the image grey and dull"}; cvar_t v_contrast = {CVAR_SAVE, "v_contrast", "1", "brightness of white (values above 1 give a brighter image with increased color saturation, unlike v_gamma)"}; cvar_t v_brightness = {CVAR_SAVE, "v_brightness", "0", "brightness of black, useful for monitors that are too dark"}; @@ -1001,6 +1004,8 @@ void VID_Shared_Init(void) Cvar_RegisterVariable(&vid_vsync); Cvar_RegisterVariable(&vid_mouse); Cvar_RegisterVariable(&vid_grabkeyboard); + Cvar_RegisterVariable(&vid_stick_mouse); + Cvar_RegisterVariable(&vid_resizable); Cvar_RegisterVariable(&vid_minwidth); Cvar_RegisterVariable(&vid_minheight); Cvar_RegisterVariable(&gl_combine);