copypasta'd sdl gamma stuff from ioquake3