-
-
Notifications
You must be signed in to change notification settings - Fork 455
Expand file tree
/
Copy pathCustomShape.hpp
More file actions
96 lines (74 loc) · 3.34 KB
/
CustomShape.hpp
File metadata and controls
96 lines (74 loc) · 3.34 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#pragma once
#include "Constants.hpp"
#include "PresetState.hpp"
#include "ShapePerFrameContext.hpp"
#include <Renderer/RenderItem.hpp>
#include <Renderer/Backend/OpenGL/OpenGLRenderItem.hpp>
#include <projectm-eval.h>
namespace libprojectM {
namespace MilkdropPreset {
class PresetFileParser;
/**
* @brief Renders a custom shape with or without a texture.
*
* The class creates two sets of VBO/VAO as it's only known later (in the Draw() call) whether the shape is textured
* or not.
*/
class CustomShape : public libprojectM::Renderer::Backend::OpenGL::OpenGLRenderItem
{
public:
CustomShape(PresetState& presetState);
virtual ~CustomShape() = default;
/**
* @brief Loads the initial values and code from the preset file.
* @param parsedFile The file parser with the preset data.
* @param index The waveform index.
*/
void Initialize(PresetFileParser& parsedFile, int index);
/**
* @brief Compiles all code blocks and runs the init expression.
* @throws MilkdropCompileException Thrown if one of the code blocks couldn't be compiled.
*/
void CompileCodeAndRunInitExpressions();
/**
* @brief Renders the shape.
*/
void Draw();
private:
Renderer::Mesh m_outlineMesh; //!< The shape's border/outline mesh.
Renderer::Mesh m_fillMesh; //!< The shape's color/texture mesh.
std::string m_image; //!< Texture filename to be rendered on this shape.
int m_index{0}; //!< The custom shape index in the preset.
bool m_enabled{false}; //!< If false, the shape isn't drawn.
int m_sides{4}; //!< Number of sides (vertices)
bool m_additive{false}; //!< Flag that specifies whether the shape should be drawn additive.
bool m_thickOutline{false}; //!< If true, the shape is rendered with a thick line, otherwise a single-pixel line.
bool m_textured{false}; //!< If true, the shape will be rendered with the given texture.
int m_instances{1}; //!< Number of shape instances to render
float m_x{0.5f}; //!< The shape x position.
float m_y{0.5f}; //!< The shape y position.
float m_radius{0.1f}; //!< The shape radius (1.0 fills the whole screen).
float m_angle{0.0f}; //!< The shape rotation.
float m_r{1.0f}; ///!< Red color value.
float m_g{0.0f}; ///!< Green color value.
float m_b{0.0f}; ///!< Blue color value.
float m_a{1.0f}; ///!< Alpha color value.
float m_r2{0.0f}; ///!< Second red color value.
float m_g2{1.0f}; ///!< Second green color value.
float m_b2{0.0f}; ///!< Second blue color value.
float m_a2{0.0f}; ///!< Second alpha color value.
float m_border_r{1.0f}; //!< Red color value.
float m_border_g{1.0f}; //!< Green color value.
float m_border_b{1.0f}; //!< Blue color value.
float m_border_a{0.0f}; //!< Alpha color value
float m_tex_ang{0.0f}; //!< Texture rotation angle.
float m_tex_zoom{1.0f}; //!< Texture zoom value.
std::string m_initCode; //!< Init expression code, run once on preset load.
std::string m_perFrameCode; //!< Per-frame expression code, run once per frame and instance.
PRJM_EVAL_F m_tValuesAfterInitCode[TVarCount]{};
PresetState& m_presetState; //!< The global preset state.
ShapePerFrameContext m_perFrameContext;
friend class ShapePerFrameContext;
};
} // namespace MilkdropPreset
} // namespace libprojectM