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
34
41 };
42
45 };
46
47 explicit RenderSettings(CommandController& commandController);
49
51 [[nodiscard]] Accuracy getAccuracy() const { return accuracySetting.getEnum(); }
52
54 [[nodiscard]] bool getDeinterlace() const { return deinterlaceSetting.getBoolean(); }
55
57 [[nodiscard]] bool getDeflicker() const { return deflickerSetting.getBoolean(); }
58
60 [[nodiscard]] IntegerSetting& getMaxFrameSkipSetting() { return maxFrameSkipSetting; }
61 [[nodiscard]] int getMaxFrameSkip() const { return maxFrameSkipSetting.getInt(); }
62
64 [[nodiscard]] IntegerSetting& getMinFrameSkipSetting() { return minFrameSkipSetting; }
65 [[nodiscard]] int getMinFrameSkip() const { return minFrameSkipSetting.getInt(); }
66
68 [[nodiscard]] BooleanSetting& getFullScreenSetting() { return fullScreenSetting; }
69 [[nodiscard]] bool getFullScreen() const { return fullScreenSetting.getBoolean(); }
70
72 [[nodiscard]] FloatSetting& getGammaSetting() { return gammaSetting; }
73 [[nodiscard]] float getGamma() const { return gammaSetting.getFloat(); }
74
76 [[nodiscard]] FloatSetting& getBrightnessSetting() { return brightnessSetting; }
77 [[nodiscard]] float getBrightness() const { return brightnessSetting.getFloat(); }
78
80 [[nodiscard]] FloatSetting& getContrastSetting() { return contrastSetting; }
81 [[nodiscard]] float getContrast() const { return contrastSetting.getFloat(); }
82
84 [[nodiscard]] StringSetting& getColorMatrixSetting() { return colorMatrixSetting; }
86 [[nodiscard]] bool isColorMatrixIdentity() const { return cmIdentity; }
87
89 [[nodiscard]] int getGlow() const { return glowSetting.getInt(); }
90
92 [[nodiscard]] FloatSetting& getNoiseSetting() { return noiseSetting; }
93 [[nodiscard]] float getNoise() const { return noiseSetting.getFloat(); }
94
96 [[nodiscard]] int getBlurFactor() const {
97 return (horizontalBlurSetting.getInt()) * 256 / 100;
98 }
99
101 [[nodiscard]] int getScanlineFactor() const {
102 return 255 - ((scanlineAlphaSetting.getInt() * 255) / 100);
103 }
104
106 [[nodiscard]] float getScanlineGap() const {
107 return narrow<float>(scanlineAlphaSetting.getInt()) * 0.01f;
108 }
109
111 [[nodiscard]] RendererSetting& getRendererSetting() { return rendererSetting; }
112 [[nodiscard]] RendererID getRenderer() const { return rendererSetting.getEnum(); }
113
115 [[nodiscard]] ScaleAlgorithm getScaleAlgorithm() const {
116 return scaleAlgorithmSetting.getEnum();
117 }
118
120 [[nodiscard]] IntegerSetting& getScaleFactorSetting() { return scaleFactorSetting; }
121 [[nodiscard]] int getScaleFactor() const { return scaleFactorSetting.getInt(); }
122
129 [[nodiscard]] BooleanSetting& getLimitSpritesSetting() { return limitSpritesSetting; }
130
132 [[nodiscard]] bool getDisableSprites() const { return disableSpritesSetting.getBoolean(); }
133
136 [[nodiscard]] EnumSetting<bool>& getCmdTimingSetting() { return cmdTimingSetting; }
137
142 [[nodiscard]] EnumSetting<bool>& getTooFastAccessSetting() { return tooFastAccessSetting; }
143
146 [[nodiscard]] DisplayDeform getDisplayDeform() { return displayDeformSetting.getEnum(); }
147
150 [[nodiscard]] BooleanSetting& getVSyncSetting() { return vSyncSetting; }
151
156 return horizontalStretchSetting;
157 }
158 [[nodiscard]] float getHorizontalStretch() const {
159 return horizontalStretchSetting.getFloat();
160 }
161
165 return pointerHideDelaySetting;
166 }
167 [[nodiscard]] float getPointerHideDelay() const {
168 return pointerHideDelaySetting.getFloat();
169 }
170
172 [[nodiscard]] bool getInterleaveBlackFrame() const {
173 return interleaveBlackFrameSetting.getBoolean();
174 }
175
183 [[nodiscard]] float transformComponent(float c) const;
184
191 [[nodiscard]] gl::vec3 transformRGB(gl::vec3 rgb) const;
192
193private:
194 [[nodiscard]] static EnumSetting<ScaleAlgorithm>::Map getScalerMap();
195 [[nodiscard]] static EnumSetting<RendererID>::Map getRendererMap();
196
197 // Observer:
198 void update(const Setting& setting) noexcept override;
199
203 void updateBrightnessAndContrast();
204
205 void parseColorMatrix(Interpreter& interp, const TclObject& value);
206
207private:
208 EnumSetting<Accuracy> accuracySetting;
209 BooleanSetting deinterlaceSetting;
210 BooleanSetting deflickerSetting;
211 IntegerSetting maxFrameSkipSetting;
212 IntegerSetting minFrameSkipSetting;
213 BooleanSetting fullScreenSetting;
214 FloatSetting gammaSetting;
215 FloatSetting brightnessSetting;
216 FloatSetting contrastSetting;
217 StringSetting colorMatrixSetting;
218 IntegerSetting glowSetting;
219 FloatSetting noiseSetting;
220 RendererSetting rendererSetting;
221 IntegerSetting horizontalBlurSetting;
222 EnumSetting<ScaleAlgorithm> scaleAlgorithmSetting;
223 IntegerSetting scaleFactorSetting;
224 IntegerSetting scanlineAlphaSetting;
225 BooleanSetting limitSpritesSetting;
226 BooleanSetting disableSpritesSetting;
227 EnumSetting<bool> cmdTimingSetting;
228 EnumSetting<bool> tooFastAccessSetting;
229 EnumSetting<DisplayDeform> displayDeformSetting;
230 BooleanSetting vSyncSetting;
231 FloatSetting horizontalStretchSetting;
232 FloatSetting pointerHideDelaySetting;
233 BooleanSetting interleaveBlackFrameSetting;
234
235 float brightness;
236 float contrast;
237
239 gl::mat3 colorMatrix;
241 bool cmIdentity;
242};
243
244} // namespace openmsx
245
246#endif
BaseSetting * setting
Definition: Interpreter.cc:28
bool getBoolean() const noexcept
T getEnum() const noexcept
Definition: EnumSetting.hh:112
A Setting with a floating point value.
Definition: FloatSetting.hh:11
float getFloat() const noexcept
Definition: FloatSetting.hh:21
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].
EnumSetting< bool > & getCmdTimingSetting()
CmdTiming [real, broken].
RendererSetting & getRendererSetting()
The current renderer.
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.
int getGlow() const
The amount of glow [0..100].
int getScanlineFactor() const
The alpha value [0..255] of the gap between scanlines.
bool getInterleaveBlackFrame() const
Is black frame interleaving enabled?
FloatSetting & getNoiseSetting()
The amount of noise to add to the frame.
RenderSettings(CommandController &commandController)
IntegerSetting & getMinFrameSkipSetting()
The current min frameskip.
float getScanlineGap() const
The amount of space [0..1] between scanlines.
BooleanSetting & getFullScreenSetting()
Full screen [on, off].
IntegerSetting & getScaleFactorSetting()
The current scaling factor.
RendererID getRenderer() const
Accuracy getAccuracy() const
Accuracy [screen, line, pixel].
float getHorizontalStretch() const
FloatSetting & getBrightnessSetting()
Brightness video setting.
float getPointerHideDelay() const
EnumSetting< RendererID > RendererSetting
BooleanSetting & getVSyncSetting()
VSync [on, off] ATM this only works when using the SDLGL-PP renderer.
FloatSetting & getGammaSetting()
The amount of gamma correction.
EnumSetting< bool > & getTooFastAccessSetting()
TooFastAccess [real, ignored].
ScaleAlgorithm
Scaler algorithm.
int getBlurFactor() const
The amount of horizontal blur [0..256].
bool getDisableSprites() const
Disable sprite rendering?
DisplayDeform getDisplayDeform()
Display deformation (normal, 3d) ATM this only works when using the SDLGL-PP renderer.
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
The current scaling algorithm.
This file implemented 3 utility functions:
Definition: Autofire.cc:9