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 
39  NO_SCALER
40  };
41 
44  };
45 
46  explicit RenderSettings(CommandController& commandController);
48 
50  Accuracy getAccuracy() const { return accuracySetting.getEnum(); }
51 
53  bool getDeinterlace() const { return deinterlaceSetting.getBoolean(); }
54 
56  bool getDeflicker() const { return deflickerSetting.getBoolean(); }
57 
59  IntegerSetting& getMaxFrameSkipSetting() { return maxFrameSkipSetting; }
60  int getMaxFrameSkip() const { return maxFrameSkipSetting.getInt(); }
61 
63  IntegerSetting& getMinFrameSkipSetting() { return minFrameSkipSetting; }
64  int getMinFrameSkip() const { return minFrameSkipSetting.getInt(); }
65 
67  BooleanSetting& getFullScreenSetting() { return fullScreenSetting; }
68  bool getFullScreen() const { return fullScreenSetting.getBoolean(); }
69 
71  FloatSetting& getGammaSetting() { return gammaSetting; }
72  float getGamma() const { return gammaSetting.getDouble(); }
73 
75  FloatSetting& getBrightnessSetting() { return brightnessSetting; }
76  float getBrightness() const { return brightnessSetting.getDouble(); }
77 
79  FloatSetting& getContrastSetting() { return contrastSetting; }
80  float getContrast() const { return contrastSetting.getDouble(); }
81 
83  StringSetting& getColorMatrixSetting() { return colorMatrixSetting; }
85  bool isColorMatrixIdentity() { return cmIdentity; }
86 
88  int getGlow() const { return glowSetting.getInt(); }
89 
91  FloatSetting& getNoiseSetting() { return noiseSetting; }
92  float getNoise() const { return noiseSetting.getDouble(); }
93 
95  int getBlurFactor() const {
96  return (horizontalBlurSetting.getInt()) * 256 / 100;
97  }
98 
100  int getScanlineFactor() const {
101  return 255 - ((scanlineAlphaSetting.getInt() * 255) / 100);
102  }
103 
105  float getScanlineGap() const {
106  return scanlineAlphaSetting.getInt() * 0.01f;
107  }
108 
110  RendererSetting& getRendererSetting() { return rendererSetting; }
111  RendererID getRenderer() const { return rendererSetting.getEnum(); }
112 
115  return scaleAlgorithmSetting.getEnum();
116  }
117 
119  IntegerSetting& getScaleFactorSetting() { return scaleFactorSetting; }
120  int getScaleFactor() const { return scaleFactorSetting.getInt(); }
121 
128  BooleanSetting& getLimitSpritesSetting() { return limitSpritesSetting; }
129 
131  bool getDisableSprites() const { return disableSpritesSetting.getBoolean(); }
132 
135  EnumSetting<bool>& getCmdTimingSetting() { return cmdTimingSetting; }
136 
141  EnumSetting<bool>& getTooFastAccessSetting() { return tooFastAccessSetting; }
142 
145  DisplayDeform getDisplayDeform() { return displayDeformSetting.getEnum(); }
146 
149  BooleanSetting& getVSyncSetting() { return vSyncSetting; }
150 
155  return horizontalStretchSetting;
156  }
157  float getHorizontalStretch() const {
158  return horizontalStretchSetting.getDouble();
159  }
160 
164  return pointerHideDelaySetting;
165  }
166  float getPointerHideDelay() const {
167  return pointerHideDelaySetting.getDouble();
168  }
169 
171  bool getInterleaveBlackFrame() const {
172  return interleaveBlackFrameSetting.getBoolean();
173  }
174 
182  float transformComponent(float c) const;
183 
190  gl::vec3 transformRGB(gl::vec3 rgb) const;
191 
192 private:
193  static EnumSetting<ScaleAlgorithm>::Map getScalerMap();
194  static EnumSetting<RendererID>::Map getRendererMap();
195 
196  // Observer:
197  void update(const Setting& setting) override;
198 
202  void updateBrightnessAndContrast();
203 
204  void parseColorMatrix(Interpreter& interp, const TclObject& value);
205 
206  EnumSetting<Accuracy> accuracySetting;
207  BooleanSetting deinterlaceSetting;
208  BooleanSetting deflickerSetting;
209  IntegerSetting maxFrameSkipSetting;
210  IntegerSetting minFrameSkipSetting;
211  BooleanSetting fullScreenSetting;
212  FloatSetting gammaSetting;
213  FloatSetting brightnessSetting;
214  FloatSetting contrastSetting;
215  StringSetting colorMatrixSetting;
216  IntegerSetting glowSetting;
217  FloatSetting noiseSetting;
218  RendererSetting rendererSetting;
219  IntegerSetting horizontalBlurSetting;
220  EnumSetting<ScaleAlgorithm> scaleAlgorithmSetting;
221  IntegerSetting scaleFactorSetting;
222  IntegerSetting scanlineAlphaSetting;
223  BooleanSetting limitSpritesSetting;
224  BooleanSetting disableSpritesSetting;
225  EnumSetting<bool> cmdTimingSetting;
226  EnumSetting<bool> tooFastAccessSetting;
227  EnumSetting<DisplayDeform> displayDeformSetting;
228  BooleanSetting vSyncSetting;
229  FloatSetting horizontalStretchSetting;
230  FloatSetting pointerHideDelaySetting;
231  BooleanSetting interleaveBlackFrameSetting;
232 
233  float brightness;
234  float contrast;
235 
237  gl::mat3 colorMatrix;
239  bool cmIdentity;
240 };
241 
242 } // namespace openmsx
243 
244 #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:261
openmsx::RenderSettings::getContrastSetting
FloatSetting & getContrastSetting()
Contrast video setting.
Definition: RenderSettings.hh:79
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:88
openmsx::RenderSettings::getGamma
float getGamma() const
Definition: RenderSettings.hh:72
openmsx::CommandController
Definition: CommandController.hh:18
gl_mat.hh
openmsx::RenderSettings::getColorMatrixSetting
StringSetting & getColorMatrixSetting()
Color matrix setting.
Definition: RenderSettings.hh:83
openmsx::RenderSettings
Class containing all settings for renderers.
Definition: RenderSettings.hh:22
openmsx::RenderSettings::ACC_LINE
@ ACC_LINE
Definition: RenderSettings.hh:32
gl::matMxN
Definition: gl_mat.hh:31
openmsx::RenderSettings::getBlurFactor
int getBlurFactor() const
The amount of horizontal blur [0..256].
Definition: RenderSettings.hh:95
openmsx::RenderSettings::getScanlineGap
float getScanlineGap() const
The amount of space [0..1] between scanlines.
Definition: RenderSettings.hh:105
openmsx::FloatSetting
A Setting with a floating point value.
Definition: FloatSetting.hh:11
openmsx::RenderSettings::getMaxFrameSkipSetting
IntegerSetting & getMaxFrameSkipSetting()
The current max frameskip.
Definition: RenderSettings.hh:59
openmsx::RenderSettings::getHorizontalStretch
float getHorizontalStretch() const
Definition: RenderSettings.hh:157
openmsx::RenderSettings::getHorizontalStretchSetting
FloatSetting & getHorizontalStretchSetting()
Amount of horizontal stretch.
Definition: RenderSettings.hh:154
openmsx::RenderSettings::getScaleFactorSetting
IntegerSetting & getScaleFactorSetting()
The current scaling factor.
Definition: RenderSettings.hh:119
openmsx::RenderSettings::transformRGB
gl::vec3 transformRGB(gl::vec3 rgb) const
Apply brightness, contrast and gamma transformation on the input color.
Definition: RenderSettings.cc:267
openmsx::RenderSettings::getBrightnessSetting
FloatSetting & getBrightnessSetting()
Brightness video setting.
Definition: RenderSettings.hh:75
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:91
openmsx::RenderSettings::getDisableSprites
bool getDisableSprites() const
Disable sprite rendering?
Definition: RenderSettings.hh:131
openmsx::Setting
Definition: Setting.hh:120
openmsx::RenderSettings::Accuracy
Accuracy
Render accuracy: granularity of the rendered area.
Definition: RenderSettings.hh:32
BooleanSetting.hh
gl::vecN
Definition: gl_vec.hh:36
openmsx::RenderSettings::getFullScreenSetting
BooleanSetting & getFullScreenSetting()
Full screen [on, off].
Definition: RenderSettings.hh:67
openmsx::RenderSettings::getPointerHideDelaySetting
FloatSetting & getPointerHideDelaySetting()
The amount of time until the pointer is hidden in the openMSX window.
Definition: RenderSettings.hh:163
openmsx::RenderSettings::SDLGL_PP
@ SDLGL_PP
Definition: RenderSettings.hh:27
openmsx::RenderSettings::getScaleFactor
int getScaleFactor() const
Definition: RenderSettings.hh:120
StringSetting.hh
openmsx::RenderSettings::getDeinterlace
bool getDeinterlace() const
Deinterlacing [on, off].
Definition: RenderSettings.hh:53
openmsx::RenderSettings::SCALER_SCALE
@ SCALER_SCALE
Definition: RenderSettings.hh:37
openmsx::StringSetting
Definition: StringSetting.hh:9
openmsx::RenderSettings::DisplayDeform
DisplayDeform
Definition: RenderSettings.hh:42
openmsx::IntegerSetting::getInt
int getInt() const noexcept
Definition: IntegerSetting.hh:21
openmsx::RenderSettings::getGammaSetting
FloatSetting & getGammaSetting()
The amount of gamma correction.
Definition: RenderSettings.hh:71
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:145
openmsx::RenderSettings::DEFORM_NORMAL
@ DEFORM_NORMAL
Definition: RenderSettings.hh:43
openmsx::RenderSettings::getMinFrameSkipSetting
IntegerSetting & getMinFrameSkipSetting()
The current min frameskip.
Definition: RenderSettings.hh:63
openmsx::RenderSettings::getBrightness
float getBrightness() const
Definition: RenderSettings.hh:76
openmsx::FloatSetting::getDouble
double getDouble() const noexcept
Definition: FloatSetting.hh:20
openmsx::RenderSettings::SCALER_TV
@ SCALER_TV
Definition: RenderSettings.hh:38
openmsx::RenderSettings::getAccuracy
Accuracy getAccuracy() const
Accuracy [screen, line, pixel].
Definition: RenderSettings.hh:50
openmsx::RenderSettings::~RenderSettings
~RenderSettings()
Definition: RenderSettings.cc:231
openmsx::RenderSettings::isColorMatrixIdentity
bool isColorMatrixIdentity()
Returns true iff the current color matrix is the identity matrix.
Definition: RenderSettings.hh:85
openmsx::RenderSettings::SCALER_RGBTRIPLET
@ SCALER_RGBTRIPLET
Definition: RenderSettings.hh:38
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:111
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:128
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:68
openmsx::RenderSettings::getScanlineFactor
int getScanlineFactor() const
The alpha value [0..255] of the gap between scanlines.
Definition: RenderSettings.hh:100
openmsx::RenderSettings::getPointerHideDelay
float getPointerHideDelay() const
Definition: RenderSettings.hh:166
openmsx::RenderSettings::getMinFrameSkip
int getMinFrameSkip() const
Definition: RenderSettings.hh:64
openmsx::RenderSettings::ACC_SCREEN
@ ACC_SCREEN
Definition: RenderSettings.hh:32
openmsx::RenderSettings::getMaxFrameSkip
int getMaxFrameSkip() const
Definition: RenderSettings.hh:60
openmsx::RenderSettings::SCALER_MLAA
@ SCALER_MLAA
Definition: RenderSettings.hh:38
openmsx::BooleanSetting
Definition: BooleanSetting.hh:9
openmsx::IntegerSetting
A Setting with an integer value.
Definition: IntegerSetting.hh:11
openmsx::RenderSettings::getContrast
float getContrast() const
Definition: RenderSettings.hh:80
openmsx::RenderSettings::getDeflicker
bool getDeflicker() const
Deflicker [on, off].
Definition: RenderSettings.hh:56
openmsx::TclObject
Definition: TclObject.hh:22
openmsx::RenderSettings::SCALER_SIMPLE
@ SCALER_SIMPLE
Definition: RenderSettings.hh:37
openmsx::RenderSettings::getCmdTimingSetting
EnumSetting< bool > & getCmdTimingSetting()
CmdTiming [real, broken].
Definition: RenderSettings.hh:135
openmsx::RenderSettings::DUMMY
@ DUMMY
Definition: RenderSettings.hh:27
openmsx::RenderSettings::getTooFastAccessSetting
EnumSetting< bool > & getTooFastAccessSetting()
TooFastAccess [real, ignored].
Definition: RenderSettings.hh:141
openmsx::RenderSettings::getInterleaveBlackFrame
bool getInterleaveBlackFrame() const
Is black frame interleaving enabled?
Definition: RenderSettings.hh:171
openmsx::Interpreter
Definition: Interpreter.hh:17
openmsx::RenderSettings::getScaleAlgorithm
ScaleAlgorithm getScaleAlgorithm() const
The current scaling algorithm.
Definition: RenderSettings.hh:114
openmsx::RenderSettings::getNoise
float getNoise() const
Definition: RenderSettings.hh:92
openmsx
This file implemented 3 utility functions:
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:10
openmsx::RenderSettings::getVSyncSetting
BooleanSetting & getVSyncSetting()
VSync [on, off] ATM this only works when using the SDLGL-PP renderer.
Definition: RenderSettings.hh:149
openmsx::RenderSettings::ACC_PIXEL
@ ACC_PIXEL
Definition: RenderSettings.hh:32
openmsx::RenderSettings::getRendererSetting
RendererSetting & getRendererSetting()
The current renderer.
Definition: RenderSettings.hh:110