diff --git a/src/projectM-engine/BeatDetect.cpp b/src/projectM-engine/BeatDetect.cpp index dd3d795cf..ce3259070 100755 --- a/src/projectM-engine/BeatDetect.cpp +++ b/src/projectM-engine/BeatDetect.cpp @@ -35,6 +35,7 @@ #include "projectM.hpp" #include "BeatDetect.hpp" #include "PCM.hpp" +#include DLLEXPORT BeatDetect::BeatDetect() { int x,y; @@ -156,13 +157,14 @@ void BeatDetect::getBeatVals( float *vdataL,float *vdataR ) { bass=(beat_instant[0])/(1.5*beat_history[0]); - if ( isnan( treb ) ) { + + if ( projectM_isnan( treb ) ) { treb = 0.0; } - if ( isnan( mid ) ) { + if ( projectM_isnan( mid ) ) { mid = 0.0; } - if ( isnan( bass ) ) { + if ( projectM_isnan( bass ) ) { bass = 0.0; } treb_att=.6 * treb_att + .4 * treb; diff --git a/src/projectM-engine/BuiltinParams.cpp b/src/projectM-engine/BuiltinParams.cpp index 50e1f7e40..ec5800db9 100644 --- a/src/projectM-engine/BuiltinParams.cpp +++ b/src/projectM-engine/BuiltinParams.cpp @@ -6,6 +6,8 @@ #include "Algorithms.hpp" #include "InitCondUtils.hpp" #include +#include + using namespace Algorithms; diff --git a/src/projectM-engine/Common.hpp b/src/projectM-engine/Common.hpp index 6d6776acd..21e0a0b5d 100755 --- a/src/projectM-engine/Common.hpp +++ b/src/projectM-engine/Common.hpp @@ -51,6 +51,10 @@ extern FILE *fmemopen(void *buf, size_t len, const char *pMode); #define STRING_BUFFER_SIZE 1024*150 #define STRING_LINE_SIZE 1024 +#define projectM_isnan(x) ((x) != (x)) +#define projectM_fmax(x,y) ((x) >= (y) ? (x): (y)) +#define projectM_fmin(x,y) ((x) <= (y) ? (x): (y)) + #ifndef TRUE #define TRUE 1 #endif diff --git a/src/projectM-engine/Expr.cpp b/src/projectM-engine/Expr.cpp index 3026d117f..1d3096292 100755 --- a/src/projectM-engine/Expr.cpp +++ b/src/projectM-engine/Expr.cpp @@ -59,7 +59,7 @@ float PrefunExpr::eval_prefun_expr ( int mesh_i, int mesh_j ) /* This is slightly less than safe, since who knows if the passed argument is valid. For speed purposes we'll go with this */ - float arg_list[this->num_args]; + float * arg_list = new float[this->num_args]; #ifdef EVAL_DEBUG_DOUBLE DWRITE ( "fn[" ); @@ -79,6 +79,7 @@ float PrefunExpr::eval_prefun_expr ( int mesh_i, int mesh_j ) } + delete(arg_list); #ifdef EVAL_DEBUG_DOUBLE DWRITE ( "]" ); diff --git a/src/projectM-engine/MoodBar.cpp b/src/projectM-engine/MoodBar.cpp index 5ccde4fb4..45dce1947 100644 --- a/src/projectM-engine/MoodBar.cpp +++ b/src/projectM-engine/MoodBar.cpp @@ -15,6 +15,8 @@ // #include "MoodBar.hpp" +#include "Common.hpp" + #include extern "C" { #include @@ -272,8 +274,8 @@ void MoodBar::stretchNormalize (float * rgb) avgbb /= (float) tb; // lost from here- what is theory behind this? - mini = fmaxf (avg + (avgb - avg) * 2.f, avgbb); - maxi = fminf (avg + (avgu - avg) * 2.f, avguu); + mini = projectM_fmax (avg + (avgb - avg) * 2.f, avgbb); + maxi = projectM_fmin (avg + (avgu - avg) * 2.f, avguu); delta = maxi - mini; if (delta == 0.f) @@ -282,7 +284,10 @@ void MoodBar::stretchNormalize (float * rgb) // Assign colos to normalized m_ringBufferue of last item in buffer // i = numvals-1; // m_ringBuffers[c]. - rgb[c] = finite (rgb[c]) ? fminf(1.f, fmaxf(0.f, (rgb[c] - mini) / delta)) +#ifdef LINUX + rgb[c] = finite (rgb[c]) ? projectM_fmin(1.f, projectM_fmax(0.f, (rgb[c] - mini) / delta)) : 0.f; +#endif + } } diff --git a/src/projectM-engine/PBuffer.hpp b/src/projectM-engine/PBuffer.hpp index 591b89a20..34dc08a91 100755 --- a/src/projectM-engine/PBuffer.hpp +++ b/src/projectM-engine/PBuffer.hpp @@ -38,7 +38,7 @@ #ifdef WIN32 #include -#include +#include #endif /** WIN32 */ #ifdef LINUX diff --git a/src/projectM-engine/Param.cpp b/src/projectM-engine/Param.cpp index 045e621cb..f32cc6c7e 100755 --- a/src/projectM-engine/Param.cpp +++ b/src/projectM-engine/Param.cpp @@ -159,7 +159,7 @@ Param * Param::new_param_int(char * name, short int flags, void * engine_val, /* Creates a new parameter of type bool */ Param * Param::new_param_bool(char * name, short int flags, void * engine_val, - int upper_bound, int lower_bound, bool init_val) { + bool upper_bound, bool lower_bound, bool init_val) { Param * param; CValue iv, ub, lb; diff --git a/src/projectM-engine/Param.hpp b/src/projectM-engine/Param.hpp index 0ad2b614d..29ce96027 100755 --- a/src/projectM-engine/Param.hpp +++ b/src/projectM-engine/Param.hpp @@ -97,7 +97,7 @@ public: static Param * new_param_int( char * name, short int flags, void * engine_val, int upper_bound, int lower_bound, int init_val ); static Param * new_param_bool( char * name, short int flags, void * engine_val, - int upper_bound, int lower_bound, bool init_val ); + bool upper_bound, bool lower_bound, bool init_val ); static Param * new_param_string(char * name, short int flags, void * engine_val); }; diff --git a/src/projectM-engine/PresetChooser.hpp b/src/projectM-engine/PresetChooser.hpp index 5f6064963..935f6c9cc 100644 --- a/src/projectM-engine/PresetChooser.hpp +++ b/src/projectM-engine/PresetChooser.hpp @@ -14,7 +14,6 @@ #include #include #include - class PresetChooser; /// A simple iterator class to traverse back and forth a preset directory @@ -218,8 +217,16 @@ inline std::auto_ptr PresetChooser::directoryIndex(std::size_t index, co template inline std::auto_ptr PresetChooser::doWeightedSample(WeightFunctor & weightFunctor, const PresetInputs & presetInputs, PresetOutputs & presetOutputs) { + +#ifdef WIN32 + // Choose a random bounded mass between 0 and 1 + float cutoff = ((float)(rand())) / RAND_MAX; +#endif + +#ifdef LINUX // Choose a random bounded mass between 0 and 1 float cutoff = ((float)(random())) / RAND_MAX; +#endif // Sum up mass, stopping when cutoff is reached. This is the typical // weighted sampling algorithm. diff --git a/src/projectM-engine/PresetLoader.cpp b/src/projectM-engine/PresetLoader.cpp index fe330051a..5bd2242bb 100644 --- a/src/projectM-engine/PresetLoader.cpp +++ b/src/projectM-engine/PresetLoader.cpp @@ -15,11 +15,14 @@ #include #include +#ifdef LINUX extern "C" { #include -#include } +#endif + + #include #include "projectM.hpp" @@ -114,6 +117,10 @@ std::auto_ptr PresetLoader::loadPreset(unsigned int index, const PresetI void PresetLoader::handleDirectoryError() { +#ifdef WIN32 + std::cerr << "[PresetLoader] warning: errno unsupported on win32 platforms. fix me" << std::endl; +#else + switch (errno) { case ENOENT: @@ -137,4 +144,5 @@ void PresetLoader::handleDirectoryError() default: break; } +#endif } diff --git a/src/projectM-engine/PresetLoader.hpp b/src/projectM-engine/PresetLoader.hpp index 3e3b079ab..0144744c6 100644 --- a/src/projectM-engine/PresetLoader.hpp +++ b/src/projectM-engine/PresetLoader.hpp @@ -5,7 +5,18 @@ #include // for auto pointers #include +#ifdef WIN32 +#include "win32-dirent.h" +#endif + +#ifdef LINUX #include +#endif + +#ifdef MACOS +#include +#endif + #include class Preset; diff --git a/src/projectM-engine/Renderer.hpp b/src/projectM-engine/Renderer.hpp index 496d46842..0fa0485ec 100644 --- a/src/projectM-engine/Renderer.hpp +++ b/src/projectM-engine/Renderer.hpp @@ -5,8 +5,16 @@ #include "PresetFrameIO.hpp" #include "BeatDetect.hpp" #include + +#ifdef LINUX #include #include +#endif + +#ifdef WIN32 +#include +#endif + #ifdef USE_FTGL #include #include diff --git a/src/projectM-engine/TextureManager.hpp b/src/projectM-engine/TextureManager.hpp index 08e37cdb4..0bcfc9d34 100644 --- a/src/projectM-engine/TextureManager.hpp +++ b/src/projectM-engine/TextureManager.hpp @@ -2,7 +2,12 @@ #define TextureManager_HPP #include "PresetFrameIO.hpp" +#ifdef LINUX #include +#endif +#ifdef WIN32 +#include +#endif #include "texture.h" #include #include diff --git a/src/projectM-engine/libprojectM.rc b/src/projectM-engine/libprojectM.rc new file mode 100644 index 000000000..11c5d52f7 --- /dev/null +++ b/src/projectM-engine/libprojectM.rc @@ -0,0 +1,61 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE 9, 1 +#pragma code_page(1252) + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/src/projectM-engine/libprojectM.vcproj b/src/projectM-engine/libprojectM.vcproj index 2baabf317..b88fdb680 100644 --- a/src/projectM-engine/libprojectM.vcproj +++ b/src/projectM-engine/libprojectM.vcproj @@ -117,7 +117,8 @@ Name="VCCLCompilerTool" Optimization="2" InlineFunctionExpansion="1" - PreprocessorDefinitions="WIN32;NDEBUG;_LIB" + AdditionalIncludeDirectories=""C:\Program Files\Microsoft Visual Studio 8\VC\include\GL"" + PreprocessorDefinitions="WIN32;NDEBUG;_LIB;GLEW_BUILD;USE_FBO" StringPooling="true" RuntimeLibrary="0" EnableFunctionLevelLinking="true" @@ -127,6 +128,8 @@ ProgramDataBaseFileName=".\Release/" WarningLevel="3" SuppressStartupBanner="true" + Detect64BitPortabilityProblems="true" + ShowIncludes="true" /> + + @@ -479,6 +486,10 @@ RelativePath=".\Renderer.hpp" > + + diff --git a/src/projectM-engine/projectM.cpp b/src/projectM-engine/projectM.cpp index eaaa02f59..7735b389e 100755 --- a/src/projectM-engine/projectM.cpp +++ b/src/projectM-engine/projectM.cpp @@ -33,6 +33,10 @@ #include "time.h" #endif +#ifdef WIN32 +#include +#endif + //#include #include #include "projectM.hpp" @@ -72,7 +76,7 @@ DLLEXPORT projectM::projectM(int gx, int gy, int fps, int texsize, int width, in projectM_resetGL( wvw, wvh ); } -DLLEXPORT projectM::~projectM() { +projectM::~projectM() { std::cerr << "[projectM] DESTROY PRESET TOOLS BEGIN" << std::endl; destroyPresetTools(); std::cerr << "[projectM] DESTROY PRESET TOOLS END" << std::endl; @@ -308,7 +312,7 @@ DLLEXPORT void projectM::renderFrame() DWRITE ( "exiting renderFrame()\n" ); } -DLLEXPORT void projectM::projectM_reset() +void projectM::projectM_reset() { // DWRITE( "projectM_reset(): in\n" ); diff --git a/src/projectM-engine/resource.h b/src/projectM-engine/resource.h new file mode 100644 index 000000000..a0b6e9601 --- /dev/null +++ b/src/projectM-engine/resource.h @@ -0,0 +1,14 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by libprojectM.rc + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/src/projectM-engine/texture.cpp b/src/projectM-engine/texture.cpp index 7d7386121..99e2a84f5 100644 --- a/src/projectM-engine/texture.cpp +++ b/src/projectM-engine/texture.cpp @@ -7,8 +7,14 @@ #include #include #include -#include +#ifdef LINUX +#include +#endif + +#ifdef WIN32 +#include +#endif // openGL extensions if not present, define them #ifndef GL_COMPRESSED_RGB_S3TC_DXT1_EXT