diff --git a/src/libprojectM/projectM.cpp b/src/libprojectM/projectM.cpp index 0090b8c56..dd6f036c6 100755 --- a/src/libprojectM/projectM.cpp +++ b/src/libprojectM/projectM.cpp @@ -106,12 +106,20 @@ DLLEXPORT void projectM::projectM_resetTextures() DLLEXPORT projectM::projectM ( std::string config_file, int flags) : beatDetect ( 0 ), renderer ( 0 ), _pcm(0), m_presetPos(0), m_flags(flags), _pipelineContext(new PipelineContext()) { - readConfig ( config_file ); + readConfig(config_file); projectM_reset(); - projectM_resetGL ( _settings.windowWidth, _settings.windowHeight); + projectM_resetGL(_settings.windowWidth, _settings.windowHeight); } +DLLEXPORT projectM::projectM(Settings settings, int flags): + beatDetect ( 0 ), renderer ( 0 ), _pcm(0), m_presetPos(0), m_flags(flags), _pipelineContext(new PipelineContext()) +{ + readSettings(settings); + projectM_reset(); + projectM_resetGL(_settings.windowWidth, _settings.windowHeight); +} + bool projectM::writeConfig(const std::string & configFile, const Settings & settings) { @@ -212,6 +220,35 @@ void projectM::readConfig (const std::string & configFile ) } + +void projectM::readSettings (const Settings & settings ) +{ + _settings.meshX = settings.meshX; + _settings.meshY = settings.meshY; + _settings.textureSize = settings.textureSize; + _settings.fps = settings.fps; + _settings.windowWidth = settings.windowWidth; + _settings.windowHeight = settings.windowHeight; + _settings.smoothPresetDuration = settings.smoothPresetDuration; + _settings.presetDuration = settings.presetDuration; + + + _settings.presetURL = settings.presetURL; + _settings.titleFontURL = settings.titleFontURL; + _settings.menuFontURL = settings.menuFontURL; + _settings.shuffleEnabled = settings.shuffleEnabled; + + _settings.easterEgg = settings.easterEgg; + + projectM_init ( _settings.meshX, _settings.meshY, _settings.fps, + _settings.textureSize, _settings.windowWidth,_settings.windowHeight); + + + _settings.beatSensitivity = settings.beatSensitivity; + _settings.aspectCorrection = settings.aspectCorrection; + +} + #ifdef USE_THREADS static void *thread_callback(void *prjm) { projectM *p = (projectM *)prjm; diff --git a/src/libprojectM/projectM.hpp b/src/libprojectM/projectM.hpp index 31f5da28e..b288c5f97 100755 --- a/src/libprojectM/projectM.hpp +++ b/src/libprojectM/projectM.hpp @@ -64,7 +64,6 @@ #include "pthread.h" class PipelineContext; -//#include "PipelineContext.hpp" #include class BeatDetect; @@ -120,7 +119,26 @@ public: static const int FLAG_NONE = 0; static const int FLAG_DISABLE_PLAYLIST_LOAD = 1 << 0; + struct Settings { + int meshX; + int meshY; + int fps; + int textureSize; + int windowWidth; + int windowHeight; + std::string presetURL; + std::string titleFontURL; + std::string menuFontURL; + int smoothPresetDuration; + int presetDuration; + float beatSensitivity; + bool aspectCorrection; + float easterEgg; + bool shuffleEnabled; + }; + DLLEXPORT projectM(std::string config_file, int flags = FLAG_NONE); + DLLEXPORT projectM(Settings settings, int flags = FLAG_NONE); //DLLEXPORT projectM(int gx, int gy, int fps, int texsize, int width, int height,std::string preset_url,std::string title_fonturl, std::string title_menuurl); @@ -135,23 +153,7 @@ public: DLLEXPORT virtual ~projectM(); - struct Settings { - int meshX; - int meshY; - int fps; - int textureSize; - int windowWidth; - int windowHeight; - std::string presetURL; - std::string titleFontURL; - std::string menuFontURL; - int smoothPresetDuration; - int presetDuration; - float beatSensitivity; - bool aspectCorrection; - float easterEgg; - bool shuffleEnabled; - }; + DLLEXPORT const Settings & settings() const { @@ -267,7 +269,8 @@ private: int count; float fpsstart; - void readConfig(const std::string & configFile); + void readConfig(const std::string &configFile); + void readSettings(const Settings &settings); void projectM_init(int gx, int gy, int fps, int texsize, int width, int height); void projectM_reset();