void HandleKeyPresses(void) { char k; k = gamemgl->LastKeyPressed(); if (k) { lastKey = k; if ((lastKey >= 'a' && lastKey <= 'z') || (lastKey >= 'A' && lastKey <= 'Z')) CheatKey(lastKey); } #ifdef _DEBUG // can't show stats unless in debug mode if (lastKey == 's') { showStats = 1 - showStats; lastKey = 0; } #endif if (lastKey == 'g') { k = GetGamma(); k++; if (k > 3) k = 0; gamemgl->GammaCorrect(k); SetGamma(k); lastKey = 0; } }
bool BaseV4L2VideoCapture::SetGamma(int32_t value) { //return v4l2_s_ctrl(V4L2_CID_GAMMA, value); if(_pVideoCaptureFiltersCapability->VerifyGamma(value)){ if(v4l2_s_ctrl(V4L2_CID_GAMMA, value)){ _pVideoCaptureFilters->gamma = GetGamma(); return true; } else return false; } else return false; }
OBUnitCell::LatticeType OBUnitCell::GetLatticeType() const { if (_lattice != Undefined) return _lattice; else if (_spaceGroup != NULL) return GetLatticeType(_spaceGroup->GetId()); double a = GetA(); double b = GetB(); double c = GetC(); double alpha = GetAlpha(); double beta = GetBeta(); double gamma = GetGamma(); unsigned int rightAngles = 0; if (IsApprox(alpha, 90.0, 1.0e-3)) rightAngles++; if (IsApprox(beta, 90.0, 1.0e-3)) rightAngles++; if (IsApprox(gamma, 90.0, 1.0e-3)) rightAngles++; // recast cache member "_lattice" as mutable OBUnitCell::LatticeType *lattice = const_cast<OBUnitCell::LatticeType*>(&_lattice); switch (rightAngles) { case 3: if (IsApprox(a, b, 1.0e-4) && IsApprox(b, c, 1.0e-4)) *lattice = Cubic; else if (IsApprox(a, b, 1.0e-4) || IsApprox(b, c, 1.0e-4)) *lattice = Tetragonal; else *lattice = Orthorhombic; break; case 2: if ( (IsApprox(alpha, 120.0, 1.0e-3) || IsApprox(beta, 120.0, 1.0e-3) || IsApprox(gamma, 120.0f, 1.0e-3)) && (IsApprox(a, b, 1.0e-4) || IsApprox(b, c, 1.0e-4)) ) *lattice = Hexagonal; else *lattice = Monoclinic; break; default: if (IsApprox(a, b, 1.0e-4) && IsApprox(b, c, 1.0e-4)) *lattice = Rhombohedral; else *lattice = Triclinic; } return *lattice; }
bool BaseV4L2VideoCapture::InitVideoCaptureFilters() { if(_pVideoCaptureFilters == NULL) _pVideoCaptureFilters = new VideoCaptureFilters(); _pVideoCaptureFilters->brightness = GetBrightness(); _pVideoCaptureFilters->contrast = GetContrast(); _pVideoCaptureFilters->hue = GetHUE(); _pVideoCaptureFilters->saturation = GetSaturation(); _pVideoCaptureFilters->sharpness = GetSharpness(); _pVideoCaptureFilters->gamma = GetGamma(); _pVideoCaptureFilters->backlightCompensation = GetBacklightCompensation(); // Below is for debug sake //FATAL("brightness : %d\n contrast : %d\n hue : %d\n saturation : %d\n sharpness : %d\n gamma : %d\n backlightCompensation :%d", _pVideoCaptureFilters->brightness , _pVideoCaptureFilters->contrast, _pVideoCaptureFilters->hue, _pVideoCaptureFilters->saturation , _pVideoCaptureFilters->sharpness, _pVideoCaptureFilters->gamma, _pVideoCaptureFilters->backlightCompensation); return true; }
OSStatus FadeToGamma( ScreenRef screen, const RLGammaTable *newGamma, float seconds ) { if( ! newGamma ) return paramErr; DEBUGMESSAGE( "Fading to new gamma over " << seconds << " seconds." ); //Calculate the starting and ending time for out fade double startTime = GetCurrentTime(); double endTime = startTime + seconds; //Determine our starting gamma RLGammaTable oldGamma, currentGamma; OSStatus error = GetGamma( screen, &oldGamma ); if( error ) return error; //Loop until we run out of time, resetting the gamma as fast as possible for( double currentTime = GetCurrentTime(); currentTime < endTime && ! error; currentTime = GetCurrentTime() ) { //The fraction is the percentage of time that we have spend so far in this loop as a value between 0 and 1.0 double fraction = (currentTime - startTime) / seconds; //Calculate the new gamma based on the amount of time spent so far //(1-fraction)startGamma + fraction * endGamma = startGamma + fraction( endGamma - startGamma) for( int i = 0; i < kGammaTableEntryCount; i++ ) { currentGamma.red[i] = oldGamma.red[i] + fraction * (newGamma->red[i] - oldGamma.red[i]); currentGamma.green[i] = oldGamma.green[i] + fraction * (newGamma->green[i] - oldGamma.green[i]); currentGamma.blue[i] = oldGamma.blue[i] + fraction * (newGamma->blue[i] - oldGamma.blue[i]); } error = SetGamma( screen, ¤tGamma ); } if( error ) DEBUGMESSAGE( "Got error # " << error << " doing a gamma fade in FadeToGamma(). Attempting to achieve the final gamma...." ); return SetGamma( screen, newGamma ); }
/* Do a gamma fade to the gamma table provided over the time period desired */ OSStatus FadeToGammaMultiple( ScreenRef *screen, unsigned int count, const RLGammaTable *newGamma, float seconds ) { int i; OSStatus error = noErr; if( ! newGamma ) return paramErr; //Calculate the starting and ending time for out fade double startTime = GetCurrentTime(); double endTime = startTime + seconds; //Determine our starting gamma RLGammaTable *oldGamma = (RLGammaTable*) NewPtr( sizeof( RLGammaTable ) * count ); RLGammaTable *currentGamma = (RLGammaTable*) NewPtr( sizeof( RLGammaTable ) * count ); if( NULL == oldGamma || NULL == currentGamma ) { if( NULL != oldGamma ) DisposePtr( Ptr( oldGamma ) ); if( NULL != currentGamma ) DisposePtr( Ptr( currentGamma ) ); return rlOutOfMemory; } for( i = 0; i < count; i++ ) { error = GetGamma( screen[i], &oldGamma[i] ); if( noErr != error ) goto exit; } //Loop until we run out of time, resetting the gamma as fast as possible for( double currentTime = GetCurrentTime(); currentTime < endTime; currentTime = GetCurrentTime() ) { //The fraction is the percentage of time that we have spend so far in this loop as a value between 0 and 1.0 double fraction = (currentTime - startTime) / seconds; for( i = 0; i < count; i++ ) { //Calculate the new gamma based on the amount of time spent so far //(1-fraction)startGamma + fraction * endGamma = startGamma + fraction( endGamma - startGamma) for( int j = 0; j < kGammaTableEntryCount; j++ ) { currentGamma[i].red[j] = oldGamma[i].red[j] + fraction * (newGamma[i].red[j] - oldGamma[i].red[j]); currentGamma[i].green[j] = oldGamma[i].green[j] + fraction * (newGamma[i].green[j] - oldGamma[i].green[j]); currentGamma[i].blue[j] = oldGamma[i].blue[j] + fraction * (newGamma[i].blue[j] - oldGamma[i].blue[j]); } error = SetGamma( screen[i], ¤tGamma[i] ); if( noErr != error ) goto finish; } } finish: if( error ) DEBUGMESSAGE( "Got error # " << error << " doing a gamma fade in FadeToGamma(). Attempting to achieve the final gamma...." ); for( i = 0; i < count; i++ ) SetGamma( screen[i], &newGamma[i] ); exit: DisposePtr( Ptr( oldGamma ) ); DisposePtr( Ptr( currentGamma ) ); return error; }