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#include "narrow.hh"
12
13namespace openmsx {
14
15class CommandController;
16class Interpreter;
17
22class RenderSettings final : private Observer<Setting>
23{
24public:
30
33 enum class Accuracy { SCREEN, LINE, PIXEL };
34
37 enum class ScaleAlgorithm {
39 NO
40 };
41
42 enum class DisplayDeform {
43 NORMAL, _3D
44 };
45
46 explicit RenderSettings(CommandController& commandController);
48
50 [[nodiscard]] EnumSetting<Accuracy>& getAccuracySetting() { return accuracySetting; }
51 [[nodiscard]] Accuracy getAccuracy() const { return accuracySetting.getEnum(); }
52
54 [[nodiscard]] BooleanSetting& getDeinterlaceSetting() { return deinterlaceSetting; }
55 [[nodiscard]] bool getDeinterlace() const { return deinterlaceSetting.getBoolean(); }
56
58 [[nodiscard]] BooleanSetting& getDeflickerSetting() { return deflickerSetting; }
59 [[nodiscard]] bool getDeflicker() const { return deflickerSetting.getBoolean(); }
60
62 [[nodiscard]] IntegerSetting& getMaxFrameSkipSetting() { return maxFrameSkipSetting; }
63 [[nodiscard]] int getMaxFrameSkip() const { return maxFrameSkipSetting.getInt(); }
64
66 [[nodiscard]] IntegerSetting& getMinFrameSkipSetting() { return minFrameSkipSetting; }
67 [[nodiscard]] int getMinFrameSkip() const { return minFrameSkipSetting.getInt(); }
68
70 [[nodiscard]] BooleanSetting& getFullScreenSetting() { return fullScreenSetting; }
71 [[nodiscard]] bool getFullScreen() const { return fullScreenSetting.getBoolean(); }
72
74 [[nodiscard]] FloatSetting& getGammaSetting() { return gammaSetting; }
75 [[nodiscard]] float getGamma() const { return gammaSetting.getFloat(); }
76
78 [[nodiscard]] FloatSetting& getBrightnessSetting() { return brightnessSetting; }
79 [[nodiscard]] float getBrightness() const { return brightnessSetting.getFloat(); }
80
82 [[nodiscard]] FloatSetting& getContrastSetting() { return contrastSetting; }
83 [[nodiscard]] float getContrast() const { return contrastSetting.getFloat(); }
84
86 [[nodiscard]] StringSetting& getColorMatrixSetting() { return colorMatrixSetting; }
88 [[nodiscard]] bool isColorMatrixIdentity() const { return cmIdentity; }
89
91 [[nodiscard]] IntegerSetting& getGlowSetting() { return glowSetting; }
92 [[nodiscard]] int getGlow() const { return glowSetting.getInt(); }
93
95 [[nodiscard]] FloatSetting& getNoiseSetting() { return noiseSetting; }
96 [[nodiscard]] float getNoise() const { return noiseSetting.getFloat(); }
97
99 [[nodiscard]] IntegerSetting& getBlurSetting() { return horizontalBlurSetting; }
100 [[nodiscard]] int getBlurFactor() const {
101 return (horizontalBlurSetting.getInt()) * 256 / 100;
102 }
103
105 [[nodiscard]] IntegerSetting& getScanlineSetting() { return scanlineAlphaSetting; }
106 [[nodiscard]] int getScanlineFactor() const {
107 return 255 - ((scanlineAlphaSetting.getInt() * 255) / 100);
108 }
110 [[nodiscard]] float getScanlineGap() const {
111 return narrow<float>(scanlineAlphaSetting.getInt()) * 0.01f;
112 }
113
115 [[nodiscard]] RendererSetting& getRendererSetting() { return rendererSetting; }
116 [[nodiscard]] RendererID getRenderer() const {
117 auto r = rendererSetting.getEnum();
119 }
120
122 [[nodiscard]] auto& getScaleAlgorithmSetting() { return scaleAlgorithmSetting; }
123 [[nodiscard]] ScaleAlgorithm getScaleAlgorithm() const {
124 return scaleAlgorithmSetting.getEnum();
125 }
126
128 [[nodiscard]] IntegerSetting& getScaleFactorSetting() { return scaleFactorSetting; }
129 [[nodiscard]] int getScaleFactor() const { return scaleFactorSetting.getInt(); }
130
137 [[nodiscard]] BooleanSetting& getLimitSpritesSetting() { return limitSpritesSetting; }
138
140 [[nodiscard]] BooleanSetting& getDisableSpritesSetting() { return disableSpritesSetting; }
141 [[nodiscard]] bool getDisableSprites() const { return disableSpritesSetting.getBoolean(); }
142
145 [[nodiscard]] EnumSetting<bool>& getCmdTimingSetting() { return cmdTimingSetting; }
146
151 [[nodiscard]] EnumSetting<bool>& getTooFastAccessSetting() { return tooFastAccessSetting; }
152
154 [[nodiscard]] auto& getDisplayDeformSetting() { return displayDeformSetting; }
155 [[nodiscard]] DisplayDeform getDisplayDeform() const { return displayDeformSetting.getEnum(); }
156
158 [[nodiscard]] BooleanSetting& getVSyncSetting() { return vSyncSetting; }
159
164 return horizontalStretchSetting;
165 }
166 [[nodiscard]] float getHorizontalStretch() const {
167 return horizontalStretchSetting.getFloat();
168 }
169
173 return pointerHideDelaySetting;
174 }
175 [[nodiscard]] float getPointerHideDelay() const {
176 return pointerHideDelaySetting.getFloat();
177 }
178
180 [[nodiscard]] bool getInterleaveBlackFrame() const {
181 return interleaveBlackFrameSetting.getBoolean();
182 }
183
191 [[nodiscard]] float transformComponent(float c) const;
192
199 [[nodiscard]] gl::vec3 transformRGB(gl::vec3 rgb) const;
200
201private:
202 [[nodiscard]] static EnumSetting<ScaleAlgorithm>::Map getScalerMap();
203 [[nodiscard]] static EnumSetting<RendererID>::Map getRendererMap();
204
205 // Observer:
206 void update(const Setting& setting) noexcept override;
207
211 void updateBrightnessAndContrast();
212
213 void parseColorMatrix(Interpreter& interp, const TclObject& value);
214
215private:
216 EnumSetting<Accuracy> accuracySetting;
217 BooleanSetting deinterlaceSetting;
218 BooleanSetting deflickerSetting;
219 IntegerSetting maxFrameSkipSetting;
220 IntegerSetting minFrameSkipSetting;
221 BooleanSetting fullScreenSetting;
222 FloatSetting gammaSetting;
223 FloatSetting brightnessSetting;
224 FloatSetting contrastSetting;
225 StringSetting colorMatrixSetting;
226 IntegerSetting glowSetting;
227 FloatSetting noiseSetting;
228 RendererSetting rendererSetting;
229 IntegerSetting horizontalBlurSetting;
230 EnumSetting<ScaleAlgorithm> scaleAlgorithmSetting;
231 IntegerSetting scaleFactorSetting;
232 IntegerSetting scanlineAlphaSetting;
233 BooleanSetting limitSpritesSetting;
234 BooleanSetting disableSpritesSetting;
235 EnumSetting<bool> cmdTimingSetting;
236 EnumSetting<bool> tooFastAccessSetting;
237 EnumSetting<DisplayDeform> displayDeformSetting;
238 BooleanSetting vSyncSetting;
239 FloatSetting horizontalStretchSetting;
240 FloatSetting pointerHideDelaySetting;
241 BooleanSetting interleaveBlackFrameSetting;
242
243 float brightness;
244 float contrast;
245
247 gl::mat3 colorMatrix;
249 bool cmIdentity;
250};
251
252} // namespace openmsx
253
254#endif
BaseSetting * setting
bool getBoolean() const noexcept
EnumSettingBase::Map Map
T getEnum() const noexcept
A Setting with a floating point value.
float getFloat() const noexcept
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.
BooleanSetting & getDeinterlaceSetting()
Deinterlacing [on, off].
IntegerSetting & getBlurSetting()
The amount of horizontal blur [0..256].
EnumSetting< bool > & getCmdTimingSetting()
CmdTiming [real, broken].
RendererSetting & getRendererSetting()
The current renderer.
auto & getScaleAlgorithmSetting()
The current scaling algorithm.
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.
bool isColorMatrixIdentity() const
Returns true iff the current color matrix is the identity matrix.
FloatSetting & getPointerHideDelaySetting()
The amount of time until the pointer is hidden in the openMSX window.
Accuracy
Render accuracy: granularity of the rendered area.
FloatSetting & getContrastSetting()
Contrast video setting.
BooleanSetting & getDisableSpritesSetting()
Disable sprite rendering?
bool getInterleaveBlackFrame() const
Is black frame interleaving enabled?
FloatSetting & getNoiseSetting()
The amount of noise to add to the frame.
IntegerSetting & getMinFrameSkipSetting()
The current min frameskip.
float getScanlineGap() const
The amount of space [0..1] between scanlines.
EnumSetting< Accuracy > & getAccuracySetting()
Accuracy [screen, line, pixel].
BooleanSetting & getFullScreenSetting()
Full screen [on, off].
IntegerSetting & getScaleFactorSetting()
The current scaling factor.
RendererID getRenderer() const
Accuracy getAccuracy() const
float getHorizontalStretch() const
FloatSetting & getBrightnessSetting()
Brightness video setting.
float getPointerHideDelay() const
EnumSetting< RendererID > RendererSetting
BooleanSetting & getVSyncSetting()
VSync [on, off].
IntegerSetting & getGlowSetting()
The amount of glow [0..100].
IntegerSetting & getScanlineSetting()
The alpha value [0..255] of the gap between scanlines.
DisplayDeform getDisplayDeform() const
FloatSetting & getGammaSetting()
The amount of gamma correction.
EnumSetting< bool > & getTooFastAccessSetting()
TooFastAccess [real, ignored].
ScaleAlgorithm
Scaler algorithm.
BooleanSetting & getDeflickerSetting()
Deflicker [on, off].
auto & getDisplayDeformSetting()
Display deformation (normal, 3d).
RendererID
Enumeration of Renderers known to openMSX.
FloatSetting & getHorizontalStretchSetting()
Amount of horizontal stretch.
IntegerSetting & getMaxFrameSkipSetting()
The current max frameskip.
StringSetting & getColorMatrixSetting()
Color matrix setting.
BooleanSetting & getLimitSpritesSetting()
Limit number of sprites per line? If true, limit number of sprites per line as real VDP does.
ScaleAlgorithm getScaleAlgorithm() const
This file implemented 3 utility functions:
Definition Autofire.cc:11