X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=vid_glx.c;h=de1ac666dc29f00015a58f0553f11f7d28e0f4e8;hb=14b7453edd10760d5d45735f392f8ae7277e05c6;hp=c510104106e5e117785b129148da2c3a8f859b4c;hpb=d9919887fed8a056fb3437562d649baf8ced2297;p=xonotic%2Fdarkplaces.git diff --git a/vid_glx.c b/vid_glx.c index c5101041..de1ac666 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; @@ -437,13 +434,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 +491,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; } @@ -571,9 +566,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; @@ -583,32 +578,26 @@ 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 (vid_x11_hardwaregammasupported) + VID_UpdateGamma(false, vid_x11_gammarampsize); } -int VID_SetGamma(unsigned short *ramps) +int VID_SetGamma(unsigned short *ramps, int rampsize) { - int rampsize; - // FIXME: it would be good to generate ramps of the size reported by X, - // for instance Quadro cards seem to use 1024 color ramps not 256 - if(!XF86VidModeGetGammaRampSize(vidx11_display, vidx11_screen, &rampsize)) - return 0; - if(rampsize != 256) - return 0; - return XF86VidModeSetGammaRamp(vidx11_display, vidx11_screen, 256, ramps, ramps + 256, ramps + 512); + return XF86VidModeSetGammaRamp(vidx11_display, vidx11_screen, rampsize, ramps, ramps + rampsize, ramps + rampsize*2); } -int VID_GetGamma(unsigned short *ramps) +int VID_GetGamma(unsigned short *ramps, int rampsize) { - int rampsize; - if(!XF86VidModeGetGammaRampSize(vidx11_display, vidx11_screen, &rampsize)) - return 0; - if(rampsize != 256) - return 0; - return XF86VidModeGetGammaRamp(vidx11_display, vidx11_screen, 256, ramps, ramps + 256, ramps + 512); + return XF86VidModeGetGammaRamp(vidx11_display, vidx11_screen, rampsize, ramps, ramps + rampsize, ramps + rampsize*2); } void VID_Init(void) @@ -623,7 +612,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; @@ -637,10 +626,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]; @@ -698,7 +689,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) { @@ -845,12 +836,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(); }