From 32932550ef6685576eb5b6a284367b2df2bb7cb2 Mon Sep 17 00:00:00 2001 From: w1z7ard Date: Sat, 13 Sep 2008 04:40:32 +0000 Subject: [PATCH] took out preset outputs / inputs references from projectm. chaos ensued. git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/personal/carm/represet@1153 6778bc44-b910-0410-a7a0-be141de4315d --- src/libprojectM/CompiledPreset.hpp | 2 +- src/libprojectM/KeyHandler.cpp | 8 +- src/libprojectM/MilkdropPreset.hpp | 2 +- src/libprojectM/MilkdropPresetFactory.cpp | 167 +++++++++++++++- src/libprojectM/MilkdropPresetFactory.hpp | 2 + src/libprojectM/Preset.hpp | 2 +- src/libprojectM/projectM.cpp | 220 ++++------------------ src/libprojectM/projectM.hpp | 12 +- 8 files changed, 207 insertions(+), 208 deletions(-) diff --git a/src/libprojectM/CompiledPreset.hpp b/src/libprojectM/CompiledPreset.hpp index f99b46867..c877799e4 100644 --- a/src/libprojectM/CompiledPreset.hpp +++ b/src/libprojectM/CompiledPreset.hpp @@ -26,7 +26,7 @@ public: virtual ~CompiledPreset() {} - inline const PipelineT & pipeline() const { return _pipeline; } + inline PipelineT & pipeline() { return _pipeline; } inline virtual void Render(const BeatDetect &music, const PipelineContext &context) { _pipeline.Render(music, context); } diff --git a/src/libprojectM/KeyHandler.cpp b/src/libprojectM/KeyHandler.cpp index dc54eb719..675bfe7ef 100755 --- a/src/libprojectM/KeyHandler.cpp +++ b/src/libprojectM/KeyHandler.cpp @@ -168,8 +168,8 @@ void projectM::default_key_handler( projectMEvent event, projectMKeycode keycode case PROJECTM_K_n: m_presetChooser->nextPreset(*m_presetPos); presetSwitchedEvent(true, **m_presetPos); - m_activePreset = m_presetPos->allocate(); - renderer->SetPipeline(presetOutputs); + m_activePreset = m_presetPos->allocate(); + renderer->SetPipeline(m_activePreset->pipeline()); renderer->setPresetName(m_activePreset->name()); timeKeeper->StartPreset(); break; @@ -182,7 +182,7 @@ void projectM::default_key_handler( projectMEvent event, projectMKeycode keycode *m_presetPos = m_presetChooser->weightedRandom(); presetSwitchedEvent(true, **m_presetPos); m_activePreset = m_presetPos->allocate(); - renderer->SetPipeline(presetOutputs); + renderer->SetPipeline(m_activePreset->pipeline()); assert(m_activePreset.get()); renderer->setPresetName(m_activePreset->name()); @@ -209,7 +209,7 @@ void projectM::default_key_handler( projectMEvent event, projectMKeycode keycode } m_activePreset = m_presetPos->allocate(); - renderer->SetPipeline(presetOutputs); + renderer->SetPipeline(m_activePreset->pipeline()); renderer->setPresetName(m_activePreset->name()); timeKeeper->StartPreset(); diff --git a/src/libprojectM/MilkdropPreset.hpp b/src/libprojectM/MilkdropPreset.hpp index 28b0a74cf..abdb57e73 100644 --- a/src/libprojectM/MilkdropPreset.hpp +++ b/src/libprojectM/MilkdropPreset.hpp @@ -134,7 +134,7 @@ public: std::map user_param_tree; /* user parameter splay tree */ - const Pipeline & pipeline() const { return _presetOutputs; } + Pipeline & pipeline() { return _presetOutputs; } void Render(const BeatDetect &music, const PipelineContext &context); diff --git a/src/libprojectM/MilkdropPresetFactory.cpp b/src/libprojectM/MilkdropPresetFactory.cpp index 62413ac4a..9d17df2fd 100644 --- a/src/libprojectM/MilkdropPresetFactory.cpp +++ b/src/libprojectM/MilkdropPresetFactory.cpp @@ -32,9 +32,8 @@ MilkdropPresetFactory::MilkdropPresetFactory(int gx, int gy) { /* Initializes all infix operators */ Eval::init_infix_ops(); - - _presetOutputs.Initialize(gx,gy); - + + initializePresetOutputs(gx,gy); } MilkdropPresetFactory::~MilkdropPresetFactory() { @@ -44,6 +43,168 @@ MilkdropPresetFactory::~MilkdropPresetFactory() { } +/* Reinitializes the engine variables to a default (conservative and sane) value */ +void MilkdropPresetFactory::Reset() +{ + + _presetOutputs.zoom=1.0; + _presetOutputs.zoomexp= 1.0; + _presetOutputs.rot= 0.0; + _presetOutputs.warp= 0.0; + + _presetOutputs.sx= 1.0; + _presetOutputs.sy= 1.0; + _presetOutputs.dx= 0.0; + _presetOutputs.dy= 0.0; + _presetOutputs.cx= 0.5; + _presetOutputs.cy= 0.5; + + _presetOutputs.screenDecay=.98; + + _presetOutputs.wave.r= 1.0; + _presetOutputs.wave.g= 0.2; + _presetOutputs.wave.b= 0.0; + _presetOutputs.wave.x= 0.5; + _presetOutputs.wave.y= 0.5; + _presetOutputs.wave.mystery= 0.0; + + _presetOutputs.border.outer_size= 0.0; + _presetOutputs.border.outer_r= 0.0; + _presetOutputs.border.outer_g= 0.0; + _presetOutputs.border.outer_b= 0.0; + _presetOutputs.border.outer_a= 0.0; + + _presetOutputs.border.inner_size = 0.0; + _presetOutputs.border.inner_r = 0.0; + _presetOutputs.border.inner_g = 0.0; + _presetOutputs.border.inner_b = 0.0; + _presetOutputs.border.inner_a = 0.0; + + _presetOutputs.mv.a = 0.0; + _presetOutputs.mv.r = 0.0; + _presetOutputs.mv.g = 0.0; + _presetOutputs.mv.b = 0.0; + _presetOutputs.mv.length = 1.0; + _presetOutputs.mv.x_num = 16.0; + _presetOutputs.mv.y_num = 12.0; + _presetOutputs.mv.x_offset = 0.02; + _presetOutputs.mv.y_offset = 0.02; + + _presetInputs.progress = 0; + _presetInputs.frame = 1; + + /* PER_FRAME CONSTANTS END */ + _presetOutputs.fRating = 0; + _presetOutputs.fGammaAdj = 1.0; + _presetOutputs.videoEcho.zoom = 1.0; + _presetOutputs.videoEcho.a = 0; + _presetOutputs.videoEcho.orientation = Normal; + + _presetOutputs.wave.additive = false; + _presetOutputs.wave.dots = false; + _presetOutputs.wave.thick = false; + _presetOutputs.wave.modulateAlphaByVolume = 0; + _presetOutputs.wave.maximizeColors = 0; + _presetOutputs.textureWrap = 0; + _presetOutputs.bDarkenCenter = 0; + _presetOutputs.bRedBlueStereo = 0; + _presetOutputs.bBrighten = 0; + _presetOutputs.bDarken = 0; + _presetOutputs.bSolarize = 0; + _presetOutputs.bInvert = 0; + _presetOutputs.bMotionVectorsOn = 1; + + _presetOutputs.wave.a =1.0; + _presetOutputs.wave.scale = 1.0; + _presetOutputs.wave.smoothing = 0; + _presetOutputs.wave.mystery = 0; + _presetOutputs.wave.modOpacityEnd = 0; + _presetOutputs.wave.modOpacityStart = 0; + _presetOutputs.fWarpAnimSpeed = 0; + _presetOutputs.fWarpScale = 0; + _presetOutputs.fShader = 0; + + + _presetInputs.x_per_pixel = 0; + _presetInputs.y_per_pixel = 0; + _presetInputs.rad_per_pixel = 0; + _presetInputs.ang_per_pixel = 0; + + /* PER_PIXEL CONSTANT END */ + + /* Q VARIABLES START */ + + for (int i = 0;i<32;i++) + _presetOutputs.q[i] = 0; + + + /* Q VARIABLES END */ + +} + +void MilkdropPresetFactory::initializePresetOutputs(int gx, int gy) +{ + + _presetOutputs.Initialize(gx,gy); + + /* PER FRAME CONSTANTS BEGIN */ + _presetOutputs.zoom=1.0; + _presetOutputs.zoomexp= 1.0; + _presetOutputs.rot= 0.0; + _presetOutputs.warp= 0.0; + + _presetOutputs.sx= 1.0; + _presetOutputs.sy= 1.0; + _presetOutputs.dx= 0.0; + _presetOutputs.dy= 0.0; + _presetOutputs.cx= 0.5; + _presetOutputs.cy= 0.5; + + _presetOutputs.screenDecay=.98; + + +//_presetInputs.meshx = 0; +//_presetInputs.meshy = 0; + + + _presetInputs.progress = 0; + _presetInputs.frame = 1; + + /* PER_FRAME CONSTANTS END */ + _presetOutputs.fRating = 0; + _presetOutputs.fGammaAdj = 1.0; + _presetOutputs.videoEcho.zoom = 1.0; + _presetOutputs.videoEcho.a = 0; + _presetOutputs.videoEcho.orientation = Normal; + + _presetOutputs.textureWrap = 0; + _presetOutputs.bDarkenCenter = 0; + _presetOutputs.bRedBlueStereo = 0; + _presetOutputs.bBrighten = 0; + _presetOutputs.bDarken = 0; + _presetOutputs.bSolarize = 0; + _presetOutputs.bInvert = 0; + _presetOutputs.bMotionVectorsOn = 1; + + _presetOutputs.fWarpAnimSpeed = 0; + _presetOutputs.fWarpScale = 0; + _presetOutputs.fShader = 0; + + /* PER_PIXEL CONSTANTS BEGIN */ + + /* PER_PIXEL CONSTANT END */ + + /* Q AND T VARIABLES START */ + + for (int i = 0;i<32;i++) + _presetOutputs.q[i] = 0; + + + + /* Q AND T VARIABLES END */ + +} + std::auto_ptr MilkdropPresetFactory::allocate(const std::string & url, const std::string & name, const std::string & author) { _presetOutputs.customWaves.clear(); _presetOutputs.customShapes.clear(); diff --git a/src/libprojectM/MilkdropPresetFactory.hpp b/src/libprojectM/MilkdropPresetFactory.hpp index 047a1f685..e5b99d702 100644 --- a/src/libprojectM/MilkdropPresetFactory.hpp +++ b/src/libprojectM/MilkdropPresetFactory.hpp @@ -32,6 +32,8 @@ public: std::string supportedExtensions() const { return "milk prjm"; } private: + void initializePresetOutputs(int gx, int gy); + void Reset(); PresetOutputs _presetOutputs; PresetInputs _presetInputs; }; diff --git a/src/libprojectM/Preset.hpp b/src/libprojectM/Preset.hpp index d01b3b2b4..b684be870 100644 --- a/src/libprojectM/Preset.hpp +++ b/src/libprojectM/Preset.hpp @@ -27,7 +27,7 @@ public: void setAuthor(const std::string & value); const std::string & author() const; - virtual const Pipeline & pipeline() const = 0; + virtual Pipeline & pipeline() = 0; virtual void Render(const BeatDetect &music, const PipelineContext &context) = 0; private: diff --git a/src/libprojectM/projectM.cpp b/src/libprojectM/projectM.cpp index be85b8b69..4436d863e 100755 --- a/src/libprojectM/projectM.cpp +++ b/src/libprojectM/projectM.cpp @@ -263,7 +263,11 @@ DLLEXPORT void projectM::renderFrame() timeKeeper->UpdateTimers(); //printf("A:%f, B:%f, S:%f\n", timeKeeper->PresetProgressA(), timeKeeper->PresetProgressB(), timeKeeper->SmoothRatio()); - mspf= ( int ) ( 1000.0/ ( float ) presetInputs.fps ); //milliseconds per frame + +std::cerr << "mspf: FIX ME!"; + abort(); + + //mspf= ( int ) ( 1000.0/ ( float ) presetInputs.fps ); //milliseconds per frame //m_activePreset->Render(beatDetect, pipelineContext); //setupPresetInputs(&m_activePreset->presetInputs()); @@ -293,7 +297,9 @@ assert(false); else if ( ( beatDetect->vol-beatDetect->vol_old>beatDetect->beat_sensitivity ) && timeKeeper->CanHardCut() ) { // printf("Hard Cut\n"); - switchPreset(m_activePreset, presetInputs, presetOutputs); +std::cerr << "HARD CUT. SWITCH PRESET BROKEN" << std::endl; + abort(); + //switchPreset(m_activePreset, presetInputs, presetOutputs); timeKeeper->StartPreset(); presetSwitchedEvent(true, **m_presetPos); @@ -326,10 +332,19 @@ assert(false); //PresetMerger::MergePresets ( m_activePreset->presetOutputs(),m_activePreset2->presetOutputs(),timeKeeper->SmoothRatio(),presetInputs.gx, presetInputs.gy ); + + Pipeline pipeline; -pipeline.setStaticPerPixel(presetInputs.gx,presetInputs.gy); + +std::cerr << "FIX ME STATIC PER PIXEL" << std::endl; +abort(); +//pipeline.setStaticPerPixel(presetInputs.gx,presetInputs.gy); PipelineMerger::MergePipelines( m_activePreset->pipeline(),m_activePreset2->pipeline(), pipeline,timeKeeper->SmoothRatio()); -renderer->RenderFrame ( pipeline, presetInputs ); + + +std::cerr << "FIX ME RENDER FRAME" << std::endl; +abort(); +//renderer->RenderFrame ( pipeline, presetInputs ); } else { @@ -407,10 +422,6 @@ void projectM::projectM_init ( int gx, int gy, int fps, int texsize, int width, /** Initialise engine variables */ projectM_initengine(); - presetInputs.Initialize ( gx, gy ); - presetInputs2.Initialize ( gx, gy ); - presetOutputs.Initialize ( gx, gy ); - presetOutputs2.Initialize ( gx, gy ); /** Initialise start time */ timeKeeper = new TimeKeeper(_settings.presetDuration,_settings.smoothPresetDuration, _settings.easterEgg); @@ -419,10 +430,6 @@ void projectM::projectM_init ( int gx, int gy, int fps, int texsize, int width, /** Initialise per-pixel matrix calculations */ - - - presetInputs.fps = fps; - presetInputs2.fps = fps; /** We need to initialise this before the builtin param db otherwise bass/mid etc won't bind correctly */ assert ( !beatDetect ); @@ -432,17 +439,17 @@ void projectM::projectM_init ( int gx, int gy, int fps, int texsize, int width, beatDetect = new BeatDetect ( _pcm ); - if ( presetInputs.fps > 0 ) - mspf= ( int ) ( 1000.0/ ( float ) presetInputs.fps ); - else mspf = 0; - - this->presetInputs.gx = gx; - this->presetInputs.gy = gy; - this->presetInputs2.gx = gx; - this->presetInputs2.gy = gy; + std::cerr << "fps broken FIX ME" << std::endl; + abort(); + //if ( presetInputs.fps > 0 ) + // mspf= ( int ) ( 1000.0/ ( float ) presetInputs.fps ); + //else mspf = 0; this->renderer = new Renderer ( width, height, gx, gy, texsize, beatDetect, settings().presetURL, settings().titleFontURL, settings().menuFontURL ); - renderer->SetPipeline(presetOutputs); + + std::cerr << "set pipeline broken FIX ME" << std::endl; + abort(); + //renderer->SetPipeline(presetOutputs); running = true; initPresetTools(gx, gy); @@ -467,179 +474,18 @@ void projectM::projectM_init ( int gx, int gy, int fps, int texsize, int width, // printf ( "exiting projectM_init()\n" ); } - -void projectM::projectM_initengine() -{ - - /* PER FRAME CONSTANTS BEGIN */ - this->presetOutputs.zoom=1.0; - this->presetOutputs.zoomexp= 1.0; - this->presetOutputs.rot= 0.0; - this->presetOutputs.warp= 0.0; - - this->presetOutputs.sx= 1.0; - this->presetOutputs.sy= 1.0; - this->presetOutputs.dx= 0.0; - this->presetOutputs.dy= 0.0; - this->presetOutputs.cx= 0.5; - this->presetOutputs.cy= 0.5; - - this->presetOutputs.screenDecay=.98; - - -//this->presetInputs.meshx = 0; -//this->presetInputs.meshy = 0; - - - this->presetInputs.progress = 0; - this->presetInputs.frame = 1; - this->presetInputs2.progress = 0; - this->presetInputs2.frame = 1; -//bass_thresh = 0; - - /* PER_FRAME CONSTANTS END */ - this->presetOutputs.fRating = 0; - this->presetOutputs.fGammaAdj = 1.0; - this->presetOutputs.videoEcho.zoom = 1.0; - this->presetOutputs.videoEcho.a = 0; - this->presetOutputs.videoEcho.orientation = Normal; - - this->presetOutputs.textureWrap = 0; - this->presetOutputs.bDarkenCenter = 0; - this->presetOutputs.bRedBlueStereo = 0; - this->presetOutputs.bBrighten = 0; - this->presetOutputs.bDarken = 0; - this->presetOutputs.bSolarize = 0; - this->presetOutputs.bInvert = 0; - this->presetOutputs.bMotionVectorsOn = 1; - - this->presetOutputs.fWarpAnimSpeed = 0; - this->presetOutputs.fWarpScale = 0; - this->presetOutputs.fShader = 0; - - /* PER_PIXEL CONSTANTS BEGIN */ - - /* PER_PIXEL CONSTANT END */ - - /* Q AND T VARIABLES START */ - - for (int i = 0;i<32;i++) - presetOutputs.q[i] = 0; - - - - /* Q AND T VARIABLES END */ - -} - /* Reinitializes the engine variables to a default (conservative and sane) value */ void projectM::projectM_resetengine() { - this->presetOutputs.zoom=1.0; - this->presetOutputs.zoomexp= 1.0; - this->presetOutputs.rot= 0.0; - this->presetOutputs.warp= 0.0; - - this->presetOutputs.sx= 1.0; - this->presetOutputs.sy= 1.0; - this->presetOutputs.dx= 0.0; - this->presetOutputs.dy= 0.0; - this->presetOutputs.cx= 0.5; - this->presetOutputs.cy= 0.5; - - this->presetOutputs.screenDecay=.98; - - this->presetOutputs.wave.r= 1.0; - this->presetOutputs.wave.g= 0.2; - this->presetOutputs.wave.b= 0.0; - this->presetOutputs.wave.x= 0.5; - this->presetOutputs.wave.y= 0.5; - this->presetOutputs.wave.mystery= 0.0; - - this->presetOutputs.border.outer_size= 0.0; - this->presetOutputs.border.outer_r= 0.0; - this->presetOutputs.border.outer_g= 0.0; - this->presetOutputs.border.outer_b= 0.0; - this->presetOutputs.border.outer_a= 0.0; - - this->presetOutputs.border.inner_size = 0.0; - this->presetOutputs.border.inner_r = 0.0; - this->presetOutputs.border.inner_g = 0.0; - this->presetOutputs.border.inner_b = 0.0; - this->presetOutputs.border.inner_a = 0.0; - - this->presetOutputs.mv.a = 0.0; - this->presetOutputs.mv.r = 0.0; - this->presetOutputs.mv.g = 0.0; - this->presetOutputs.mv.b = 0.0; - this->presetOutputs.mv.length = 1.0; - this->presetOutputs.mv.x_num = 16.0; - this->presetOutputs.mv.y_num = 12.0; - this->presetOutputs.mv.x_offset = 0.02; - this->presetOutputs.mv.y_offset = 0.02; - - if ( beatDetect != NULL ) { beatDetect->reset(); } - this->presetInputs.progress = 0; - this->presetInputs.frame = 1; - this->presetInputs2.progress = 0; - this->presetInputs2.frame = 1; -// bass_thresh = 0; - - /* PER_FRAME CONSTANTS END */ - this->presetOutputs.fRating = 0; - this->presetOutputs.fGammaAdj = 1.0; - this->presetOutputs.videoEcho.zoom = 1.0; - this->presetOutputs.videoEcho.a = 0; - this->presetOutputs.videoEcho.orientation = Normal; - - this->presetOutputs.wave.additive = false; - this->presetOutputs.wave.dots = false; - this->presetOutputs.wave.thick = false; - this->presetOutputs.wave.modulateAlphaByVolume = 0; - this->presetOutputs.wave.maximizeColors = 0; - this->presetOutputs.textureWrap = 0; - this->presetOutputs.bDarkenCenter = 0; - this->presetOutputs.bRedBlueStereo = 0; - this->presetOutputs.bBrighten = 0; - this->presetOutputs.bDarken = 0; - this->presetOutputs.bSolarize = 0; - this->presetOutputs.bInvert = 0; - this->presetOutputs.bMotionVectorsOn = 1; - - this->presetOutputs.wave.a =1.0; - this->presetOutputs.wave.scale = 1.0; - this->presetOutputs.wave.smoothing = 0; - this->presetOutputs.wave.mystery = 0; - this->presetOutputs.wave.modOpacityEnd = 0; - this->presetOutputs.wave.modOpacityStart = 0; - this->presetOutputs.fWarpAnimSpeed = 0; - this->presetOutputs.fWarpScale = 0; - this->presetOutputs.fShader = 0; - - - /* PER_PIXEL CONSTANTS BEGIN */ - this->presetInputs2.x_per_pixel = 0; - this->presetInputs2.y_per_pixel = 0; - this->presetInputs2.rad_per_pixel = 0; - this->presetInputs2.ang_per_pixel = 0; - this->presetInputs.x_per_pixel = 0; - this->presetInputs.y_per_pixel = 0; - this->presetInputs.rad_per_pixel = 0; - this->presetInputs.ang_per_pixel = 0; - - /* PER_PIXEL CONSTANT END */ - - /* Q VARIABLES START */ - - for (int i = 0;i<32;i++) - presetOutputs.q[i] = 0; - + /// @bug call factory clear here? + std::cerr << "call factory clear?" << std::endl; + abort(); /* Q VARIABLES END */ } @@ -807,7 +653,7 @@ void projectM::selectPreset ( unsigned int index ) timeKeeper->StartPreset(); } -void projectM::switchPreset(std::auto_ptr & targetPreset, PresetInputs & inputs, PresetOutputs & outputs) { +void projectM::switchPreset(std::auto_ptr & targetPreset) { if (_settings.shuffleEnabled) *m_presetPos = m_presetChooser->weightedRandom(); @@ -818,7 +664,7 @@ void projectM::switchPreset(std::auto_ptr & targetPreset, PresetInputs & // Set preset name here- event is not done because at the moment this function is oblivious to smooth/hard switches renderer->setPresetName ( targetPreset->name() ); - renderer->SetPipeline(outputs); + renderer->SetPipeline(targetPreset->pipeline()); } diff --git a/src/libprojectM/projectM.hpp b/src/libprojectM/projectM.hpp index 99900ae20..f7a301a23 100755 --- a/src/libprojectM/projectM.hpp +++ b/src/libprojectM/projectM.hpp @@ -61,7 +61,6 @@ #include "dlldefs.h" #include "event.h" #include "fatal.h" -#include "PresetFrameIO.hpp" #include "PCM.hpp" #include "pthread.h" #include "PipelineContext.hpp" @@ -266,7 +265,6 @@ private: int count; float fpsstart; - void switchPreset(std::auto_ptr & targetPreset, PresetInputs & inputs, PresetOutputs & outputs); void readConfig(const std::string & configFile); void projectM_init(int gx, int gy, int fps, int texsize, int width, int height); void projectM_reset(); @@ -280,7 +278,6 @@ private: void destroyPresetTools(); void default_key_handler( projectMEvent event, projectMKeycode keycode ); - void setupPresetInputs(PresetInputs *inputs); /// The current position of the directory iterator PresetIterator * m_presetPos; @@ -296,14 +293,6 @@ private: /// Destination preset when smooth preset switching std::auto_ptr m_activePreset2; - /// All readonly variables which are passed as inputs to presets - PresetInputs presetInputs; - PresetInputs presetInputs2; - /// A preset outputs container used and modified by the "current" preset - PresetOutputs presetOutputs; - - /// A preset outputs container used for smooth preset switching - PresetOutputs presetOutputs2; TimeKeeper *timeKeeper; @@ -318,6 +307,7 @@ pthread_t thread; Pipeline* currentPipe; +void switchPreset(std::auto_ptr & targetPreset); };