On Tue, May 03, 2011 at 03:47:30PM +0200, Jasper Lievisse Adriaanse wrote:
> On Tue, May 03, 2011 at 10:26:16AM +0200, Alf Schlichting wrote:
> > On Mon, May 02, 2011 at 10:36:10PM +0300, Antti Harri wrote:
> > > On Monday 02 May 2011 20:33:22 Jasper Lievisse Adriaanse wrote:
> > > > On Mon, May 02, 2011 at 06:10:12PM +0300, Antti Harri wrote:
> > > > > On Monday 02 May 2011 14:53:55 Jasper Lievisse Adriaanse wrote:
> > > > > > Hi,
> > > > > >
> > > > > > Here's an update for openarena to the latest patch release. Any
> > > > > > testers? ;-) OK?
> > > > >
> > > > > Lightly tested on amd64.
> > > > >
> > > > > Display->brightness is not working, the screen is very dark by 
> > > > > default.
> > > >
> > > > I noticed the brightness thing on mac os x too...
> > > 
> > > This seems to be a problem in SDL that was caused by a X.org update.
> > > http://bugzilla.libsdl.org/show_bug.cgi?id=971
> > > 
> > 
> > fyi, the patch posted in that threat works fine, I use it all the time
> > on my linux q3 machines and used it on OpenBSD iirc (don't have a gfx card 
> > for
> > OpenBSD atm). 
> > 
> > Maybe worth to include it in OpenBSDs SDL port? 
> We could, though it's going to be removed for the update to 1.3.x anyway.
> 
> Jake, what do you think?
>  
> > > It's not perfect but this can be worked around by calling xgamma or 
> > > xrandr 
> > > before starting the game.
> > > 
> > > >
> > > > > I experience sound stuttering when aucat is on. Tried default buffer 
> > > > > size
> > > > > and -b 2048.
> > > > >
> > > > > Same thing with the 0.8.1p1 though.
> > > >
> > > > Guess it's going in then ;-)
> > > 
> > > 
> > > -- 
> > > Antti Harri
> > > 
> > 
> 
> -- 
> Cheers,
> Jasper
> 
> "Capable, generous men do not create victims, they nurture them."
> 

Here's the diff btw, it's much better now with OA.

-- 
Cheers,
Jasper

"Capable, generous men do not create victims, they nurture them."

Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/sdl/Makefile,v
retrieving revision 1.78
diff -p -u -r1.78 Makefile
--- Makefile    15 Nov 2010 19:46:09 -0000      1.78
+++ Makefile    3 May 2011 14:12:23 -0000
@@ -5,7 +5,7 @@ COMMENT=        cross-platform multimedia libra
 VERSION=       1.2.13
 DISTNAME=      SDL-${VERSION}
 PKGNAME=       ${DISTNAME:L}
-REVISION =     14
+REVISION =     15
 CATEGORIES=    devel
 
 HOMEPAGE=      http://www.libsdl.org/
Index: patches/patch-src_video_x11_SDL_x11sym_h
===================================================================
RCS file: patches/patch-src_video_x11_SDL_x11sym_h
diff -N patches/patch-src_video_x11_SDL_x11sym_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_video_x11_SDL_x11sym_h    3 May 2011 14:12:23 -0000
@@ -0,0 +1,24 @@
+$OpenBSD$
+
+Add support for XRandR and VidMode gamma ramps.
+From upstream bz: http://bugzilla.libsdl.org/show_bug.cgi?id=971
+
+Will not be part of SDL 1.3 to gamma API removal.
+
+--- src/video/x11/SDL_x11sym.h.orig    Mon Dec 31 05:48:13 2007
++++ src/video/x11/SDL_x11sym.h Tue May  3 15:12:12 2011
+@@ -190,6 +190,14 @@ SDL_X11_SYM(SizeID,XRRConfigCurrentConfiguration,(XRRS
+ SDL_X11_SYM(XRRScreenSize *,XRRConfigSizes,(XRRScreenConfiguration *config, 
int *nsizes),(config,nsizes),return)
+ SDL_X11_SYM(Status,XRRSetScreenConfig,(Display *dpy, XRRScreenConfiguration 
*config, Drawable draw, int size_index, Rotation rotation, Time 
timestamp),(dpy,config,draw,size_index,rotation,timestamp),return)
+ SDL_X11_SYM(void,XRRFreeScreenConfigInfo,(XRRScreenConfiguration 
*config),(config),)
++SDL_X11_SYM(XRRScreenResources *,XRRGetScreenResources,(Display *dpy, Window 
window),(dpy,window),return)
++SDL_X11_SYM(XRRScreenResources *,XRRGetScreenResourcesCurrent,(Display *dpy, 
Window window),(dpy,window),return)
++SDL_X11_SYM(void,XRRFreeScreenResources,(XRRScreenResources 
*resources),(resources),)
++SDL_X11_SYM(int,XRRGetCrtcGammaSize,(Display *dpy, RRCrtc 
crtc),(dpy,crtc),return)
++SDL_X11_SYM(XRRCrtcGamma *,XRRAllocGamma,(int size),(size),return)
++SDL_X11_SYM(void,XRRFreeGamma,(XRRCrtcGamma *gamma),(gamma),)
++SDL_X11_SYM(XRRCrtcGamma *,XRRGetCrtcGamma,(Display *dpy, RRCrtc 
crtc),(dpy,crtc),return)
++SDL_X11_SYM(void,XRRSetCrtcGamma,(Display *dpy, RRCrtc crtc, XRRCrtcGamma 
*gamma),(dpy,crtc,gamma),)
+ #endif
+ 
+ /* DPMS support */
Index: patches/patch-src_video_x11_SDL_x11video_c
===================================================================
RCS file: patches/patch-src_video_x11_SDL_x11video_c
diff -N patches/patch-src_video_x11_SDL_x11video_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_video_x11_SDL_x11video_c  3 May 2011 14:12:23 -0000
@@ -0,0 +1,288 @@
+$OpenBSD$
+
+Add support for XRandR and VidMode gamma ramps.
+From upstream bz: http://bugzilla.libsdl.org/show_bug.cgi?id=971
+
+Will not be part of SDL 1.3 to gamma API removal.
+
+--- src/video/x11/SDL_x11video.c.orig  Mon Dec 31 05:48:13 2007
++++ src/video/x11/SDL_x11video.c       Tue May  3 15:12:12 2011
+@@ -65,6 +65,9 @@ static int X11_ToggleFullScreen(_THIS, int on);
+ static void X11_UpdateMouse(_THIS);
+ static int X11_SetColors(_THIS, int firstcolor, int ncolors,
+                        SDL_Color *colors);
++static void X11_FreeSavedGammaRamp(_THIS);
++static int X11_RestoreGammaRamp(_THIS);
++static int X11_SaveGammaRamp(_THIS);
+ static int X11_SetGammaRamp(_THIS, Uint16 *ramp);
+ static void X11_VideoQuit(_THIS);
+ 
+@@ -665,6 +668,7 @@ static int X11_VideoInit(_THIS, SDL_PixelFormat *vform
+       if ( this->hidden->depth == 32 ) {
+               vformat->Amask = (0xFFFFFFFF & 
~(vformat->Rmask|vformat->Gmask|vformat->Bmask));
+       }
++      X11_SaveGammaRamp(this);
+       X11_SaveVidModeGamma(this);
+ 
+       /* Allow environment override of screensaver disable. */
+@@ -1429,11 +1433,249 @@ int X11_SetColors(_THIS, int firstcolor, int ncolors, 
+       return nrej == 0;
+ }
+ 
++void X11_FreeSavedGammaRamp(_THIS)
++{
++      int i;
++
++#if SDL_VIDEO_DRIVER_X11_XRANDR
++      if (gamma_ramp_saved_xrr) {
++              for ( i=0; i<gamma_ramp_saved_xrr_size; ++i ) {
++                      XRRFreeGamma(gamma_ramp_saved_xrr[i]);
++              }
++              SDL_free(gamma_ramp_saved_xrr);
++              gamma_ramp_saved_xrr = NULL;
++      }
++#endif
++
++#if SDL_VIDEO_DRIVER_X11_VIDMODE
++      if (gamma_ramp_saved_vm) {
++              SDL_free(gamma_ramp_saved_vm);
++              gamma_ramp_saved_vm = NULL;
++      }
++#endif
++}
++
++int X11_SaveGammaRamp(_THIS)
++{
++      int i;
++      Bool succeeded;
++
++      X11_FreeSavedGammaRamp(this);
++
++#if SDL_VIDEO_DRIVER_X11_XRANDR
++      if (use_xrandr) {
++              XRRScreenResources *resrc;
++
++              if (use_xrandr >= 103) {
++                      resrc = XRRGetScreenResourcesCurrent(SDL_Display, 
SDL_Root);
++              } else {
++                      resrc = XRRGetScreenResources(SDL_Display, SDL_Root);
++              }
++
++              if (resrc != NULL) {
++                      gamma_ramp_saved_xrr_size = resrc->ncrtc;
++                      gamma_ramp_saved_xrr = SDL_malloc(
++                                      sizeof(gamma_ramp_saved_xrr[0]) *
++                                      gamma_ramp_saved_xrr_size);
++              }
++
++              for ( i=0; resrc != NULL && i<resrc->ncrtc; ++i ) {
++                      gamma_ramp_saved_xrr[i] = XRRGetCrtcGamma(SDL_Display,
++                                      resrc->crtcs[i]);
++              }
++
++              if (resrc != NULL) {
++                      XRRFreeScreenResources(resrc);
++                      return(0);
++              }
++      }
++#endif /* SDL_VIDEO_DRIVER_X11_XRANDR */
++
++#if SDL_VIDEO_DRIVER_X11_VIDMODE
++      if (use_vidmode >= 200 && gamma_ramp_size == 0) {
++              succeeded = SDL_NAME(XF86VidModeGetGammaRampSize)(
++                              SDL_Display, SDL_Screen,
++                              &gamma_ramp_size);
++
++              if (!succeeded) {
++                      gamma_ramp_size = 0;
++              }
++      }
++
++      if (use_vidmode >= 200 && gamma_ramp_size > 0) {
++              gamma_ramp_saved_vm = SDL_malloc(
++                              sizeof(gamma_ramp_saved_vm[0]) *
++                              3 * gamma_ramp_size);
++
++              succeeded = SDL_NAME(XF86VidModeGetGammaRamp)(
++                              SDL_Display, SDL_Screen,
++                              gamma_ramp_size,
++                              gamma_ramp_saved_vm + 0*gamma_ramp_size,
++                              gamma_ramp_saved_vm + 1*gamma_ramp_size,
++                              gamma_ramp_saved_vm + 2*gamma_ramp_size);
++
++              if (!succeeded) {
++                      SDL_free(gamma_ramp_saved_vm);
++                      gamma_ramp_saved_vm = NULL;
++              } else {
++                      return(0);
++              }
++      }
++#endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */
++
++      return(-1);
++}
++
++int X11_RestoreGammaRamp(_THIS)
++{
++      int i;
++      Bool succeeded;
++
++#if SDL_VIDEO_DRIVER_X11_XRANDR
++      if (use_xrandr && gamma_ramp_saved_xrr != NULL) {
++              XRRScreenResources *resrc;
++
++              if (use_xrandr >= 103) {
++                      resrc = XRRGetScreenResourcesCurrent(SDL_Display, 
SDL_Root);
++              } else {
++                      resrc = XRRGetScreenResources(SDL_Display, SDL_Root);
++              }
++
++              for ( i=0; resrc != NULL && i<resrc->ncrtc && 
i<gamma_ramp_saved_xrr_size; ++i ) {
++                      XRRSetCrtcGamma(SDL_Display, resrc->crtcs[i],
++                                      gamma_ramp_saved_xrr[i]);
++              }
++
++              if (resrc != NULL) {
++                      XRRFreeScreenResources(resrc);
++                      return(0);
++              }
++      }
++#endif /* SDL_VIDEO_DRIVER_X11_XRANDR */
++
++#if SDL_VIDEO_DRIVER_X11_VIDMODE
++      if (use_vidmode >= 200 && gamma_ramp_saved_vm != NULL) {
++              succeeded = SDL_NAME(XF86VidModeSetGammaRamp)(
++                              SDL_Display, SDL_Screen,
++                              gamma_ramp_size,
++                              gamma_ramp_saved_vm + 0*gamma_ramp_size,
++                              gamma_ramp_saved_vm + 1*gamma_ramp_size,
++                              gamma_ramp_saved_vm + 2*gamma_ramp_size);
++
++              if (succeeded)
++                      return(0);
++      }
++#endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */
++
++      return(-1);
++}
++
+ int X11_SetGammaRamp(_THIS, Uint16 *ramp)
+ {
+-      int i, ncolors;
++      int i, j, ncolors;
+       XColor xcmap[256];
++      Bool succeeded;
+ 
++#if SDL_VIDEO_DRIVER_X11_XRANDR
++      if (use_xrandr) {
++              XRRCrtcGamma *gamma = NULL;
++              int gammasize = 0;
++              XRRScreenResources *resrc;
++
++              if (use_xrandr >= 103) {
++                      resrc = XRRGetScreenResourcesCurrent(SDL_Display, 
SDL_Root);
++              } else {
++                      resrc = XRRGetScreenResources(SDL_Display, SDL_Root);
++              }
++
++              /* Implementation Note:
++               * We try to make few assumptions here, notably:
++               *  - Ramp size can vary between crtcs
++               *    (which can happen when using multiple video cards)
++               *  - Ramp size (by index) can vary between calls
++               *    (which can happen if the window is moved to a new crtc)
++               */
++              for ( i=0; resrc != NULL && i<resrc->ncrtc; ++i ) {
++                      int crtcgs;
++
++                      crtcgs = XRRGetCrtcGammaSize(SDL_Display,
++                                      resrc->crtcs[i]);
++                      if (crtcgs != gammasize) {
++                              /* Size in this CRTC differs from last */
++                              if (gamma != NULL) {
++                                      XRRFreeGamma(gamma);
++                              }
++
++                              gammasize = crtcgs;
++                              gamma = XRRAllocGamma(gammasize);
++
++                              for ( j=0; j<gammasize; ++j ) {
++                                      gamma->red[j]   =
++                                              ramp[0*256+j*256/gammasize];
++                                      gamma->green[j] =
++                                              ramp[1*256+j*256/gammasize];
++                                      gamma->blue[j]  =
++                                              ramp[2*256+j*256/gammasize];
++                              }
++                      }
++
++                      XRRSetCrtcGamma(SDL_Display, resrc->crtcs[i], gamma);
++              }
++
++              if (gamma != NULL) {
++                      XRRFreeGamma(gamma);
++              }
++
++              if (resrc != NULL) {
++                      XRRFreeScreenResources(resrc);
++                      return(0);
++              }
++      }
++#endif /* SDL_VIDEO_DRIVER_X11_XRANDR */
++
++#if SDL_VIDEO_DRIVER_X11_VIDMODE
++      if (use_vidmode >= 200 && gamma_ramp_size == 0) {
++              succeeded = SDL_NAME(XF86VidModeGetGammaRampSize)(
++                              SDL_Display, SDL_Screen,
++                              &gamma_ramp_size);
++
++              if (!succeeded) {
++                      gamma_ramp_size = 0;
++              }
++      }
++
++      if (use_vidmode >= 200 && gamma_ramp_size > 0) {
++              Uint16 *sizedramp;
++
++              if (gamma_ramp_size == 256) {
++                      sizedramp = ramp;
++              } else {
++                      sizedramp = SDL_stack_alloc(Uint16, 3*gamma_ramp_size);
++                      if (sizedramp == NULL) {
++                              SDL_OutOfMemory();
++                              return(-1);
++                      }
++
++                      for ( i=0; i<gamma_ramp_size*3; ++i ) {
++                              sizedramp[i] = ramp[i * 256 / gamma_ramp_size];
++                      }
++              }
++
++              succeeded = SDL_NAME(XF86VidModeSetGammaRamp)(
++                              SDL_Display, SDL_Screen,
++                              gamma_ramp_size,
++                              sizedramp+0*256,
++                              sizedramp+1*256,
++                              sizedramp+2*256);
++
++              if (gamma_ramp_size != 256) {
++                      SDL_stack_free(sizedramp);
++              }
++
++              return(succeeded ? 0 : -1);
++      }
++#endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */
++
+       /* See if actually setting the gamma is supported */
+       if ( SDL_Visual->class != DirectColor ) {
+           SDL_SetError("Gamma correction not supported on this visual");
+@@ -1504,7 +1746,9 @@ void X11_VideoQuit(_THIS)
+               /* Restore gamma settings if they've changed */
+               if ( SDL_GetAppState() & SDL_APPACTIVE ) {
+                       X11_SwapVidModeGamma(this);
++                      X11_RestoreGammaRamp(this);
+               }
++              X11_FreeSavedGammaRamp(this);
+ 
+               /* Restore DPMS and screensaver settings */
+               X11_RestoreScreenSaver(this, SDL_Display, screensaver_timeout, 
dpms_enabled);
Index: patches/patch-src_video_x11_SDL_x11video_h
===================================================================
RCS file: patches/patch-src_video_x11_SDL_x11video_h
diff -N patches/patch-src_video_x11_SDL_x11video_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_video_x11_SDL_x11video_h  3 May 2011 14:12:23 -0000
@@ -0,0 +1,37 @@
+$OpenBSD$
+
+Add support for XRandR and VidMode gamma ramps.
+From upstream bz: http://bugzilla.libsdl.org/show_bug.cgi?id=971
+
+Will not be part of SDL 1.3 to gamma API removal.
+
+--- src/video/x11/SDL_x11video.h.orig  Mon Dec 31 05:48:13 2007
++++ src/video/x11/SDL_x11video.h       Tue May  3 15:12:12 2011
+@@ -122,12 +122,16 @@ struct SDL_PrivateVideoData {
+     XRRScreenConfiguration* screen_config;
+     int saved_size_id;
+     Rotation saved_rotation;
++    XRRCrtcGamma** gamma_ramp_saved_xrr;
++    int gamma_ramp_saved_xrr_size;
+ #endif
+ #if SDL_VIDEO_DRIVER_X11_VIDMODE
+     SDL_NAME(XF86VidModeModeInfo) saved_mode;
+     struct {
+         int x, y;
+     } saved_view;
++    int gamma_ramp_size;
++    Uint16* gamma_ramp_saved_vm;
+ #endif
+ #if SDL_VIDEO_DRIVER_X11_XME /* XiG XME fullscreen */
+     XiGMiscResolutionInfo saved_res;
+@@ -188,6 +192,10 @@ struct SDL_PrivateVideoData {
+ #define mouse_accel           (this->hidden->mouse_accel)
+ #define mouse_relative                (this->hidden->mouse_relative)
+ #define SDL_modelist          (this->hidden->modelist)
++#define gamma_ramp_size               (this->hidden->gamma_ramp_size)
++#define gamma_ramp_saved_vm   (this->hidden->gamma_ramp_saved_vm)
++#define gamma_ramp_saved_xrr  (this->hidden->gamma_ramp_saved_xrr)
++#define gamma_ramp_saved_xrr_size     
(this->hidden->gamma_ramp_saved_xrr_size)
+ #define xinerama_info         (this->hidden->xinerama_info)
+ #define saved_mode            (this->hidden->saved_mode)
+ #define saved_view            (this->hidden->saved_view)

Reply via email to