Files
projectm/src/libprojectM/Preset.hpp
Kai Blaschke a1d300f48c Include cleanup, plus a few small code improvements.
Also removed empty FrameAudioData implementation file.
2024-02-02 15:08:05 +01:00

65 lines
2.0 KiB
C++

#pragma once
#include <Audio/FrameAudioData.hpp>
#include <Renderer/RenderContext.hpp>
#include <Renderer/Texture.hpp>
#include <memory>
#include <string>
namespace libprojectM {
class Preset
{
public:
virtual ~Preset() = default;
/**
* @brief Initializes additional preset resources.
* @param renderContext A render context with the initial data.
*/
virtual void Initialize(const Renderer::RenderContext& renderContext) = 0;
/**
* @brief Renders the preset into the current framebuffer.
* @param audioData Audio data to be used by the preset.
* @param renderContext The current render context data.
*/
virtual void RenderFrame(const libprojectM::Audio::FrameAudioData& audioData,
const Renderer::RenderContext& renderContext) = 0;
/**
* @brief Returns a pointer to the current rendering output texture.
* This pointer (the actual texture) may change from frame to frame, so this pointer should not be stored for use
* across multiple frames. Instead, a new pointer should be requested whenever needed.
* @return A pointer to the current output texture of the preset.
*/
virtual auto OutputTexture() const -> std::shared_ptr<Renderer::Texture> = 0;
/**
* @brief Draws an initial image into the preset, e.g. the last frame of a previous preset.
* It's not guaranteed a preset supports using a previously rendered image. If not
* supported, this call is simply a no-op.
* @param image The texture to be copied as the initial preset image.
* @param renderContext The current render context data.
*/
virtual void DrawInitialImage(const std::shared_ptr<Renderer::Texture>& image,
const Renderer::RenderContext& renderContext) = 0;
inline void SetFilename(const std::string& filename)
{
m_filename = filename;
}
inline auto Filename() const -> const std::string&
{
return m_filename;
}
private:
std::string m_filename;
};
} // namespace libprojectM