diff --git a/src/libprojectM/CMakeLists.txt b/src/libprojectM/CMakeLists.txt index 2da39f833..eb46542b0 100644 --- a/src/libprojectM/CMakeLists.txt +++ b/src/libprojectM/CMakeLists.txt @@ -33,7 +33,7 @@ Func.cpp Eval.cpp PerFrameEqn.cpp PerPointEqn.cpp fftsg.cpp KeyHandler.cpp timer.cpp wipemalloc.cpp BuiltinFuncs.cpp BuiltinParams.cpp Renderer.cpp PresetLoader.cpp PresetChooser.cpp PresetFrameIO.cpp PresetMerge.cpp PipelineContext.cpp ConfigFile.cpp IdlePreset.cpp TextureManager.cpp TimeKeeper.cpp Filters.cpp Renderable.cpp Pipeline.cpp PerPixelMesh.cpp -MilkdropWaveform.cpp Waveform.cpp VideoEcho.cpp Shader.cpp PerlinNoise.cpp UserTexture.cpp ShaderEngine.cpp Common.cpp ${GLEW_SOURCES}) +MilkdropWaveform.cpp Waveform.cpp VideoEcho.cpp Shader.cpp PerlinNoise.cpp UserTexture.cpp ShaderEngine.cpp MilkdropPreset.cpp MilkdropPresetFactory.cpp ${GLEW_SOURCES}) if (USE_DEVIL) SET (projectM_SOURCES ${projectM_SOURCES}) diff --git a/src/libprojectM/MilkdropPreset.cpp b/src/libprojectM/MilkdropPreset.cpp index bc24bee1c..815bd377f 100755 --- a/src/libprojectM/MilkdropPreset.cpp +++ b/src/libprojectM/MilkdropPreset.cpp @@ -39,37 +39,42 @@ MilkdropPreset::MilkdropPreset(std::istream & in, const std::string & presetName, PresetInputs & presetInputs, PresetOutputs & presetOutputs): - Preset(presetName, ""), + Preset(presetName), builtinParams(presetInputs, presetOutputs), - m_presetName(presetName), - m_presetOutputs(presetOutputs), - presetInputs(presetInputs) + _presetOutputs(presetOutputs), + _presetInputs(presetInputs) { - m_presetOutputs.customWaves.clear(); - m_presetOutputs.customShapes.clear(); + _presetOutputs.customWaves.clear(); + _presetOutputs.customShapes.clear(); initialize(in); } +/** + * + * @param absoluteFilePath + * @param presetName + * @param presetInputs + * @param presetOutputs + */ MilkdropPreset::MilkdropPreset(const std::string & absoluteFilePath, const std::string & presetName, PresetInputs & presetInputs, PresetOutputs & presetOutputs): builtinParams(presetInputs, presetOutputs), - m_absoluteFilePath(absoluteFilePath), - m_presetName(presetName), - m_presetOutputs(presetOutputs), - presetInputs(presetInputs) + _absoluteFilePath(absoluteFilePath), + _presetOutputs(presetOutputs), + _presetInputs(presetInputs) { - m_presetOutputs.customWaves.clear(); - m_presetOutputs.customShapes.clear(); + _presetOutputs.customWaves.clear(); + _presetOutputs.customShapes.clear(); initialize(absoluteFilePath); } -Preset::~MilkdropPreset() +MilkdropPreset::~MilkdropPreset() { Algorithms::traverse >(init_cond_tree); @@ -272,18 +277,24 @@ void MilkdropPreset::postloadInitialize() { } +void MilkdropPreset::Render(const BeatDetect &music, const PipelineContext &context) +{ + // set stuff here + this->evaluateFrame(); +} + void MilkdropPreset::initialize(const std::string & pathname) { int retval; preloadInitialize(); -if (PRESET_DEBUG) +if (MILKDROP_PRESET_DEBUG) std::cerr << "[Preset] loading file \"" << pathname << "\"..." << std::endl; if ((retval = loadPresetFile(pathname)) < 0) { -if (PRESET_DEBUG) +if (MILKDROP_PRESET_DEBUG) std::cerr << "[Preset] failed to load file \"" << pathname << "\"!" << std::endl; @@ -303,7 +314,7 @@ void MilkdropPreset::initialize(std::istream & in) if ((retval = readIn(in)) < 0) { - if (PRESET_DEBUG) + if (MILKDROP_PRESET_DEBUG) std::cerr << "[Preset] failed to load from stream " << std::endl; /// @bug how should we handle this problem? a well define exception? @@ -370,8 +381,8 @@ void MilkdropPreset::evaluateFrame() // Setup pointers of the custom waves and shapes to the preset outputs instance /// @slow an extra O(N) per frame, could do this during eval - m_presetOutputs.customWaves = PresetOutputs::cwave_container(customWaves); - m_presetOutputs.customShapes = PresetOutputs::cshape_container(customShapes); + _presetOutputs.customWaves = PresetOutputs::cwave_container(customWaves); + _presetOutputs.customShapes = PresetOutputs::cshape_container(customShapes); } @@ -379,74 +390,74 @@ void MilkdropPreset::initialize_PerPixelMeshes() { int x,y; - for (x=0;x::iterator pos = per_pixel_eqn_tree.begin(); pos != per_pixel_eqn_tree.end(); ++pos) pos->second->evaluate(mesh_x, mesh_y); @@ -474,7 +485,7 @@ int MilkdropPreset::readIn(std::istream & fs) { /* Parse any comments */ if (Parser::parse_top_comment(fs) < 0) { - if (PRESET_DEBUG) + if (MILKDROP_PRESET_DEBUG) std::cerr << "[Preset::readIn] no left bracket found..." << std::endl; return PROJECTM_FAILURE; } @@ -520,7 +531,7 @@ int MilkdropPreset::loadPresetFile(const std::string & pathname) /* Open the file corresponding to pathname */ std::ifstream fs(pathname.c_str()); if (!fs || fs.eof()) { - if (PRESET_DEBUG) + if (MILKDROP_PRESET_DEBUG) std::cerr << "loadPresetFile: loading of file \"" << pathname << "\" failed!\n"; return PROJECTM_ERROR; } diff --git a/src/libprojectM/MilkdropPreset.hpp b/src/libprojectM/MilkdropPreset.hpp index bdf2f360b..022f1a278 100644 --- a/src/libprojectM/MilkdropPreset.hpp +++ b/src/libprojectM/MilkdropPreset.hpp @@ -35,7 +35,7 @@ #include #include -#define MilkdropPreset_DEBUG 0 /* 0 for no debugging, 1 for normal, 2 for insane */ +#define MILKDROP_PRESET_DEBUG 0 /* 0 for no debugging, 1 for normal, 2 for insane */ #include "CustomShape.hpp" #include "CustomWave.hpp" @@ -120,7 +120,8 @@ public: return _presetInputs; } - /// @bug encapsulate + +// @bug encapsulate PresetOutputs::cwave_container customWaves; PresetOutputs::cshape_container customShapes; @@ -134,7 +135,7 @@ public: std::map user_param_tree; /* user parameter splay tree */ - const Pipeline & pipeline() { return _presetOutputs; } + const Pipeline & pipeline() const { return _presetOutputs; } void Render(const BeatDetect &music, const PipelineContext &context); diff --git a/src/libprojectM/MilkdropPresetFactory.cpp b/src/libprojectM/MilkdropPresetFactory.cpp new file mode 100644 index 000000000..3d5fd788c --- /dev/null +++ b/src/libprojectM/MilkdropPresetFactory.cpp @@ -0,0 +1,33 @@ +// +// C++ Implementation: MilkdropPresetFactory +// +// Description: +// +// +// Author: Carmelo Piccione , (C) 2008 +// +// Copyright: See COPYING file that comes with this distribution +// +// +// +// C++ Interface: PresetFactory +// +// Description: +// +// +// Author: Carmelo Piccione , (C) 2008 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#include "MilkdropPresetFactory.hpp" + + +MilkdropPresetFactory::MilkdropPresetFactory() {} + +MilkdropPresetFactory::~MilkdropPresetFactory() {} + +std::auto_ptr MilkdropPresetFactory::allocate(const std::string & url, const std::string & name, const std::string & author) { + return std::auto_ptr(new MilkdropPreset(url, name, _presetInputs, _presetOutputs)); +} diff --git a/src/libprojectM/MilkdropPresetFactory.hpp b/src/libprojectM/MilkdropPresetFactory.hpp new file mode 100644 index 000000000..2384aea49 --- /dev/null +++ b/src/libprojectM/MilkdropPresetFactory.hpp @@ -0,0 +1,36 @@ +// +// C++ Interface: PresetFactory +// +// Description: +// +// +// Author: Carmelo Piccione , (C) 2008 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#ifndef __MILKDROP_PRESET_FACTORY_HPP +#define __MILKDROP_PRESET_FACTORY_HPP + +#include "MilkdropPreset.hpp" +#include +#include "PresetFactory.hpp" + +class MilkdropPresetFactory : public PresetFactory { + +public: + + + MilkdropPresetFactory(); + + virtual ~MilkdropPresetFactory(); + + std::auto_ptr allocate(const std::string & url, const std::string & name = std::string(), const std::string & author = std::string()); + +private: + PresetOutputs _presetOutputs; + PresetInputs _presetInputs; +}; + +#endif \ No newline at end of file diff --git a/src/libprojectM/PipelineContext.cpp b/src/libprojectM/PipelineContext.cpp index 0e8ad1a50..223314756 100644 --- a/src/libprojectM/PipelineContext.cpp +++ b/src/libprojectM/PipelineContext.cpp @@ -8,3 +8,4 @@ #include "PipelineContext.hpp" PipelineContext::PipelineContext() {} +PipelineContext::~PipelineContext() {} diff --git a/src/libprojectM/Preset.cpp b/src/libprojectM/Preset.cpp index 69bebaf03..84e823af6 100755 --- a/src/libprojectM/Preset.cpp +++ b/src/libprojectM/Preset.cpp @@ -7,8 +7,6 @@ #include "Preset.hpp" -Preset::Preset() {} - Preset::~Preset() {} Preset::Preset(const std::string & presetName, const std::string & presetAuthor): diff --git a/src/libprojectM/Preset.hpp b/src/libprojectM/Preset.hpp index 4e8cd9d15..d01b3b2b4 100644 --- a/src/libprojectM/Preset.hpp +++ b/src/libprojectM/Preset.hpp @@ -17,8 +17,8 @@ class Preset { public: - Preset(); - Preset(const std::string & name, const std::string & author); + + Preset(const std::string & name=std::string(), const std::string & author = std::string()); virtual ~Preset(); void setName(const std::string & value); diff --git a/src/libprojectM/PresetFactory.hpp b/src/libprojectM/PresetFactory.hpp index 9d3e1043e..8187fdbc5 100644 --- a/src/libprojectM/PresetFactory.hpp +++ b/src/libprojectM/PresetFactory.hpp @@ -21,14 +21,17 @@ class PresetFactory { public: - PresetFactory() {} + inline PresetFactory() {} - virtual ~PresetFactory() {} + inline virtual ~PresetFactory() {} /// Constructs a new preset given an url /// \param url a locational identifier referencing the preset - /// \returns a valid preset object- otherwise - virtual std::auto_ptr allocate(std::string url, std::string name); +/// \param name the preset name +/// \param author the preset author + /// \returns a valid preset object + virtual std::auto_ptr allocate(const std::string & url, const std::string & name=std::string(), + const std::string & author=std::string()) = 0;