45 rendererMap.emplace_back(
"SDLGL-PP",
SDLGL_PP);
51 : accuracySetting(commandController,
52 "accuracy",
"rendering accuracy", ACC_PIXEL,
56 {
"pixel", ACC_PIXEL}})
58 , deinterlaceSetting(commandController,
59 "deinterlace",
"deinterlacing on/off",
true)
61 , deflickerSetting(commandController,
62 "deflicker",
"deflicker on/off",
false)
64 , maxFrameSkipSetting(commandController,
65 "maxframeskip",
"set the max amount of frameskip", 3, 0, 100)
67 , minFrameSkipSetting(commandController,
68 "minframeskip",
"set the min amount of frameskip", 0, 0, 100)
70 , fullScreenSetting(commandController,
71 "fullscreen",
"full screen display on/off",
false)
73 , gammaSetting(commandController,
"gamma",
74 "amount of gamma correction: low is dark, high is bright",
77 , brightnessSetting(commandController,
"brightness",
78 "brightness video setting: "
79 "0 is normal, lower is darker, higher is brighter",
81 , contrastSetting(commandController,
"contrast",
82 "contrast video setting: "
83 "0 is normal, lower is less contrast, higher is more contrast",
86 , colorMatrixSetting(commandController,
88 "3x3 matrix to transform MSX RGB to host RGB, see manual for details",
89 "{ 1 0 0 } { 0 1 0 } { 0 0 1 }")
91 , glowSetting(commandController,
92 "glow",
"amount of afterglow effect: 0 = none, 100 = lots",
95 , noiseSetting(commandController,
96 "noise",
"amount of noise to add to the frame",
99 , rendererSetting(commandController,
100 "renderer",
"rendering back-end used to display the MSX screen",
108 , horizontalBlurSetting(commandController,
109 "blur",
"amount of horizontal blur effect: 0 = none, 100 = full",
112 , scaleAlgorithmSetting(
113 commandController,
"scale_algorithm",
"scale algorithm",
114 SCALER_SIMPLE, getScalerMap())
116 , scaleFactorSetting(commandController,
117 "scale_factor",
"scale factor",
120 , scanlineAlphaSetting(commandController,
121 "scanline",
"amount of scanline effect: 0 = none, 100 = full",
124 , limitSpritesSetting(commandController,
125 "limitsprites",
"limit number of sprites per line "
126 "(on for realism, off to reduce sprite flashing)",
true)
128 , disableSpritesSetting(commandController,
129 "disablesprites",
"disable sprite rendering",
130 false, Setting::DONT_SAVE)
132 , cmdTimingSetting(commandController,
133 "cmdtiming",
"VDP command timing",
false,
137 , tooFastAccessSetting(commandController,
138 "too_fast_vram_access",
139 "Should too fast VDP VRAM access be correctly emulated.\n"
140 "Possible values are:\n"
141 " real -> too fast accesses are dropped\n"
142 " ignore -> access speed is ignored, all accesses are executed",
147 , displayDeformSetting(
149 "display_deform",
"Display deform (for the moment this only "
150 "works with the SDLGL-PP renderer)", DEFORM_NORMAL,
152 {
"normal", DEFORM_NORMAL},
155 , vSyncSetting(commandController,
156 "vsync",
"Synchronize page flip with the host screen vertical sync:\n"
157 " on -> flip on host vsync: avoids tearing\n"
158 " off -> immediate flip: might be more fluent when host framerate"
159 " (typically 60Hz) differs from MSX framerate (50 or 60Hz)\n"
160 "Currently this only affects the SDLGL-PP renderer.",
166 , horizontalStretchSetting(commandController,
167 "horizontal_stretch",
168 "Amount of horizontal stretch: this many MSX pixels will be "
169 "stretched over the complete width of the output screen.\n"
170 " 320 = no stretch\n"
171 " 256 = max stretch (no border visible anymore)\n"
172 " good values are 272 or 280\n"
173 "This setting has only effect when using the SDLGL-PP renderer.",
176 , pointerHideDelaySetting(commandController,
177 "pointer_hide_delay",
178 "number of seconds after which the mouse pointer is hidden in the openMSX "
179 "window; negative = no hiding, 0 = immediately",
182 , interleaveBlackFrameSetting(commandController,
183 "interleave_black_frame",
184 "Insert a black frame in between each normal MSX frame. "
185 "Useful on (100Hz+) lightboost enabled monitors to reduce "
186 "motion blur and double frame artifacts.",
189 brightnessSetting.attach(*
this);
190 contrastSetting .attach(*
this);
191 updateBrightnessAndContrast();
193 auto& interp = commandController.getInterpreter();
194 colorMatrixSetting.setChecker([
this, &interp](TclObject& newValue) {
196 parseColorMatrix(interp, newValue);
197 }
catch (CommandException&
e) {
198 throw CommandException(
199 "Invalid color matrix: ",
e.getMessage());
203 parseColorMatrix(interp, colorMatrixSetting.getValue());
204 }
catch (MSXException&
e) {
205 std::cerr <<
e.getMessage() <<
'\n';
219 rendererSetting.setDontSaveValue(TclObject(
"none"));
222 if (rendererSetting.getEnum() ==
DUMMY) {
223 rendererSetting.setValue(rendererSetting.getDefaultValue());
226 rendererSetting.setRestoreValue(rendererSetting.getValue());
228 rendererSetting.setEnum(
DUMMY);
231RenderSettings::~RenderSettings()
233 brightnessSetting.detach(*
this);
234 contrastSetting .detach(*
this);
239 if (&
setting == &brightnessSetting) {
240 updateBrightnessAndContrast();
241 }
else if (&
setting == &contrastSetting) {
242 updateBrightnessAndContrast();
248void RenderSettings::updateBrightnessAndContrast()
250 float contrastValue = getContrast();
251 contrast = (contrastValue >= 0.0f) ? (1.0f + contrastValue / 25.0f)
252 : (1.0f + contrastValue / 125.0f);
253 brightness = (getBrightness() / 100.0f - 0.5f) * contrast + 0.5f;
256static float conv2(
float x,
float gamma)
258 return ::powf(
std::clamp(x, 0.0f, 1.0f), gamma);
261float RenderSettings::transformComponent(
float c)
const
263 float c2 = c * contrast + brightness;
264 return conv2(c2, 1.0f / getGamma());
269 auto [r,
g, b] = colorMatrix * (rgb * contrast +
vec3(brightness));
270 float gamma = 1.0f / getGamma();
271 return {conv2(r, gamma),
281 bool identity =
true;
282 for (
auto i :
xrange(3)) {
284 if (row.getListLength(interp) != 3) {
285 throw CommandException(
"each row must have 3 elements");
287 for (
auto j :
xrange(3)) {
288 TclObject element = row.getListIndex(interp, j);
289 float val = element.getFloat(interp);
290 colorMatrix[j][i] = val;
291 identity &= (val == (i == j ? 1.0f : 0.0f));
294 cmIdentity = identity;
Accuracy
Render accuracy: granularity of the rendered area.
RenderSettings(CommandController &commandController)
unsigned getListLength(Interpreter &interp) const
TclObject getListIndex(Interpreter &interp, unsigned index) const
static const bool RELEASE
constexpr vecN< N, T > min(const vecN< N, T > &x, const vecN< N, T > &y)
constexpr vecN< N, T > clamp(const vecN< N, T > &x, const vecN< N, T > &minVal, const vecN< N, T > &maxVal)
This file implemented 3 utility functions:
constexpr auto xrange(T e)