Skip to content

Commit ccdb3fb

Browse files
committed
Added remaining settings.
Also fixed and improved some windowing stuff. The current window position can now be copied to the settings, so the window should be placed at this exact position on the next startup.
1 parent 5696e85 commit ccdb3fb

11 files changed

+505
-64
lines changed

src/ProjectMSDLApplication.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ void ProjectMSDLApplication::defineOptions(Poco::Util::OptionSet& options)
165165
false, "<0/1>", true)
166166
.binding("window.waitForVerticalSync", _commandLineOverrides));
167167

168+
options.addOption(Option("vsyncAdaptive", "",
169+
"If true and vsync is enabled, tries to use adaptive vsync. Set FPS to 0 for best results.",
170+
false, "<0/1>", true)
171+
.binding("window.adaptiveVerticalSync", _commandLineOverrides));
172+
168173
options.addOption(Option("width", "", "Initial window width.",
169174
false, "<number>", true)
170175
.binding("window.width", _commandLineOverrides));

src/ProjectMWrapper.cpp

+54-8
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,24 @@ void ProjectMWrapper::initialize(Poco::Util::Application& app)
3737

3838
_projectM = projectm_create();
3939

40+
int fps = _projectMConfigView->getInt("fps", 60);
41+
if (fps <= 0)
42+
{
43+
// We don't know the target framerate, pass in a default of 60.
44+
fps = 60;
45+
}
46+
4047
projectm_set_window_size(_projectM, canvasWidth, canvasHeight);
41-
projectm_set_fps(_projectM, _projectMConfigView->getInt("fps", 60));
42-
projectm_set_mesh_size(_projectM, _projectMConfigView->getInt("meshX", 220), _projectMConfigView->getInt("meshY", 125));
48+
projectm_set_fps(_projectM, fps);
49+
projectm_set_mesh_size(_projectM, _projectMConfigView->getInt("meshX", 48), _projectMConfigView->getInt("meshY", 32));
4350
projectm_set_aspect_correction(_projectM, _projectMConfigView->getBool("aspectCorrectionEnabled", true));
4451
projectm_set_preset_locked(_projectM, _projectMConfigView->getBool("presetLocked", false));
4552

4653
// Preset display settings
47-
projectm_set_preset_duration(_projectM, _projectMConfigView->getInt("displayDuration", 30));
48-
projectm_set_soft_cut_duration(_projectM, _projectMConfigView->getInt("transitionDuration", 3));
54+
projectm_set_preset_duration(_projectM, _projectMConfigView->getDouble("displayDuration", 30.0));
55+
projectm_set_soft_cut_duration(_projectM, _projectMConfigView->getDouble("transitionDuration", 3.0));
4956
projectm_set_hard_cut_enabled(_projectM, _projectMConfigView->getBool("hardCutsEnabled", false));
50-
projectm_set_hard_cut_duration(_projectM, _projectMConfigView->getInt("hardCutDuration", 20));
57+
projectm_set_hard_cut_duration(_projectM, _projectMConfigView->getDouble("hardCutDuration", 20.0));
5158
projectm_set_hard_cut_sensitivity(_projectM, static_cast<float>(_projectMConfigView->getDouble("hardCutSensitivity", 1.0)));
5259
projectm_set_beat_sensitivity(_projectM, static_cast<float>(_projectMConfigView->getDouble("beatSensitivity", 1.0)));
5360

@@ -81,7 +88,6 @@ void ProjectMWrapper::initialize(Poco::Util::Application& app)
8188
// be sure what the link exactly points to, especially if a trailing slash is missing.
8289
projectm_playlist_add_path(_playlist, presetPath.c_str(), true, false);
8390
}
84-
8591
}
8692
projectm_playlist_sort(_playlist, 0, projectm_playlist_size(_playlist), SORT_PREDICATE_FILENAME_ONLY, SORT_ORDER_ASCENDING);
8793

@@ -129,6 +135,11 @@ int ProjectMWrapper::TargetFPS()
129135
return _projectMConfigView->getInt("fps", 60);
130136
}
131137

138+
void ProjectMWrapper::UpdateRealFPS(float fps)
139+
{
140+
projectm_set_fps(_projectM, static_cast<uint32_t>(std::round(fps)));
141+
}
142+
132143
void ProjectMWrapper::RenderFrame() const
133144
{
134145
glClearColor(0.0, 0.0, 0.0, 0.0);
@@ -250,12 +261,47 @@ void ProjectMWrapper::OnConfigurationPropertyRemoved(const std::string& key)
250261

251262
if (key == "projectM.presetLocked")
252263
{
253-
projectm_set_preset_locked(_projectM, _projectMConfigView->getBool("presetLocked"));
264+
projectm_set_preset_locked(_projectM, _projectMConfigView->getBool("presetLocked", false));
254265
Poco::NotificationCenter::defaultCenter().postNotification(new UpdateWindowTitleNotification);
255266
}
256267

257268
if (key == "projectM.shuffleEnabled")
258269
{
259-
projectm_playlist_set_shuffle(_playlist, _projectMConfigView->getBool("shuffleEnabled"));
270+
projectm_playlist_set_shuffle(_playlist, _projectMConfigView->getBool("shuffleEnabled", true));
271+
}
272+
273+
if (key == "projectM.aspectCorrectionEnabled")
274+
{
275+
projectm_set_aspect_correction(_projectM, _projectMConfigView->getBool("aspectCorrectionEnabled", true));
276+
}
277+
278+
if (key == "projectM.displayDuration")
279+
{
280+
projectm_set_preset_duration(_projectM, _projectMConfigView->getDouble("displayDuration", 30.0));
281+
}
282+
283+
if (key == "projectM.transitionDuration")
284+
{
285+
projectm_set_soft_cut_duration(_projectM, _projectMConfigView->getDouble("transitionDuration", 3.0));
286+
}
287+
288+
if (key == "projectM.hardCutsEnabled")
289+
{
290+
projectm_set_aspect_correction(_projectM, _projectMConfigView->getBool("hardCutsEnabled", false));
291+
}
292+
293+
if (key == "projectM.hardCutDuration")
294+
{
295+
projectm_set_hard_cut_duration(_projectM, _projectMConfigView->getDouble("hardCutDuration", 20.0));
296+
}
297+
298+
if (key == "projectM.hardCutSensitivity")
299+
{
300+
projectm_set_hard_cut_sensitivity(_projectM, static_cast<float>(_projectMConfigView->getDouble("hardCutSensitivity", 1.0)));
301+
}
302+
303+
if (key == "projectM.meshX" || key == "projectM.meshY")
304+
{
305+
projectm_set_mesh_size(_projectM, _projectMConfigView->getUInt64("meshX", 48), _projectMConfigView->getUInt64("meshY", 32));
260306
}
261307
}

src/ProjectMWrapper.h

+10
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,18 @@ class ProjectMWrapper : public Poco::Util::Subsystem
3939
*/
4040
void RenderFrame() const;
4141

42+
/**
43+
* @brief Returns the targeted FPS value.
44+
* @return The user-configured target FPS. Can be 0, which means unlimited.
45+
*/
4246
int TargetFPS();
4347

48+
/**
49+
* @brief Updates projectM with the current, actual FPS value.
50+
* @param fps The current FPS value.
51+
*/
52+
void UpdateRealFPS(float fps);
53+
4454
/**
4555
* @brief If splash is disabled, shows the initial preset.
4656
* If shuffle is on, a random preset will be picked. Otherwise, the first playlist item is displayed.

src/RenderLoop.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ RenderLoop::RenderLoop()
2323
void RenderLoop::Run()
2424
{
2525
FPSLimiter limiter;
26-
limiter.TargetFPS(_projectMWrapper.TargetFPS());
2726

2827
auto& notificationCenter{Poco::NotificationCenter::defaultCenter()};
2928

@@ -33,6 +32,7 @@ void RenderLoop::Run()
3332

3433
while (!_wantsToQuit)
3534
{
35+
limiter.TargetFPS(_projectMWrapper.TargetFPS());
3636
limiter.StartFrame();
3737

3838
PollEvents();
@@ -44,6 +44,9 @@ void RenderLoop::Run()
4444
_sdlRenderingWindow.Swap();
4545

4646
limiter.EndFrame();
47+
48+
// Pass projectM the actual FPS value of the last frame.
49+
_projectMWrapper.UpdateRealFPS(limiter.FPS());
4750
}
4851

4952
notificationCenter.removeObserver(_quitNotificationObserver);

0 commit comments

Comments
 (0)