Ticket #8932: gamma.patch

File gamma.patch, 8.0 KB (added by bluegr, 16 years ago)

ScummVM gamma support

  • scummvm/trunk/backends/platform/sdl/graphics.cpp

     
    307307        }
    308308}
    309309
     310void OSystem_SDL::resetGamma() {
     311        SDL_SetGamma(1.0f, 1.0f, 1.0f);
     312}
     313
     314void OSystem_SDL::setGamma(float gamma) {
     315        SDL_SetGamma(gamma, gamma, gamma);
     316}
     317
    310318void OSystem_SDL::loadGFXMode() {
    311319        assert(_inited);
    312320        _forceFull = true;
  • scummvm/trunk/backends/platform/sdl/sdl.h

     
    9191        // Typically, 320x200
    9292        virtual void initSize(uint w, uint h); // overloaded by CE backend
    9393
     94        void resetGamma();
     95        void setGamma(float gamma);
     96
    9497        virtual int getScreenChangeID() const { return _screenChangeCount; }
    9598
    9699        // Set colors of the palette
  • scummvm/trunk/common/system.h

     
    398398         */
    399399        virtual void endGFXTransaction() {}
    400400
     401        virtual void resetGamma() {}
     402       
     403        virtual void setGamma(float gamma) {}
    401404
    402405        /**
    403406         * Returns the currently set virtual screen height.
  • scummvm/trunk/gui/options.cpp

     
    5656        kChooseThemeDirCmd              = 'chth',
    5757        kChooseExtraDirCmd              = 'chex',
    5858        kChoosePluginsDirCmd    = 'chpl',
    59         kChooseThemeCmd                 = 'chtf'
     59        kChooseThemeCmd                 = 'chtf',
     60        kGammaChanged                   = 'gach'
    6061};
    6162
    6263#ifdef SMALL_SCREEN_DEVICE
     
    161162                        _renderModePopUp->setSelected(sel);
    162163                }
    163164
     165                _gammaSlider->setValue(ConfMan.getInt("gamma", _domain));
     166                _gammaLabel->setValue(_gammaSlider->getValue());
     167                _gammaLabel->draw();
     168                // Change gamma
     169                g_system->setGamma(_gammaSlider->getValue() / 100.0f);
     170
    164171#ifndef SMALL_SCREEN_DEVICE
    165172                // Fullscreen setting
    166173                _fullscreenCheckbox->setState(ConfMan.getBool("fullscreen", _domain));
     
    284291
    285292                                if ((int32)_renderModePopUp->getSelectedTag() >= 0)
    286293                                        ConfMan.set("render_mode", Common::getRenderModeCode((Common::RenderMode)_renderModePopUp->getSelectedTag()), _domain);
     294                                ConfMan.setInt("gamma", _gammaSlider->getValue(), _domain);
    287295                        } else {
    288296                                ConfMan.removeKey("fullscreen", _domain);
    289297                                ConfMan.removeKey("aspect_ratio", _domain);
    290298                                ConfMan.removeKey("gfx_mode", _domain);
    291299                                ConfMan.removeKey("render_mode", _domain);
     300                                ConfMan.removeKey("gamma", _domain);
    292301                        }
    293302                }
    294303
     
    433442                _subSpeedLabel->setValue(_subSpeedSlider->getValue());
    434443                _subSpeedLabel->draw();
    435444                break;
     445        case kGammaChanged:
     446                _gammaLabel->setValue(_gammaSlider->getValue());
     447                _gammaLabel->draw();
     448                // Change gamma
     449                g_system->setGamma(_gammaSlider->getValue() / 100.0f);
     450                break;
    436451        case kOKCmd:
    437452                setResult(1);
    438453                close();
     
    533548        // Aspect ratio checkbox
    534549        _aspectCheckbox = new CheckboxWidget(boss, prefix + "grAspectCheckbox", "Aspect ratio correction", 0, 0);
    535550
     551        _gammaSlider = new SliderWidget(boss, prefix + "grGammaSlider", kGammaChanged);
     552        _gammaSlider->setMinValue(0);
     553        _gammaSlider->setMaxValue(200);
     554        _gammaLabel = new StaticTextWidget(boss, prefix + "gammaLabel", "100%");
     555
    536556#ifdef SMALL_SCREEN_DEVICE
    537557        _fullscreenCheckbox->setState(true);
    538558        _fullscreenCheckbox->setEnabled(false);
  • scummvm/trunk/gui/options.h

     
    9393        PopUpWidget *_gfxPopUp;
    9494        CheckboxWidget *_fullscreenCheckbox;
    9595        CheckboxWidget *_aspectCheckbox;
     96        SliderWidget *_gammaSlider;
     97        StaticTextWidget *_gammaLabel;
    9698        PopUpWidget *_renderModePopUp;
    9799
    98100        //
  • scummvm/trunk/gui/themes/scummclassic/classic_layout.stx

     
    176176                        <widget name = 'grFullscreenCheckbox'
    177177                                        type = 'Checkbox'
    178178                        />
     179                        <layout type = 'horizontal' padding = '0, 0, 0, 0'>
     180                                <widget name = 'grGammaSlider'
     181                                                type = 'Slider'
     182                                />
     183                                <widget name = 'gammaLabel'
     184                                                type = 'SmallLabel'
     185                                />
     186                        </layout>       
    179187                </layout>
    180188        </dialog>
    181189       
     
    464472                                        height = 'Globals.Button.Height'
    465473                        />
    466474                        <space size = '10'/>
     475                        <widget name = 'Load'
     476                                        width = '150'
     477                                        height = 'Globals.Button.Height'
     478                        />
     479                        <widget name = 'Save'
     480                                        width = '150'
     481                                        height = 'Globals.Button.Height'
     482                        />                     
     483                        <space size = '10'/>
    467484                        <widget name = 'Options'
    468485                                        width = '150'
    469486                                        height = 'Globals.Button.Height'
  • scummvm/trunk/gui/themes/scummclassic/classic_layout_320.stx

     
    174174                        <widget name = 'grFullscreenCheckbox'
    175175                                        type = 'Checkbox'
    176176                        />
     177                        <layout type = 'horizontal' padding = '0, 0, 0, 0'>
     178                                <widget name = 'grGammaSlider'
     179                                                type = 'Slider'
     180                                />
     181                                <widget name = 'gammaLabel'
     182                                                type = 'SmallLabel'
     183                                />
     184                        </layout>               
    177185                </layout>
    178186        </dialog>
    179187
     
    465473                                        height = 'Globals.Button.Height'
    466474                        />
    467475                        <space size = '4'/>
     476                        <widget name = 'Load'
     477                                        width = '70'
     478                                        height = 'Globals.Button.Height'
     479                        />
     480                        <widget name = 'Save'
     481                                        width = '70'
     482                                        height = 'Globals.Button.Height'
     483                        />
     484                        <space size = '4'/>
    468485                        <widget name = 'Options'
    469486                                        width = '70'
    470487                                        height = 'Globals.Button.Height'
  • scummvm/trunk/gui/themes/scummmodern/scummmodern_layout.stx

     
    188188                        <widget name = 'grFullscreenCheckbox'
    189189                                        type = 'Checkbox'
    190190                        />
     191                        <layout type = 'horizontal' padding = '0, 0, 0, 0'>
     192                                <widget name = 'grGammaSlider'
     193                                                type = 'Slider'
     194                                />
     195                                <widget name = 'gammaLabel'
     196                                                type = 'SmallLabel'
     197                                />
     198                        </layout>
    191199                </layout>
    192200        </dialog>
    193201       
     
    476484                                        height = 'Globals.Button.Height'
    477485                        />
    478486                        <space size = '10'/>
     487                        <widget name = 'Load'
     488                                        width = '150'
     489                                        height = 'Globals.Button.Height'
     490                        />
     491                        <widget name = 'Save'
     492                                        width = '150'
     493                                        height = 'Globals.Button.Height'
     494                        />                     
     495                        <space size = '10'/>
    479496                        <widget name = 'Options'
    480497                                        width = '150'
    481498                                        height = 'Globals.Button.Height'
  • scummvm/trunk/gui/themes/scummmodern/scummmodern_layout_320.stx

     
    171171                        <widget name = 'grFullscreenCheckbox'
    172172                                        type = 'Checkbox'
    173173                        />
     174                        <layout type = 'horizontal' padding = '0, 0, 0, 0'>
     175                                <widget name = 'grGammaSlider'
     176                                                type = 'Slider'
     177                                />
     178                                <widget name = 'gammaLabel'
     179                                                type = 'SmallLabel'
     180                                />
     181                        </layout>
    174182                </layout>
    175183        </dialog>
    176184
     
    462470                                        height = 'Globals.Button.Height'
    463471                        />
    464472                        <space size = '4'/>
     473                        <widget name = 'Load'
     474                                        width = '70'
     475                                        height = 'Globals.Button.Height'
     476                        />
     477                        <widget name = 'Save'
     478                                        width = '70'
     479                                        height = 'Globals.Button.Height'
     480                        />                                     
     481                        <space size = '4'/>
    465482                        <widget name = 'Options'
    466483                                        width = '70'
    467484                                        height = 'Globals.Button.Height'