Skip to content

Commit 760a4c9

Browse files
committed
Add Milkdrop user sprites
1 parent f0bad56 commit 760a4c9

16 files changed

+891
-0
lines changed

src/libprojectM/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ add_compile_definitions(
99
add_subdirectory(Audio)
1010
add_subdirectory(MilkdropPreset)
1111
add_subdirectory(Renderer)
12+
add_subdirectory(UserSprites)
1213

1314
add_library(projectM_main OBJECT
1415
"${PROJECTM_EXPORT_HEADER}"
@@ -65,6 +66,7 @@ add_library(projectM
6566
$<TARGET_OBJECTS:Audio>
6667
$<TARGET_OBJECTS:MilkdropPreset>
6768
$<TARGET_OBJECTS:Renderer>
69+
$<TARGET_OBJECTS:UserSprites>
6870
$<TARGET_OBJECTS:hlslparser>
6971
$<TARGET_OBJECTS:SOIL2>
7072
$<TARGET_OBJECTS:projectM_main>

src/libprojectM/MilkdropPreset/MilkdropPreset.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,14 @@ void MilkdropPreset::DrawInitialImage(const std::shared_ptr<Renderer::Texture>&
181181
m_flipTexture.Draw(image, m_framebuffer, m_previousFrameBuffer);
182182
}
183183

184+
void MilkdropPreset::BindFramebuffer()
185+
{
186+
if (m_framebuffer.Width() > 0 && m_framebuffer.Height() > 0)
187+
{
188+
m_framebuffer.BindDraw(m_previousFrameBuffer);
189+
}
190+
}
191+
184192
void MilkdropPreset::PerFrameUpdate()
185193
{
186194
m_perFrameContext.LoadStateVariables(m_state);
@@ -312,5 +320,6 @@ auto MilkdropPreset::ParseFilename(const std::string& filename) -> std::string
312320
return filename.substr(start + 1, filename.length());
313321
}
314322

323+
315324
} // namespace MilkdropPreset
316325
} // namespace libprojectM

src/libprojectM/MilkdropPreset/MilkdropPreset.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ class MilkdropPreset : public ::libprojectM::Preset
8787

8888
void DrawInitialImage(const std::shared_ptr<Renderer::Texture>& image, const Renderer::RenderContext& renderContext) override;
8989

90+
void BindFramebuffer() override;
91+
9092
private:
9193
void PerFrameUpdate();
9294

src/libprojectM/Preset.hpp

+13
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,19 @@ class Preset
4747
virtual void DrawInitialImage(const std::shared_ptr<Renderer::Texture>& image,
4848
const Renderer::RenderContext& renderContext) = 0;
4949

50+
/**
51+
* @brief Bind the preset's internal framebuffer.
52+
* This framebuffer contains the image passed on to the next frame, onto which warp effects etc.
53+
* are then applied. Has no effect if the framebuffer isn't initialized yet, e.g. before drawing
54+
* the first frame.
55+
*
56+
* Can be used to draw anything on top of the preset's image, "burning in" additional shapes,
57+
* images or text. Depending on the preset, it's not guaranteed though that the image actually
58+
* is used in the next frame, or completely painted over. That said, the effect varies between
59+
* presets.
60+
*/
61+
virtual void BindFramebuffer() = 0;
62+
5063
inline void SetFilename(const std::string& filename)
5164
{
5265
m_filename = filename;
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
set(SPRITE_SHADER_FILES
2+
Shaders/MilkdropSpriteFragmentGlsl330.frag
3+
Shaders/MilkdropSpriteVertexGlsl330.vert
4+
)
5+
6+
include(GenerateShaderResources)
7+
generate_shader_resources(${CMAKE_CURRENT_BINARY_DIR}/SpriteShaders.hpp
8+
${SPRITE_SHADER_FILES}
9+
)
10+
11+
add_library(UserSprites OBJECT
12+
${CMAKE_CURRENT_BINARY_DIR}/SpriteShaders.hpp
13+
Factory.cpp
14+
Factory.hpp
15+
MilkdropSprite.cpp
16+
MilkdropSprite.hpp
17+
Sprite.hpp
18+
SpriteException.hpp
19+
SpriteManager.cpp
20+
SpriteManager.hpp
21+
)
22+
23+
target_include_directories(UserSprites
24+
PRIVATE
25+
"${CMAKE_CURRENT_SOURCE_DIR}/.."
26+
PUBLIC
27+
"${CMAKE_CURRENT_SOURCE_DIR}"
28+
"${CMAKE_CURRENT_BINARY_DIR}"
29+
)
30+
31+
target_link_libraries(UserSprites
32+
PRIVATE
33+
projectM::Eval
34+
libprojectM::API # For export header
35+
PUBLIC
36+
GLM::GLM
37+
${PROJECTM_OPENGL_LIBRARIES}
38+
)
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "Factory.hpp"
2+
3+
namespace libprojectM {
4+
namespace UserSprites {
5+
6+
Factory::Factory()
7+
{
8+
}
9+
10+
Factory::~Factory()
11+
{
12+
}
13+
14+
} // namespace UserSprites
15+
} // namespace libprojectM
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#pragma once
2+
3+
namespace libprojectM {
4+
namespace UserSprites {
5+
6+
class Factory
7+
{
8+
public:
9+
Factory();
10+
11+
virtual ~Factory();
12+
13+
private:
14+
};
15+
16+
} // namespace UserSprites
17+
} // namespace libprojectM

0 commit comments

Comments
 (0)