Page 1 of 1

Brightness problem

Posted: Wed Jun 07, 2006 9:04 pm
by gilly
I suddenly ran to a problem with gamma things:
I couldn't set brightness to over some 5 or 6 in the slider.

I think it was caused by either an update of xorg or an update of fglrx... well, anyways.. I tracked the problem to SDL_SetGamma (made a test program, which showed that it wasn't working)

In the end I found a testgamma.c in SDL-1.2.9 sources where I stealt this block of code:

Code: Select all

void CalculateGamma(double gamma, Uint16 *ramp)
{
	int i, value;

	gamma = 1.0 / gamma;
	for ( i=0; i<256; ++i ) {
		value = (int)(pow((double)i/256.0, gamma)*65535.0 + 0.5);
		if ( value > 65535 ) {
			value = 65535;
		}
		ramp[i] = (Uint16)value;
	}
}
I added that to SDLDisplay.cxx and modified the setGamma function as follows:

Code: Select all

void SDLWindow::setGamma(float gamma) {
    /*HECK THIS NEEDED THIS*/
  Uint16 ramp[256];
  CalculateGamma(gamma, ramp);
  int result = SDL_SetGammaRamp(ramp, ramp, ramp);
...
It seems to be working now, but I'm not sure if this is the right way :) (No, I didn't try to actually play yet, just checked that I could set the gamma brighter now)

Just informing, so that, if it occurs to someone else they can update their code too, or maybe you (devs) could add this to CVS ? (No, I'm not a guru with graphics things, and I'd need some explanation myself here of this)

Posted: Fri Jun 09, 2006 7:47 am
by gilly
Aha! I've done some more digging, and I think the bug is in the SDL-1.2.10... there was a SVN log where the committer had fixed some compiler warnings, but if I interpreted it correctly he had also modified the code logic crucially so, that over 1.0 gammas won't work... gonna ask them.

(The time matches too, I've updated SDL 3 days ago)
Just to tell you, maybe stay away from 1.2.10 for a while :) or use that code I posted in the initial post.

BTW. Should I post these somewhere else? If so, could someone move these somewhere else (and tell me where)... ;)

Posted: Wed Jun 21, 2006 9:41 am
by gilly
Final post to this thread (I guess)...

The bug was in SDL (1.2.10 and SVN).

SDL folks accepted a patch I sent them and it's in their SVN version now.