X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=vid_glx.c;h=96bf36f26d51d0b2dd2a7e50a55ae22cc4212cb2;hb=b3f5f964484b851ef9eb6b714780210693462b4c;hp=eab081aad9cc7f655986244d7e6b12ce2fe4fb79;hpb=eabf1215930a0d26f23c1c83cb36da40710b235f;p=xonotic%2Fdarkplaces.git diff --git a/vid_glx.c b/vid_glx.c index eab081aa..96bf36f2 100644 --- a/vid_glx.c +++ b/vid_glx.c @@ -17,12 +17,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -//#include -//#include -//#include -//#include -//#include -//#include #include #include @@ -93,6 +87,8 @@ static qboolean mouse_avail = true; static qboolean vid_usingmouse = false; static qboolean vid_usingvsync = false; static qboolean vid_usevsync = false; +static qboolean vid_x11_hardwaregammasupported = false; +static int vid_x11_gammarampsize = 0; static float mouse_x, mouse_y; static int p_mouse_x, p_mouse_y; @@ -197,6 +193,7 @@ static int XLateKey(XKeyEvent *ev, char *ascii) case XK_Alt_L: case XK_Meta_L: + case XK_ISO_Level3_Shift: case XK_Alt_R: case XK_Meta_R: key = K_ALT; break; @@ -290,7 +287,8 @@ static void IN_Activate (qboolean grab) #endif XWarpPointer(vidx11_display, None, win, 0, 0, 0, 0, vid.width / 2, vid.height / 2); - XGrabKeyboard(vidx11_display, win, False, GrabModeAsync, GrabModeAsync, CurrentTime); + if (vid_grabkeyboard.integer) + XGrabKeyboard(vidx11_display, win, False, GrabModeAsync, GrabModeAsync, CurrentTime); mouse_x = mouse_y = 0; cl_ignoremousemove = true; @@ -437,13 +435,11 @@ static void HandleEvents(void) case MapNotify: // window restored vid_hidden = false; - vid_activewindow = false; VID_RestoreSystemGamma(); break; case UnmapNotify: // window iconified/rolledup/whatever vid_hidden = true; - vid_activewindow = false; VID_RestoreSystemGamma(); break; case FocusIn: @@ -496,7 +492,7 @@ static int GL_OpenLibrary(const char *name) Con_Printf("Unable to open symbol list for %s\n", name); return false; } - strcpy(gl_driver, name); + strlcpy(gl_driver, name, sizeof(gl_driver)); return true; } @@ -561,7 +557,6 @@ void InitSig(void) void VID_Finish (qboolean allowmousegrab) { - int rampsize; qboolean vid_usemouse; vid_usevsync = vid_vsync.integer && !cls.timedemo && gl_videosyncavailable; @@ -572,9 +567,9 @@ void VID_Finish (qboolean allowmousegrab) Con_Print("glXSwapIntervalSGI didn't accept the vid_vsync change, it will take effect on next vid_restart (GLX_SGI_swap_control does not allow turning off vsync)\n"); } -// handle the mouse state when windowed if that's changed + // handle the mouse state when windowed if that's changed vid_usemouse = false; - if (allowmousegrab && vid_mouse.integer && !key_consoleactive && !cls.demoplayback) + if (allowmousegrab && vid_mouse.integer && !key_consoleactive && (key_dest != key_game || !cls.demoplayback)) vid_usemouse = true; if (!vid_activewindow) vid_usemouse = false; @@ -584,13 +579,16 @@ void VID_Finish (qboolean allowmousegrab) if (r_render.integer) { + CHECKGLERROR if (r_speeds.integer || gl_finish.integer) - qglFinish(); - qglXSwapBuffers(vidx11_display, win); + { + qglFinish();CHECKGLERROR + } + qglXSwapBuffers(vidx11_display, win);CHECKGLERROR } - if(XF86VidModeGetGammaRampSize(vidx11_display, vidx11_screen, &rampsize)) - VID_UpdateGamma(false, rampsize); + if (vid_x11_hardwaregammasupported) + VID_UpdateGamma(false, vid_x11_gammarampsize); } int VID_SetGamma(unsigned short *ramps, int rampsize) @@ -615,7 +613,7 @@ void VID_Init(void) mouse_avail = false; } -void VID_BuildGLXAttrib(int *attrib, int stencil) +void VID_BuildGLXAttrib(int *attrib, qboolean stencil, qboolean stereobuffer) { *attrib++ = GLX_RGBA; *attrib++ = GLX_RED_SIZE;*attrib++ = 1; @@ -629,10 +627,12 @@ void VID_BuildGLXAttrib(int *attrib, int stencil) *attrib++ = GLX_STENCIL_SIZE;*attrib++ = 8; *attrib++ = GLX_ALPHA_SIZE;*attrib++ = 1; } + if (stereobuffer) + *attrib++ = GLX_STEREO; *attrib++ = None; } -int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate) +int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate, int stereobuffer) { int i; int attrib[32]; @@ -690,7 +690,7 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate return false; } - VID_BuildGLXAttrib(attrib, bpp == 32); + VID_BuildGLXAttrib(attrib, bpp == 32, stereobuffer); visinfo = qglXChooseVisual(vidx11_display, vidx11_screen, attrib); if (!visinfo) { @@ -837,12 +837,27 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate vid_usingvsync = false; vid_hidden = false; vid_activewindow = true; + vid_x11_hardwaregammasupported = XF86VidModeGetGammaRampSize(vidx11_display, vidx11_screen, &vid_x11_gammarampsize) != 0; GL_Init(); return true; } void Sys_SendKeyEvents(void) { + static qboolean sound_active = true; + + // enable/disable sound on focus gain/loss + if (!vid_activewindow && sound_active) + { + S_BlockSound (); + sound_active = false; + } + else if (vid_activewindow && !sound_active) + { + S_UnblockSound (); + sound_active = true; + } + HandleEvents(); }