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
11 changes: 8 additions & 3 deletions src/api/include/projectM-4/render_opengl.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,18 @@ extern "C" {
/**
* @brief Renders a single frame.
*
* @note Separate two-pass frame rendering is currently not supported by the C API as it is rarely used
* and also depends on the loaded preset.
*
* @param instance The projectM instance handle.
*/
PROJECTM_EXPORT void projectm_opengl_render_frame(projectm_handle instance);

/**
* @brief Renders a single frame into a user-defined framebuffer object.
*
* @param instance The projectM instance handle.
* @param framebuffer_object_id The OpenGL FBO ID to render to.
*/
PROJECTM_EXPORT void projectm_opengl_render_frame_fbo(projectm_handle instance, uint32_t framebuffer_object_id);

#ifdef __cplusplus
} // extern "C"
#endif
5 changes: 2 additions & 3 deletions src/libprojectM/ProjectM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void ProjectM::ResetTextures()
m_textureManager = std::make_unique<Renderer::TextureManager>(m_textureSearchPaths);
}

void ProjectM::RenderFrame()
void ProjectM::RenderFrame(uint32_t targetFramebufferObject /*= 0*/)
{
// Don't render if window area is zero.
if (m_windowWidth == 0 || m_windowHeight == 0)
Expand Down Expand Up @@ -166,8 +166,7 @@ void ProjectM::RenderFrame()
// ToDo: Call the to-be-implemented render method in Renderer
m_activePreset->RenderFrame(audioData, renderContext);

// ToDo: Allow external apps to provide a custom target framebuffer.
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, static_cast<GLuint>(targetFramebufferObject));

if (m_transition != nullptr && m_transitioningPreset != nullptr)
{
Expand Down
2 changes: 1 addition & 1 deletion src/libprojectM/ProjectM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class PROJECTM_EXPORT ProjectM

void ResetTextures();

void RenderFrame();
void RenderFrame(uint32_t targetFramebufferObject = 0);

void SetBeatSensitivity(float sensitivity);

Expand Down
8 changes: 8 additions & 0 deletions src/libprojectM/ProjectMCWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include <cstring>
#include <sstream>
#include <projectM-4/render_opengl.h>


namespace libprojectM {

Expand Down Expand Up @@ -171,6 +173,12 @@ void projectm_opengl_render_frame(projectm_handle instance)
projectMInstance->RenderFrame();
}

void projectm_opengl_render_frame_fbo(projectm_handle instance, uint32_t framebuffer_object_id)
{
auto projectMInstance = handle_to_instance(instance);
projectMInstance->RenderFrame(framebuffer_object_id);
}

void projectm_set_beat_sensitivity(projectm_handle instance, float sensitivity)
{
auto projectMInstance = handle_to_instance(instance);
Expand Down