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