Config-file less constructor

git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@1231 6778bc44-b910-0410-a7a0-be141de4315d
This commit is contained in:
psperl
2009-07-10 02:58:36 +00:00
parent 7f70b88c81
commit 96f98abffd
2 changed files with 61 additions and 21 deletions

View File

@ -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;

View File

@ -64,7 +64,6 @@
#include "pthread.h"
class PipelineContext;
//#include "PipelineContext.hpp"
#include <memory>
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();