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 
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 
151  return horizontalStretchSetting;
152  }
153  float getHorizontalStretch() const {
154  return horizontalStretchSetting.getDouble();
155  }
156 
160  return pointerHideDelaySetting;
161  }
162  float getPointerHideDelay() const {
163  return pointerHideDelaySetting.getDouble();
164  }
165 
167  bool getInterleaveBlackFrame() const {
168  return interleaveBlackFrameSetting.getBoolean();
169  }
170 
178  float transformComponent(float c) const;
179 
186  gl::vec3 transformRGB(gl::vec3 rgb) const;
187 
188 private:
189  static EnumSetting<ScaleAlgorithm>::Map getScalerMap();
190  static EnumSetting<RendererID>::Map getRendererMap();
191 
192  // Observer:
193  void update(const Setting& setting) override;
194 
198  void updateBrightnessAndContrast();
199 
200  void parseColorMatrix(Interpreter& interp, const TclObject& value);
201 
202  EnumSetting<Accuracy> accuracySetting;
203  BooleanSetting deinterlaceSetting;
204  BooleanSetting deflickerSetting;
205  IntegerSetting maxFrameSkipSetting;
206  IntegerSetting minFrameSkipSetting;
207  BooleanSetting fullScreenSetting;
208  FloatSetting gammaSetting;
209  FloatSetting brightnessSetting;
210  FloatSetting contrastSetting;
211  StringSetting colorMatrixSetting;
212  IntegerSetting glowSetting;
213  FloatSetting noiseSetting;
214  RendererSetting rendererSetting;
215  IntegerSetting horizontalBlurSetting;
216  EnumSetting<ScaleAlgorithm> scaleAlgorithmSetting;
217  IntegerSetting scaleFactorSetting;
218  IntegerSetting scanlineAlphaSetting;
219  BooleanSetting limitSpritesSetting;
220  BooleanSetting disableSpritesSetting;
221  EnumSetting<bool> cmdTimingSetting;
222  EnumSetting<bool> tooFastAccessSetting;
223  EnumSetting<DisplayDeform> displayDeformSetting;
224  FloatSetting horizontalStretchSetting;
225  FloatSetting pointerHideDelaySetting;
226  BooleanSetting interleaveBlackFrameSetting;
227 
228  float brightness;
229  float contrast;
230 
232  gl::mat3 colorMatrix;
234  bool cmIdentity;
235 };
236 
237 } // namespace openmsx
238 
239 #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.