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:
30 
34 
41  };
42 
45  };
46 
47  explicit RenderSettings(CommandController& commandController);
49 
51  Accuracy getAccuracy() const { return accuracySetting.getEnum(); }
52 
54  bool getDeinterlace() const { return deinterlaceSetting.getBoolean(); }
55 
57  bool getDeflicker() const { return deflickerSetting.getBoolean(); }
58 
60  IntegerSetting& getMaxFrameSkipSetting() { return maxFrameSkipSetting; }
61  int getMaxFrameSkip() const { return maxFrameSkipSetting.getInt(); }
62 
64  IntegerSetting& getMinFrameSkipSetting() { return minFrameSkipSetting; }
65  int getMinFrameSkip() const { return minFrameSkipSetting.getInt(); }
66 
68  BooleanSetting& getFullScreenSetting() { return fullScreenSetting; }
69  bool getFullScreen() const { return fullScreenSetting.getBoolean(); }
70 
72  FloatSetting& getGammaSetting() { return gammaSetting; }
73  float getGamma() const { return gammaSetting.getDouble(); }
74 
76  FloatSetting& getBrightnessSetting() { return brightnessSetting; }
77  float getBrightness() const { return brightnessSetting.getDouble(); }
78 
80  FloatSetting& getContrastSetting() { return contrastSetting; }
81  float getContrast() const { return contrastSetting.getDouble(); }
82 
84  StringSetting& getColorMatrixSetting() { return colorMatrixSetting; }
86  bool isColorMatrixIdentity() { return cmIdentity; }
87 
89  int getGlow() const { return glowSetting.getInt(); }
90 
92  FloatSetting& getNoiseSetting() { return noiseSetting; }
93  float getNoise() const { return noiseSetting.getDouble(); }
94 
96  int getBlurFactor() const {
97  return (horizontalBlurSetting.getInt()) * 256 / 100;
98  }
99 
101  int getScanlineFactor() const {
102  return 255 - ((scanlineAlphaSetting.getInt() * 255) / 100);
103  }
104 
106  float getScanlineGap() const {
107  return scanlineAlphaSetting.getInt() * 0.01f;
108  }
109 
111  RendererSetting& getRendererSetting() { return rendererSetting; }
112  RendererID getRenderer() const { return rendererSetting.getEnum(); }
113 
116  return scaleAlgorithmSetting.getEnum();
117  }
118 
120  IntegerSetting& getScaleFactorSetting() { return scaleFactorSetting; }
121  int getScaleFactor() const { return scaleFactorSetting.getInt(); }
122 
129  BooleanSetting& getLimitSpritesSetting() { return limitSpritesSetting; }
130 
132  bool getDisableSprites() const { return disableSpritesSetting.getBoolean(); }
133 
136  EnumSetting<bool>& getCmdTimingSetting() { return cmdTimingSetting; }
137 
142  EnumSetting<bool>& getTooFastAccessSetting() { return tooFastAccessSetting; }
143 
146  DisplayDeform getDisplayDeform() { return displayDeformSetting.getEnum(); }
147 
152  return horizontalStretchSetting;
153  }
154  float getHorizontalStretch() const {
155  return horizontalStretchSetting.getDouble();
156  }
157 
161  return pointerHideDelaySetting;
162  }
163  float getPointerHideDelay() const {
164  return pointerHideDelaySetting.getDouble();
165  }
166 
168  bool getInterleaveBlackFrame() const {
169  return interleaveBlackFrameSetting.getBoolean();
170  }
171 
179  float transformComponent(float c) const;
180 
187  gl::vec3 transformRGB(gl::vec3 rgb) const;
188 
189 private:
190  static EnumSetting<ScaleAlgorithm>::Map getScalerMap();
191  static EnumSetting<RendererID>::Map getRendererMap();
192 
193  // Observer:
194  void update(const Setting& setting) override;
195 
199  void updateBrightnessAndContrast();
200 
201  void parseColorMatrix(Interpreter& interp, const TclObject& value);
202 
203  EnumSetting<Accuracy> accuracySetting;
204  BooleanSetting deinterlaceSetting;
205  BooleanSetting deflickerSetting;
206  IntegerSetting maxFrameSkipSetting;
207  IntegerSetting minFrameSkipSetting;
208  BooleanSetting fullScreenSetting;
209  FloatSetting gammaSetting;
210  FloatSetting brightnessSetting;
211  FloatSetting contrastSetting;
212  StringSetting colorMatrixSetting;
213  IntegerSetting glowSetting;
214  FloatSetting noiseSetting;
215  RendererSetting rendererSetting;
216  IntegerSetting horizontalBlurSetting;
217  EnumSetting<ScaleAlgorithm> scaleAlgorithmSetting;
218  IntegerSetting scaleFactorSetting;
219  IntegerSetting scanlineAlphaSetting;
220  BooleanSetting limitSpritesSetting;
221  BooleanSetting disableSpritesSetting;
222  EnumSetting<bool> cmdTimingSetting;
223  EnumSetting<bool> tooFastAccessSetting;
224  EnumSetting<DisplayDeform> displayDeformSetting;
225  FloatSetting horizontalStretchSetting;
226  FloatSetting pointerHideDelaySetting;
227  BooleanSetting interleaveBlackFrameSetting;
228 
229  float brightness;
230  float contrast;
231 
233  gl::mat3 colorMatrix;
235  bool cmIdentity;
236 };
237 
238 } // namespace openmsx
239 
240 #endif
T getEnum() const noexcept
Definition: EnumSetting.hh:92
int getScanlineFactor() const
The alpha value [0..255] of the gap between scanlines.
FloatSetting & getBrightnessSetting()
Brightness video setting.
A Setting with a floating point value.
Definition: FloatSetting.hh:10
bool getDeinterlace() const
Deinterlacing [on, off].
FloatSetting & getGammaSetting()
The amount of gamma correction.
IntegerSetting & getMaxFrameSkipSetting()
The current max frameskip.
int getGlow() const
The amount of glow [0..100].
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.
double getDouble() const noexcept
Definition: FloatSetting.hh:20
bool getBoolean() const noexcept
StringSetting & getColorMatrixSetting()
Color matrix setting.
RendererSetting & getRendererSetting()
The current renderer.
A Setting with an integer value.
FloatSetting & getNoiseSetting()
The amount of noise to add to the frame.
IntegerSetting & getMinFrameSkipSetting()
The current min frameskip.
ScaleAlgorithm getScaleAlgorithm() const
The current scaling algorithm.
int getBlurFactor() const
The amount of horizontal blur [0..256].
float getScanlineGap() const
The amount of space [0..1] between scanlines.
bool isColorMatrixIdentity()
Returns true iff the current color matrix is the identity matrix.
Accuracy
Render accuracy: granularity of the rendered area.
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
RenderSettings(CommandController &commandController)
bool getDeflicker() const
Deflicker [on, off].
Accuracy getAccuracy() const
Accuracy [screen, line, pixel].
BooleanSetting & getLimitSpritesSetting()
Limit number of sprites per line? If true, limit number of sprites per line as real VDP does...
float transformComponent(float c) const
Apply brightness, contrast and gamma transformation on the input color component. ...
float getHorizontalStretch() const
RendererID getRenderer() const
gl::vec3 transformRGB(gl::vec3 rgb) const
Apply brightness, contrast and gamma transformation on the input color.
EnumSetting< bool > & getCmdTimingSetting()
CmdTiming [real, broken].
FloatSetting & getHorizontalStretchSetting()
Amount of horizontal stretch.
int getInt() const noexcept
float getBrightness() const
Class containing all settings for renderers.
bool getInterleaveBlackFrame() const
Is black frame interleaving enabled?
float getPointerHideDelay() const
BooleanSetting & getFullScreenSetting()
Full screen [on, off].
Generic Gang-of-Four Observer class, templatized edition.
Definition: Observer.hh:9
FloatSetting & getPointerHideDelaySetting()
The amount of time until the pointer is hidden in the openMSX window.
EnumSetting< bool > & getTooFastAccessSetting()
TooFastAccess [real, ignored].
bool getDisableSprites() const
Disable sprite rendering?
ScaleAlgorithm
Scaler algorithm.
IntegerSetting & getScaleFactorSetting()
The current scaling factor.