diff --git a/src/projectM-engine/KeyHandler.cpp b/src/projectM-engine/KeyHandler.cpp index 7a2f6b104..476d76cc3 100755 --- a/src/projectM-engine/KeyHandler.cpp +++ b/src/projectM-engine/KeyHandler.cpp @@ -58,7 +58,7 @@ void refreshConsole() { } -void projectM::key_handler( projectMEvent event, +DLLEXPORT void projectM::key_handler( projectMEvent event, projectMKeycode keycode, projectMModifier modifier ) { switch( event ) { diff --git a/src/projectM-engine/projectM.cpp b/src/projectM-engine/projectM.cpp index 7468479a7..890d2dad8 100755 --- a/src/projectM-engine/projectM.cpp +++ b/src/projectM-engine/projectM.cpp @@ -68,7 +68,7 @@ double smoothDuration = 5; //int smoothFrame = 0; int oldFrame = 1; -DLLEXPORT projectM::projectM(int gx, int gy, int fps, int texsize, int width, int height, std::string preset_url) :renderer(0), renderTarget(0), presetURL(preset_url), smoothFrame(0), beatDetect ( 0 ) { +DLLEXPORT projectM::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) :renderer(0), renderTarget(0), presetURL(preset_url), title_fontURL(title_fonturl), menu_fontURL(menu_fontURL), smoothFrame(0), beatDetect ( 0 ) { presetURL = preset_url; projectM_reset(); projectM_init(gx, gy, fps, texsize, width, height); @@ -113,9 +113,6 @@ void projectM::readConfig(std::string config_file) smoothDuration = config.read( "Smooth Transition Duration", 5 ); presetDuration = config.read( "Preset Duration", 15 ); - int fullscreen; - if (config.read("Fullscreen", true)) fullscreen = 1; - else fullscreen = 0; presetURL = config.read( "Preset Path", "/usr/share/projectM/presets" ); @@ -300,41 +297,18 @@ DLLEXPORT void projectM::renderFrame() } void projectM::projectM_reset() -{ - -// DWRITE( "projectM_reset(): in\n" ); - - /// @bug uncertain if preset should be played with here - carm -// m_activePreset = 0; - -// if (m_activePreset) { -// delete(m_activePreset); - // m_activePreset = 0; - // } - - //this->presetURL = ""; - //this->title_fontURL = ""; - +{ /** Default variable settings */ - this->hasInit = 0; - - this->pcmframes = 1; - this->freqframes = 0; - - - - this->fvw = 800; - this->fvh = 600; + this->wvw = 512; this->wvh = 512; - this->fullscreen = 0; + /** Frames per preset */ this->avgtime = 500; - /** More other stuff */ this->mspf = 0; this->timed = 0; @@ -495,20 +469,10 @@ void projectM::projectM_reset() mspf= ( int ) ( 1000.0/ ( float ) presetInputs.fps ); else mspf = 0; -// initMenu(); -//DWRITE( "post initMenu()\n" ); - -// printf ( "mesh: %d %d\n", gx,gy ); - -#ifdef PANTS - printf ( "maxsamples: %d\n", this->maxsamples ); - initPCM ( this->maxsamples ); - DWRITE ( "post PCM init\n" ); -#endif this->avgtime=(int)(this->presetInputs.fps*presetDuration); - this->hasInit = 1; + this->renderTarget = new RenderTarget ( texsize, width, height ); this->textureManager = new TextureManager(presetURL); @@ -524,13 +488,6 @@ void projectM::projectM_reset() } - - -//calculate matrices for per_pixel - - - - void projectM::projectM_initengine() { @@ -644,27 +601,6 @@ void projectM::projectM_initengine() /* Q AND T VARIABLES END */ -//per pixel meshes - /* - // this->presetOutputs.zoom_mesh = NULL; - // this->presetOutputs.zoomexp_mesh = NULL; - //this->presetOutputs.rot_mesh = NULL; - - - // this->presetOutputs.sx_mesh = NULL; - // this->presetOutputs.sy_mesh = NULL; - // this->presetOutputs.dx_mesh = NULL; - // this->presetOutputs.dy_mesh = NULL; - // this->presetOutputs.cx_mesh = NULL; - // this->presetOutputs.cy_mesh = NULL; - - // this->presetInputs.x_mesh = NULL; - / this->presetInputs.y_mesh = NULL; - // this->presetInputs.rad_mesh = NULL; - // this->presetInputs.theta_mesh = NULL; - */ - -//custom wave per point meshes } /* Reinitializes the engine variables to a default (conservative and sane) value */ @@ -794,11 +730,11 @@ DLLEXPORT void projectM::projectM_resetGL ( int w, int h ) /** Sets the title to display */ DLLEXPORT void projectM::projectM_setTitle ( std::string title ) { - if (title != renderer->title) - { - renderer->title=title; - renderer->drawtitle=1; - } + if (title != renderer->title) + { + renderer->title=title; + renderer->drawtitle=1; + } } diff --git a/src/projectM-engine/projectM.hpp b/src/projectM-engine/projectM.hpp index cc07b6fbf..bad4ecd52 100755 --- a/src/projectM-engine/projectM.hpp +++ b/src/projectM-engine/projectM.hpp @@ -109,114 +109,98 @@ typedef enum { } interface_t; -class projectM { +class projectM +{ public: - - Renderer *renderer; - RenderTarget *renderTarget; - TextureManager *textureManager; + + Renderer *renderer; + BeatDetect * beatDetect; + + /* PER_FRAME CONSTANTS END */ + + /** Functions */ + + DLLEXPORT projectM(std::string config_file); + 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); + + DLLEXPORT void projectM_resetGL( int width, int height ); + DLLEXPORT void projectM_setTitle( std::string title ); + DLLEXPORT void renderFrame(); + + DLLEXPORT void key_handler( projectMEvent event, + projectMKeycode keycode, projectMModifier modifier ); + + ~projectM(); + +private: + + TextureManager *textureManager; + RenderTarget *renderTarget; std::string presetURL; - + std::string title_fontURL; std::string menu_fontURL; - int hasInit; - - int pcmframes; - int freqframes; - int smoothFrame; - - + #ifndef WIN32 - /* The first ticks value of the application */ - struct timeval startTime; + /* The first ticks value of the application */ + struct timeval startTime; #else - long startTime; + long startTime; #endif /** !WIN32 */ - int fvw; //fullscreen dimensions - int fvh; - int wvw; //windowed dimensions - int wvh; + int wvw; //windowed dimensions + int wvh; + + int avgtime; //# frames per preset + + /** Timing information */ + int mspf; + int timed; + int timestart; + int nohard; + int count; + float fpsstart; - int fullscreen; + void readConfig(std::string config_file); + void projectM_init(int gx, int gy, int fps, int texsize, int width, int height); + void projectM_reset(); - int avgtime; //# frames per preset - - /** Timing information */ - int mspf; - int timed; - int timestart; - int nohard; - int count; - float fpsstart; - - /** Various toggles */ - /* PER_FRAME CONSTANTS END */ - - /** Beat detection engine */ - BeatDetect * beatDetect; - - /** Functions */ - DLLEXPORT projectM(int gx, int gy, int fps, int texsize, int width, int height,std::string preset_url); - - void projectM_init(int gx, int gy, int fps, int texsize, int width, int height); - void projectM_reset(); - DLLEXPORT void projectM_resetGL( int width, int height ); - DLLEXPORT void projectM_setTitle( std::string title ); - DLLEXPORT void renderFrame(); - - - void projectM_initengine(); - void projectM_resetengine(); - - DLLEXPORT projectM(std::string config_file); - void readConfig(std::string config_file); - - - void get_title(); - - void key_handler( projectMEvent event, - projectMKeycode keycode, projectMModifier modifier ); - void default_key_handler( projectMEvent event, projectMKeycode keycode ); - - /// Initializes preset loading / management libraries - int initPresetTools(); - - /// Deinitialize all preset related tools. Usually done before projectM cleanup - void destroyPresetTools(); - - ~projectM(); - - private: - - // The current position of the directory iterator - PresetIterator * m_presetPos; - - // Required by the preset chooser. Manages a loaded preset directory - PresetLoader * m_presetLoader; - - // Provides accessor functions to choose presets - PresetChooser * m_presetChooser; - - // Currently loaded preset - std::auto_ptr m_activePreset; - - // Destination preset when smooth preset switching - std::auto_ptr m_activePreset2; - - /// Experimental mood bar instance. May or may not make it into 1.0 release - MoodBar * moodBar; - - /// All readonly variables which are passed as inputs to presets - PresetInputs presetInputs; - - /// A preset outputs container used and modified by the "current" preset - PresetOutputs presetOutputs; - - /// A preset outputs container used for smooth preset switching - PresetOutputs presetOutputs2; + void projectM_initengine(); + void projectM_resetengine(); + /// Initializes preset loading / management libraries + int initPresetTools(); + + /// Deinitialize all preset related tools. Usually done before projectM cleanup + void destroyPresetTools(); + void default_key_handler( projectMEvent event, projectMKeycode keycode ); + // The current position of the directory iterator + PresetIterator * m_presetPos; + + // Required by the preset chooser. Manages a loaded preset directory + PresetLoader * m_presetLoader; + + // Provides accessor functions to choose presets + PresetChooser * m_presetChooser; + + // Currently loaded preset + std::auto_ptr m_activePreset; + + // Destination preset when smooth preset switching + std::auto_ptr m_activePreset2; + + /// Experimental mood bar instance. May or may not make it into 1.0 release + MoodBar * moodBar; + + /// All readonly variables which are passed as inputs to presets + PresetInputs presetInputs; + + /// A preset outputs container used and modified by the "current" preset + PresetOutputs presetOutputs; + + /// A preset outputs container used for smooth preset switching + PresetOutputs presetOutputs2; }; #endif diff --git a/src/projectM-jack/projectM-jack.cpp b/src/projectM-jack/projectM-jack.cpp index a5f40311a..0fa75aa33 100644 --- a/src/projectM-jack/projectM-jack.cpp +++ b/src/projectM-jack/projectM-jack.cpp @@ -179,9 +179,7 @@ void renderLoop() { if(key == PROJECTM_K_f) - { - - globalPM->fullscreen = fullscreen ^= 1; + { resize_display(fvw, fvh, fullscreen); globalPM->projectM_resetGL( fvw, fvh ); } diff --git a/src/projectM-test/projectM-test-memleak.cpp b/src/projectM-test/projectM-test-memleak.cpp index feba3a56c..a7c567829 100644 --- a/src/projectM-test/projectM-test-memleak.cpp +++ b/src/projectM-test/projectM-test-memleak.cpp @@ -182,9 +182,7 @@ void renderLoop() { if(key == SDLK_f) - { - - globalPM->fullscreen = fullscreen ^= 1; + { resize_display(fvw, fvh, fullscreen); globalPM->projectM_resetGL( fvw, fvh ); } diff --git a/src/projectM-test/projectM-test-texture.cpp b/src/projectM-test/projectM-test-texture.cpp index 265ec7ee4..52b24f7a4 100644 --- a/src/projectM-test/projectM-test-texture.cpp +++ b/src/projectM-test/projectM-test-texture.cpp @@ -179,7 +179,7 @@ void renderLoop() { if(key == PROJECTM_K_f) { - globalPM->fullscreen = fullscreen ^= 1; + resize_display(fvw, fvh, fullscreen); globalPM->projectM_resetGL( fvw, fvh ); } diff --git a/src/projectM-test/projectM-test.cpp b/src/projectM-test/projectM-test.cpp index 2e8d8ab64..f20089be7 100644 --- a/src/projectM-test/projectM-test.cpp +++ b/src/projectM-test/projectM-test.cpp @@ -182,8 +182,7 @@ void renderLoop() { if(key == SDLK_f) { - - globalPM->fullscreen = fullscreen ^= 1; + resize_display(fvw, fvh, fullscreen); globalPM->projectM_resetGL( fvw, fvh ); } diff --git a/src/projectM-xmms/main.cpp b/src/projectM-xmms/main.cpp index f4c8445c0..122dd62b5 100755 --- a/src/projectM-xmms/main.cpp +++ b/src/projectM-xmms/main.cpp @@ -217,7 +217,7 @@ int worker_func(void*) w = wvw; h = wvh; } - globalPM->fullscreen = fullscreen ^= 1; + resize_display(w, h, fullscreen); globalPM->projectM_resetGL( w, h ); }