Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/api/include/projectM-4/parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ PROJECTM_EXPORT double projectm_get_preset_duration(projectm_handle instance);

/**
* @brief Sets the per-pixel equation mesh size in units.
* @note This will currently remove any active presets and reload the default "idle" preset.
* Will internally be clamped to [8,300] in each axis. If any dimension is set to an odd value, it will be incremented by 1
* so only multiples of two are used.
* @param instance The projectM instance handle.
* @param width The new width of the mesh.
* @param height The new height of the mesh.
Expand Down
30 changes: 18 additions & 12 deletions src/libprojectM/ProjectM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,14 +429,20 @@ void ProjectM::SetMeshSize(size_t meshResolutionX, size_t meshResolutionY)
m_meshX = meshResolutionX;
m_meshY = meshResolutionY;

// Update mesh size in all sorts of classes.
//m_renderer->SetPerPixelMeshSize(m_meshX, m_meshY);
m_presetFactoryManager->initialize();
// Need multiples of two, otherwise will not render a horizontal and/or vertical bar in the center of the warp mesh.
if (m_meshX % 2 == 1)
{
m_meshX++;
}

// Unload all presets and reload idle preset
m_activePreset.reset();
m_transitioningPreset.reset();
LoadIdlePreset();
if (m_meshY % 2 == 1)
{
m_meshY++;
}

// Constrain per-pixel mesh size to sensible limits
m_meshX = std::max(static_cast<size_t>(8), std::min(static_cast<size_t>(400), m_meshX));
m_meshY = std::max(static_cast<size_t>(8), std::min(static_cast<size_t>(400), m_meshY));
}

auto ProjectM::PCM() -> libprojectM::Audio::PCM&
Expand Down Expand Up @@ -481,16 +487,16 @@ auto ProjectM::GetRenderContext() -> RenderContext
RenderContext ctx{};
ctx.viewportSizeX = m_windowWidth;
ctx.viewportSizeY = m_windowHeight;
ctx.time = m_timeKeeper->GetRunningTime();
ctx.progress = m_timeKeeper->PresetProgressA();
ctx.fps = m_targetFps;
ctx.time = static_cast<float>(m_timeKeeper->GetRunningTime());
ctx.progress = static_cast<float>(m_timeKeeper->PresetProgressA());
ctx.fps = static_cast<float>(m_targetFps);
ctx.frame = m_frameCount;
ctx.aspectX = (m_windowHeight > m_windowWidth) ? static_cast<float>(m_windowWidth) / static_cast<float>(m_windowHeight) : 1.0f;
ctx.aspectY = (m_windowWidth > m_windowHeight) ? static_cast<float>(m_windowHeight) / static_cast<float>(m_windowWidth) : 1.0f;
ctx.invAspectX = 1.0f / ctx.aspectX;
ctx.invAspectY = 1.0f / ctx.aspectY;
ctx.perPixelMeshX = m_meshX;
ctx.perPixelMeshY = m_meshY;
ctx.perPixelMeshX = static_cast<int>(m_meshX);
ctx.perPixelMeshY = static_cast<int>(m_meshY);
ctx.textureManager = m_textureManager.get();

return ctx;
Expand Down