Skip to content

Commit 0c9773c

Browse files
revmischaMischa
authored andcommitted
fix: ensure all Init() calls invoke base class methods for proper init
1 parent 5cdddf9 commit 0c9773c

5 files changed

Lines changed: 74 additions & 1 deletion

File tree

src/libprojectM/MilkdropPreset/CustomWaveform.hpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,56 @@ class CustomWaveform : public libprojectM::Renderer::Backend::OpenGL::OpenGLRend
2525

2626
void InitVertexAttrib() override;
2727

28+
/**
29+
* @brief Loads the initial values and code from the preset file.
30+
* @param parsedFile The file parser with the preset data.
31+
* @param index The waveform index.
32+
*/
2833
void Initialize(::libprojectM::PresetFileParser& parsedFile, int index);
2934

35+
/**
36+
* @brief Compiles all code blocks and runs the init expression.
37+
* @throws MilkdropCompileException Thrown if one of the code blocks couldn't be compiled.
38+
* @param presetPerFrameContext The per-frame context to retrieve the init Q vars from.
39+
*/
3040
void CompileCodeAndRunInitExpressions(const PerFrameContext& presetPerFrameContext);
3141

42+
/**
43+
* @brief Renders the waveform.
44+
* @param presetPerFrameContext The per-frame context to retrieve the init Q vars from.
45+
*/
3246
void Draw(const PerFrameContext& presetPerFrameContext);
3347

3448
private:
49+
/**
50+
* @brief Initializes the per-frame context with the preset per-frame state.
51+
* @param presetPerFrameContext The preset per-frame context to pull q vars from.
52+
*/
3553
void LoadPerFrameEvaluationVariables(const PerFrameContext& presetPerFrameContext);
3654

55+
/**
56+
* @brief Loads the Q and T variables from the per-frame code into the per-point context.
57+
*/
3758
void InitPerPointEvaluationVariables();
3859

60+
/**
61+
* @brief Loads the variables for each point into the per-point evaluation context.
62+
* @param sample The sample index being rendered.
63+
* @param value1 The left channel value.
64+
* @param value2 The right channel value.
65+
*/
3966
void LoadPerPointEvaluationVariables(float sample, float value1, float value2);
4067

68+
/**
69+
* @brief Does a better-than-linear smooth on a wave.
70+
*
71+
* Roughly doubles the number of points.
72+
*
73+
* @param inputVertices Array of input vertices to be smoothed.
74+
* @param vertexCount Number of vertices in the input array.
75+
* @param outputVertices Array to store the smoothed vertices.
76+
* @return The number of vertices in the output array.
77+
*/
4178
static int SmoothWave(const ColoredPoint* inputVertices, int vertexCount, ColoredPoint* outputVertices);
4279

4380
int m_index{0}; //!< Custom waveform index in the preset.

src/libprojectM/MilkdropPreset/FinalComposite.hpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,36 @@ class FinalComposite : public libprojectM::Renderer::Backend::OpenGL::OpenGLRend
2222

2323
void InitVertexAttrib() override;
2424

25+
/**
26+
* @brief Loads the composite shader, if the preset uses one.
27+
* @param presetState The preset state to retrieve the shader from.
28+
*/
2529
void LoadCompositeShader(const PresetState& presetState);
2630

31+
/**
32+
* @brief Loads the required textures and compiles the composite shader.
33+
* @param presetState The preset state to retrieve the configuration values from.
34+
*/
2735
void CompileCompositeShader(PresetState& presetState);
2836

37+
/**
38+
* @brief Renders the composite quad with the appropriate effects or shaders.
39+
* @param presetState The preset state to retrieve the configuration values from.
40+
* @param presetPerFrameContext The per-frame context to retrieve the initial vars from.
41+
*/
2942
void Draw(const PresetState& presetState,
3043
const PerFrameContext& perFrameContext);
3144

45+
/**
46+
* @brief Returns if the final composite is using a shader or classic filters.
47+
* @return true if the final composite is done via a shader, false if not.
48+
*/
3249
auto HasCompositeShader() const -> bool;
3350

3451
private:
52+
/**
53+
* Composite mesh vertex with all required attributes.
54+
*/
3555
struct MeshVertex {
3656
float x{}; //!< Vertex X coordinate.
3757
float y{}; //!< Vertex Y coordinate.
@@ -45,13 +65,24 @@ class FinalComposite : public libprojectM::Renderer::Backend::OpenGL::OpenGLRend
4565
float angle{};
4666
};
4767

68+
/**
69+
* @brief Initializes the vertex array and fills in static data if needed.
70+
*
71+
* The vertices will only be reinitialized if the viewport size changed.
72+
*
73+
* @param presetState The preset state to retrieve the configuration values from.
74+
*/
4875
void InitializeMesh(const PresetState& presetState);
4976

5077
static float SquishToCenter(float x, float exponent);
5178

5279
static void UvToMathSpace(float aspectX, float aspectY,
5380
float u, float v, float& rad, float& ang);
5481

82+
/**
83+
* @brief Calculates the randomized, slowly changing diffuse colors.
84+
* @param presetState The preset state to retrieve the configuration values from.
85+
*/
5586
void ApplyHueShaderColors(const PresetState& presetState);
5687

5788
static constexpr int compositeGridWidth{32};

src/libprojectM/Renderer/Backend/OpenGL/OpenGLCopyTexture.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ class OpenGLCopyTexture : public CopyTexture, public OpenGLRenderItem
2222
// Mark override for clarity and to avoid hiding warnings
2323
void Init() override
2424
{
25+
// Call both base class Init() to ensure proper initialization
2526
OpenGLRenderItem::Init();
27+
CopyTexture::Init();
2628
}
2729

2830
using OpenGLRenderItem::Init; // Unhide base Init() to avoid -Woverloaded-virtual warning

src/libprojectM/Renderer/Backend/OpenGL/OpenGLPresetTransition.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ class OpenGLPresetTransition : public PresetTransition, public OpenGLRenderItem
2424
// Mark override for clarity and to avoid hiding warnings
2525
void Init() override
2626
{
27+
// Call both base class Init() to ensure proper initialization
2728
OpenGLRenderItem::Init();
29+
PresetTransition::Init();
2830
}
2931

3032
using OpenGLRenderItem::Init; // Unhide base Init() to avoid -Woverloaded-virtual warning

src/libprojectM/Renderer/Backend/OpenGL/OpenGLRenderItem.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ class OpenGLRenderItem : public ::libprojectM::Renderer::RenderItem
2525
void Init() override;
2626

2727
protected:
28-
using ::libprojectM::Renderer::RenderItem::Init; // Unhide base Init() to avoid -Woverloaded-virtual warning
28+
// Unhide base Init() to avoid -Woverloaded-virtual warning and allow calling base from derived
29+
using ::libprojectM::Renderer::RenderItem::Init;
2930
GLuint m_vboID{0};
3031
GLuint m_vaoID{0};
3132
};

0 commit comments

Comments
 (0)