openMSX
RenderSettings.hh
Go to the documentation of this file.
1 #ifndef RENDERSETTINGS_HH
2 #define RENDERSETTINGS_HH
3 
4 #include "BooleanSetting.hh"
5 #include "EnumSetting.hh"
6 #include "FloatSetting.hh"
7 #include "IntegerSetting.hh"
8 #include "StringSetting.hh"
9 #include "Observer.hh"
10 #include "gl_mat.hh"
11 
12 namespace openmsx {
13 
14 class CommandController;
15 class Interpreter;
16 
21 class RenderSettings final : private Observer<Setting>
22 {
23 public:
29 
33 
40  };
41 
44  };
45 
48  };
49 
50  explicit RenderSettings(CommandController& commandController);
52 
54  Accuracy getAccuracy() const { return accuracySetting.getEnum(); }
55 
57  bool getDeinterlace() const { return deinterlaceSetting.getBoolean(); }
58 
60  bool getDeflicker() const { return deflickerSetting.getBoolean(); }
61 
63  IntegerSetting& getMaxFrameSkipSetting() { return maxFrameSkipSetting; }
64  int getMaxFrameSkip() const { return maxFrameSkipSetting.getInt(); }
65 
67  IntegerSetting& getMinFrameSkipSetting() { return minFrameSkipSetting; }
68  int getMinFrameSkip() const { return minFrameSkipSetting.getInt(); }
69 
71  BooleanSetting& getFullScreenSetting() { return fullScreenSetting; }
72  bool getFullScreen() const { return fullScreenSetting.getBoolean(); }
73 
75  FloatSetting& getGammaSetting() { return gammaSetting; }
76  float getGamma() const { return gammaSetting.getDouble(); }
77 
79  FloatSetting& getBrightnessSetting() { return brightnessSetting; }
80  float getBrightness() const { return brightnessSetting.getDouble(); }
81 
83  FloatSetting& getContrastSetting() { return contrastSetting; }
84  float getContrast() const { return contrastSetting.getDouble(); }
85 
87  StringSetting& getColorMatrixSetting() { return colorMatrixSetting; }
89  bool isColorMatrixIdentity() { return cmIdentity; }
90 
92  int getGlow() const { return glowSetting.getInt(); }
93 
95  FloatSetting& getNoiseSetting() { return noiseSetting; }
96  float getNoise() const { return noiseSetting.getDouble(); }
97 
99  int getBlurFactor() const {
100  return (horizontalBlurSetting.getInt()) * 256 / 100;
101  }
102 
104  int getScanlineFactor() const {
105  return 255 - ((scanlineAlphaSetting.getInt() * 255) / 100);
106  }
107 
109  float getScanlineGap() const {
110  return scanlineAlphaSetting.getInt() * 0.01f;
111  }
112 
114  RendererSetting& getRendererSetting() { return rendererSetting; }
115  RendererID getRenderer() const { return rendererSetting.getEnum(); }
116 
119  return scaleAlgorithmSetting.getEnum();
120  }
121 
123  IntegerSetting& getScaleFactorSetting() { return scaleFactorSetting; }
124  int getScaleFactor() const { return scaleFactorSetting.getInt(); }
125 
132  BooleanSetting& getLimitSpritesSetting() { return limitSpritesSetting; }
133 
135  bool getDisableSprites() const { return disableSpritesSetting.getBoolean(); }
136 
139  EnumSetting<bool>& getCmdTimingSetting() { return cmdTimingSetting; }
140 
145  EnumSetting<bool>& getTooFastAccessSetting() { return tooFastAccessSetting; }
146 
149  DisplayDeform getDisplayDeform() { return displayDeformSetting.getEnum(); }
150 
153  EnumSetting<SyncToVBlankMode>& getSyncToVBlankModeSetting() { return syncToVBlankModeSetting; }
154 
159  return horizontalStretchSetting;
160  }
161  float getHorizontalStretch() const {
162  return horizontalStretchSetting.getDouble();
163  }
164 
168  return pointerHideDelaySetting;
169  }
170  float getPointerHideDelay() const {
171  return pointerHideDelaySetting.getDouble();
172  }
173 
175  bool getInterleaveBlackFrame() const {
176  return interleaveBlackFrameSetting.getBoolean();
177  }
178 
186  float transformComponent(float c) const;
187 
194  gl::vec3 transformRGB(gl::vec3 rgb) const;
195 
196 private:
197  static EnumSetting<ScaleAlgorithm>::Map getScalerMap();
198  static EnumSetting<RendererID>::Map getRendererMap();
199 
200  // Observer:
201  void update(const Setting& setting) override;
202 
206  void updateBrightnessAndContrast();
207 
208  void parseColorMatrix(Interpreter& interp, const TclObject& value);
209 
210  EnumSetting<Accuracy> accuracySetting;
211  BooleanSetting deinterlaceSetting;
212  BooleanSetting deflickerSetting;
213  IntegerSetting maxFrameSkipSetting;
214  IntegerSetting minFrameSkipSetting;
215  BooleanSetting fullScreenSetting;
216  FloatSetting gammaSetting;
217  FloatSetting brightnessSetting;
218  FloatSetting contrastSetting;
219  StringSetting colorMatrixSetting;
220  IntegerSetting glowSetting;
221  FloatSetting noiseSetting;
222  RendererSetting rendererSetting;
223  IntegerSetting horizontalBlurSetting;
224  EnumSetting<ScaleAlgorithm> scaleAlgorithmSetting;
225  IntegerSetting scaleFactorSetting;
226  IntegerSetting scanlineAlphaSetting;
227  BooleanSetting limitSpritesSetting;
228  BooleanSetting disableSpritesSetting;
229  EnumSetting<bool> cmdTimingSetting;
230  EnumSetting<bool> tooFastAccessSetting;
231  EnumSetting<DisplayDeform> displayDeformSetting;
232  EnumSetting<SyncToVBlankMode> syncToVBlankModeSetting;
233  FloatSetting horizontalStretchSetting;
234  FloatSetting pointerHideDelaySetting;
235  BooleanSetting interleaveBlackFrameSetting;
236 
237  float brightness;
238  float contrast;
239 
241  gl::mat3 colorMatrix;
243  bool cmIdentity;
244 };
245 
246 } // namespace openmsx
247 
248 #endif
openmsx::EnumSetting< RendererID >
openmsx::RenderSettings::transformComponent
float transformComponent(float c) const
Apply brightness, contrast and gamma transformation on the input color component.
Definition: RenderSettings.cc:267
openmsx::RenderSettings::getContrastSetting
FloatSetting & getContrastSetting()
Contrast video setting.
Definition: RenderSettings.hh:83
IntegerSetting.hh
openmsx::RenderSettings::RenderSettings
RenderSettings(CommandController &commandController)
Definition: RenderSettings.cc:50
openmsx::RenderSettings::NO_SCALER
@ NO_SCALER
Definition: RenderSettings.hh:39
openmsx::RenderSettings::getGlow
int getGlow() const
The amount of glow [0..100].
Definition: RenderSettings.hh:92
openmsx::RenderSettings::getGamma
float getGamma() const
Definition: RenderSettings.hh:76
openmsx::CommandController
Definition: CommandController.hh:17
gl_mat.hh
openmsx::RenderSettings::getColorMatrixSetting
StringSetting & getColorMatrixSetting()
Color matrix setting.
Definition: RenderSettings.hh:87
openmsx::RenderSettings
Class containing all settings for renderers.
Definition: RenderSettings.hh:21
openmsx::RenderSettings::ACC_LINE
@ ACC_LINE
Definition: RenderSettings.hh:32
gl::matMxN
Definition: gl_mat.hh:30
openmsx::RenderSettings::getBlurFactor
int getBlurFactor() const
The amount of horizontal blur [0..256].
Definition: RenderSettings.hh:99
openmsx::RenderSettings::getScanlineGap
float getScanlineGap() const
The amount of space [0..1] between scanlines.
Definition: RenderSettings.hh:109
openmsx::FloatSetting
A Setting with a floating point value.
Definition: FloatSetting.hh:10
openmsx::RenderSettings::getMaxFrameSkipSetting
IntegerSetting & getMaxFrameSkipSetting()
The current max frameskip.
Definition: RenderSettings.hh:63
openmsx::RenderSettings::getHorizontalStretch
float getHorizontalStretch() const
Definition: RenderSettings.hh:161
openmsx::RenderSettings::getHorizontalStretchSetting
FloatSetting & getHorizontalStretchSetting()
Amount of horizontal stretch.
Definition: RenderSettings.hh:158
openmsx::RenderSettings::getScaleFactorSetting
IntegerSetting & getScaleFactorSetting()
The current scaling factor.
Definition: RenderSettings.hh:123
openmsx::RenderSettings::transformRGB
gl::vec3 transformRGB(gl::vec3 rgb) const
Apply brightness, contrast and gamma transformation on the input color.
Definition: RenderSettings.cc:273
openmsx::RenderSettings::getBrightnessSetting
FloatSetting & getBrightnessSetting()
Brightness video setting.
Definition: RenderSettings.hh:79
openmsx::EnumSetting::getEnum
T getEnum() const noexcept
Definition: EnumSetting.hh:92
openmsx::RenderSettings::getNoiseSetting
FloatSetting & getNoiseSetting()
The amount of noise to add to the frame.
Definition: RenderSettings.hh:95
openmsx::RenderSettings::getDisableSprites
bool getDisableSprites() const
Disable sprite rendering?
Definition: RenderSettings.hh:135
openmsx::Setting
Definition: Setting.hh:119
openmsx::RenderSettings::Accuracy
Accuracy
Render accuracy: granularity of the rendered area.
Definition: RenderSettings.hh:32
BooleanSetting.hh
gl::vecN
Definition: gl_vec.hh:35
openmsx::RenderSettings::getFullScreenSetting
BooleanSetting & getFullScreenSetting()
Full screen [on, off].
Definition: RenderSettings.hh:71
openmsx::RenderSettings::getPointerHideDelaySetting
FloatSetting & getPointerHideDelaySetting()
The amount of time until the pointer is hidden in the openMSX window.
Definition: RenderSettings.hh:167
openmsx::RenderSettings::SDLGL_PP
@ SDLGL_PP
Definition: RenderSettings.hh:27
openmsx::RenderSettings::getScaleFactor
int getScaleFactor() const
Definition: RenderSettings.hh:124
StringSetting.hh
openmsx::RenderSettings::getDeinterlace
bool getDeinterlace() const
Deinterlacing [on, off].
Definition: RenderSettings.hh:57
openmsx::RenderSettings::SCALER_SCALE
@ SCALER_SCALE
Definition: RenderSettings.hh:37
openmsx::StringSetting
Definition: StringSetting.hh:8
openmsx::RenderSettings::DisplayDeform
DisplayDeform
Definition: RenderSettings.hh:42
openmsx::IntegerSetting::getInt
int getInt() const noexcept
Definition: IntegerSetting.hh:20
openmsx::RenderSettings::getGammaSetting
FloatSetting & getGammaSetting()
The amount of gamma correction.
Definition: RenderSettings.hh:75
openmsx::RenderSettings::RendererID
RendererID
Enumeration of Renderers known to openMSX.
Definition: RenderSettings.hh:27
openmsx::RenderSettings::UNINITIALIZED
@ UNINITIALIZED
Definition: RenderSettings.hh:27
Observer.hh
openmsx::RenderSettings::DEFORM_3D
@ DEFORM_3D
Definition: RenderSettings.hh:43
openmsx::RenderSettings::getDisplayDeform
DisplayDeform getDisplayDeform()
Display deformation (normal, 3d) ATM this only works when using the SDLGL-PP renderer.
Definition: RenderSettings.hh:149
openmsx::RenderSettings::DEFORM_NORMAL
@ DEFORM_NORMAL
Definition: RenderSettings.hh:43
openmsx::RenderSettings::getMinFrameSkipSetting
IntegerSetting & getMinFrameSkipSetting()
The current min frameskip.
Definition: RenderSettings.hh:67
openmsx::RenderSettings::getBrightness
float getBrightness() const
Definition: RenderSettings.hh:80
openmsx::FloatSetting::getDouble
double getDouble() const noexcept
Definition: FloatSetting.hh:20
openmsx::RenderSettings::SCALER_TV
@ SCALER_TV
Definition: RenderSettings.hh:38
openmsx::RenderSettings::ADAPTIVE
@ ADAPTIVE
Definition: RenderSettings.hh:47
openmsx::RenderSettings::getAccuracy
Accuracy getAccuracy() const
Accuracy [screen, line, pixel].
Definition: RenderSettings.hh:54
openmsx::RenderSettings::~RenderSettings
~RenderSettings()
Definition: RenderSettings.cc:237
openmsx::RenderSettings::isColorMatrixIdentity
bool isColorMatrixIdentity()
Returns true iff the current color matrix is the identity matrix.
Definition: RenderSettings.hh:89
openmsx::RenderSettings::SCALER_RGBTRIPLET
@ SCALER_RGBTRIPLET
Definition: RenderSettings.hh:38
openmsx::RenderSettings::SyncToVBlankMode
SyncToVBlankMode
Definition: RenderSettings.hh:46
openmsx::RenderSettings::SCALER_HQLITE
@ SCALER_HQLITE
Definition: RenderSettings.hh:38
EnumSetting.hh
openmsx::RenderSettings::SCALER_HQ
@ SCALER_HQ
Definition: RenderSettings.hh:38
openmsx::RenderSettings::getRenderer
RendererID getRenderer() const
Definition: RenderSettings.hh:115
openmsx::RenderSettings::IMMEDIATE
@ IMMEDIATE
Definition: RenderSettings.hh:47
openmsx::RenderSettings::SCALER_SAI
@ SCALER_SAI
Definition: RenderSettings.hh:37
openmsx::RenderSettings::getLimitSpritesSetting
BooleanSetting & getLimitSpritesSetting()
Limit number of sprites per line? If true, limit number of sprites per line as real VDP does.
Definition: RenderSettings.hh:132
openmsx::RenderSettings::SDL
@ SDL
Definition: RenderSettings.hh:27
openmsx::RenderSettings::RendererSetting
EnumSetting< RendererID > RendererSetting
Definition: RenderSettings.hh:28
openmsx::RenderSettings::getFullScreen
bool getFullScreen() const
Definition: RenderSettings.hh:72
openmsx::RenderSettings::getScanlineFactor
int getScanlineFactor() const
The alpha value [0..255] of the gap between scanlines.
Definition: RenderSettings.hh:104
openmsx::RenderSettings::getPointerHideDelay
float getPointerHideDelay() const
Definition: RenderSettings.hh:170
openmsx::RenderSettings::getMinFrameSkip
int getMinFrameSkip() const
Definition: RenderSettings.hh:68
openmsx::RenderSettings::ACC_SCREEN
@ ACC_SCREEN
Definition: RenderSettings.hh:32
openmsx::RenderSettings::SYNC
@ SYNC
Definition: RenderSettings.hh:47
openmsx::RenderSettings::getMaxFrameSkip
int getMaxFrameSkip() const
Definition: RenderSettings.hh:64
openmsx::RenderSettings::SCALER_MLAA
@ SCALER_MLAA
Definition: RenderSettings.hh:38
openmsx::BooleanSetting
Definition: BooleanSetting.hh:8
openmsx::IntegerSetting
A Setting with an integer value.
Definition: IntegerSetting.hh:10
openmsx::RenderSettings::getContrast
float getContrast() const
Definition: RenderSettings.hh:84
openmsx::RenderSettings::getDeflicker
bool getDeflicker() const
Deflicker [on, off].
Definition: RenderSettings.hh:60
openmsx::TclObject
Definition: TclObject.hh:21
openmsx::RenderSettings::SCALER_SIMPLE
@ SCALER_SIMPLE
Definition: RenderSettings.hh:37
openmsx::RenderSettings::getCmdTimingSetting
EnumSetting< bool > & getCmdTimingSetting()
CmdTiming [real, broken].
Definition: RenderSettings.hh:139
openmsx::RenderSettings::DUMMY
@ DUMMY
Definition: RenderSettings.hh:27
openmsx::RenderSettings::getTooFastAccessSetting
EnumSetting< bool > & getTooFastAccessSetting()
TooFastAccess [real, ignored].
Definition: RenderSettings.hh:145
openmsx::RenderSettings::getInterleaveBlackFrame
bool getInterleaveBlackFrame() const
Is black frame interleaving enabled?
Definition: RenderSettings.hh:175
openmsx::Interpreter
Definition: Interpreter.hh:16
openmsx::RenderSettings::getScaleAlgorithm
ScaleAlgorithm getScaleAlgorithm() const
The current scaling algorithm.
Definition: RenderSettings.hh:118
openmsx::RenderSettings::getNoise
float getNoise() const
Definition: RenderSettings.hh:96
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
FloatSetting.hh
openmsx::BooleanSetting::getBoolean
bool getBoolean() const noexcept
Definition: BooleanSetting.hh:17
openmsx::RenderSettings::ScaleAlgorithm
ScaleAlgorithm
Scaler algorithm.
Definition: RenderSettings.hh:36
openmsx::Observer
Generic Gang-of-Four Observer class, templatized edition.
Definition: Observer.hh:9
openmsx::RenderSettings::getSyncToVBlankModeSetting
EnumSetting< SyncToVBlankMode > & getSyncToVBlankModeSetting()
SyncToVBlankMode (immediate, sync, sync_adaptive) ATM this only works when using the SDLGL-PP rendere...
Definition: RenderSettings.hh:153
openmsx::RenderSettings::ACC_PIXEL
@ ACC_PIXEL
Definition: RenderSettings.hh:32
openmsx::RenderSettings::getRendererSetting
RendererSetting & getRendererSetting()
The current renderer.
Definition: RenderSettings.hh:114