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
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:253
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
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:17
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:21
openmsx::RenderSettings::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: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:10
openmsx::RenderSettings::getMaxFrameSkipSetting
IntegerSetting & getMaxFrameSkipSetting()
The current max frameskip.
Definition: RenderSettings.hh:59
openmsx::RenderSettings::getHorizontalStretch
float getHorizontalStretch() const
Definition: RenderSettings.hh:153
openmsx::RenderSettings::getHorizontalStretchSetting
FloatSetting & getHorizontalStretchSetting()
Amount of horizontal stretch.
Definition: RenderSettings.hh:150
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:259
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: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:67
openmsx::RenderSettings::getPointerHideDelaySetting
FloatSetting & getPointerHideDelaySetting()
The amount of time until the pointer is hidden in the openMSX window.
Definition: RenderSettings.hh:159
openmsx::RenderSettings::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
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:71
openmsx::RenderSettings::RendererID
RendererID
Enumeration of Renderers known to openMSX.
Definition: RenderSettings.hh:27
openmsx::RenderSettings::UNINITIALIZED
Definition: RenderSettings.hh:27
Observer.hh
openmsx::RenderSettings::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
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
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:223
openmsx::RenderSettings::isColorMatrixIdentity
bool isColorMatrixIdentity()
Returns true iff the current color matrix is the identity matrix.
Definition: RenderSettings.hh:85
openmsx::RenderSettings::SCALER_RGBTRIPLET
Definition: RenderSettings.hh:38
openmsx::RenderSettings::SCALER_HQLITE
Definition: RenderSettings.hh:38
EnumSetting.hh
openmsx::RenderSettings::SCALER_HQ
Definition: RenderSettings.hh:38
openmsx::RenderSettings::getRenderer
RendererID getRenderer() const
Definition: RenderSettings.hh:111
openmsx::RenderSettings::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
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:162
openmsx::RenderSettings::getMinFrameSkip
int getMinFrameSkip() const
Definition: RenderSettings.hh:64
openmsx::RenderSettings::ACC_SCREEN
Definition: RenderSettings.hh:32
openmsx::RenderSettings::getMaxFrameSkip
int getMaxFrameSkip() const
Definition: RenderSettings.hh:60
openmsx::RenderSettings::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:80
openmsx::RenderSettings::getDeflicker
bool getDeflicker() const
Deflicker [on, off].
Definition: RenderSettings.hh:56
openmsx::TclObject
Definition: TclObject.hh:21
openmsx::RenderSettings::SCALER_SIMPLE
Definition: RenderSettings.hh:37
openmsx::RenderSettings::getCmdTimingSetting
EnumSetting< bool > & getCmdTimingSetting()
CmdTiming [real, broken].
Definition: RenderSettings.hh:135
openmsx::RenderSettings::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:167
openmsx::Interpreter
Definition: Interpreter.hh:16
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
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::ACC_PIXEL
Definition: RenderSettings.hh:32
openmsx::RenderSettings::getRendererSetting
RendererSetting & getRendererSetting()
The current renderer.
Definition: RenderSettings.hh:110