forked from projectM-visualizer/projectm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPreset.hpp
64 lines (51 loc) · 2.04 KB
/
Preset.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#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