diff --git a/Makefile.am b/Makefile.am index 6e1f9d416..4dc536589 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,4 @@ +ACLOCAL_AMFLAGS = -I m4 SUBDIRS=src PRESETSDIR = presets EXTRA_DIST=README.md AUTHORS.txt presets fonts src/libprojectM/Renderer/blur.cg src/libprojectM/Renderer/projectM.cg $(PRESETSDIR) diff --git a/README.md b/README.md index 9aeaadc83..beb807501 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,9 @@ Silverjuke (FOSS Jukebox) ## Linux (debian/ubuntu) * `sudo apt-get install autoconf libtool libsdl2-dev libglew-dev libftgl-dev libsdl2-dev libdevil-dev` +## FreeBSD +* `pkg install gcc autoconf automake libtool mesa-libs libGLU sdl2` + ## Mac OS X * [Prebuilt iTunes plugin installer](https://github.com/projectM-visualizer/projectm/releases) * [OSX Build instructions](https://github.com/projectM-visualizer/projectm/raw/master/BUILDING_OSX.txt) diff --git a/src/libprojectM/Common.hpp b/src/libprojectM/Common.hpp index 8e2a7547d..8bf484e6b 100755 --- a/src/libprojectM/Common.hpp +++ b/src/libprojectM/Common.hpp @@ -61,7 +61,7 @@ extern FILE *fmemopen(void *buf, size_t len, const char *pMode); #define STRING_LINE_SIZE 1024 -#ifdef __linux__ +#ifdef __unix__ #include #define projectM_isnan std::isnan #endif @@ -79,7 +79,7 @@ extern FILE *fmemopen(void *buf, size_t len, const char *pMode); #define projectM_isnan(x) ((x) != (x)) #endif -#ifdef __linux__ +#ifdef __unix__ #define projectM_fmax fmax #endif @@ -91,7 +91,7 @@ extern FILE *fmemopen(void *buf, size_t len, const char *pMode); #define projectM_fmax(x,y) ((x) >= (y) ? (x): (y)) #endif -#ifdef __linux__ +#ifdef __unix__ #define projectM_fmin fmin #endif @@ -245,5 +245,3 @@ enum PresetRatingType { typedef std::vector RatingList; #endif - - diff --git a/src/libprojectM/Makefile.am b/src/libprojectM/Makefile.am index fde2cb55c..0cdc7dc2a 100644 --- a/src/libprojectM/Makefile.am +++ b/src/libprojectM/Makefile.am @@ -29,7 +29,7 @@ libprojectM_la_SOURCES = ConfigFile.cpp Preset.cpp PresetLoader.cpp timer.cpp \ IdleTextures.hpp PresetChooser.hpp TimeKeeper.hpp\ KeyHandler.hpp PresetFactory.hpp projectM.hpp\ PCM.hpp PresetFactoryManager.hpp\ - projectM.hpp \ + projectM.hpp projectM-opengl.h \ ConfigFile.h glew.h\ carbontoprojectM.h glxew.h\ cocoatoprojectM.h lvtoprojectM.h\ diff --git a/src/libprojectM/PresetLoader.cpp b/src/libprojectM/PresetLoader.cpp index 4f184ceb9..85c07e6e5 100644 --- a/src/libprojectM/PresetLoader.cpp +++ b/src/libprojectM/PresetLoader.cpp @@ -16,7 +16,7 @@ #include #include -#ifdef __linux__ +#ifdef __unix__ extern "C" { #include @@ -63,7 +63,7 @@ void PresetLoader::rescan() // Clear the directory entry collection clear(); - + // If directory already opened, close it first if ( _dir ) { @@ -121,7 +121,7 @@ void PresetLoader::rescan() // Give all presets equal rating of 3 - why 3? I don't know _ratings = std::vector(TOTAL_RATING_TYPES, RatingList( _presetNames.size(), 3 )); _ratingsSums = std::vector(TOTAL_RATING_TYPES, 3 * _presetNames.size()); - + assert ( _entries.size() == _presetNames.size() ); @@ -194,10 +194,10 @@ void PresetLoader::handleDirectoryError() void PresetLoader::setRating(unsigned int index, int rating, const PresetRatingType ratingType) { assert ( index >=0 ); - + const unsigned int ratingTypeIndex = static_cast(ratingType); assert (index < _ratings[ratingTypeIndex].size()); - + _ratingsSums[ratingTypeIndex] -= _ratings[ratingTypeIndex][index]; _ratings[ratingTypeIndex][index] = rating; @@ -219,7 +219,7 @@ unsigned int PresetLoader::addPresetURL ( const std::string & url, const std::st for (int i = 0; i < ratings.size(); i++) _ratingsSums[i] += ratings[i]; - + return _entries.size()-1; } @@ -228,12 +228,12 @@ void PresetLoader::removePreset ( unsigned int index ) _entries.erase ( _entries.begin() + index ); _presetNames.erase ( _presetNames.begin() + index ); - + for (int i = 0; i < _ratingsSums.size(); i++) { _ratingsSums[i] -= _ratings[i][index]; _ratings[i].erase ( _ratings[i].begin() + index ); } - + } @@ -269,8 +269,8 @@ void PresetLoader::insertPresetURL ( unsigned int index, const std::string & url { _entries.insert ( _entries.begin() + index, url ); _presetNames.insert ( _presetNames.begin() + index, presetName ); - - + + for (int i = 0; i < _ratingsSums.size();i++) { _ratingsSums[i] += _ratings[i][index]; @@ -278,6 +278,6 @@ void PresetLoader::insertPresetURL ( unsigned int index, const std::string & url } assert ( _entries.size() == _presetNames.size() ); - - + + } diff --git a/src/libprojectM/PresetLoader.hpp b/src/libprojectM/PresetLoader.hpp index dea950154..8acbc0a30 100644 --- a/src/libprojectM/PresetLoader.hpp +++ b/src/libprojectM/PresetLoader.hpp @@ -9,7 +9,7 @@ #include "win32-dirent.h" #endif -#ifdef __linux__ +#ifdef __unix__ #include #endif @@ -31,15 +31,15 @@ class PresetFactory; class PresetLoader { public: - - - /// Initializes the preset loader with the target directory specified + + + /// Initializes the preset loader with the target directory specified PresetLoader(int gx, int gy, std::string dirname); - + ~PresetLoader(); - + /// Load a preset by specifying its unique identifier given when the preset url - /// was added to this loader + /// was added to this loader std::auto_ptr loadPreset(unsigned int index) const; std::auto_ptr loadPreset ( const std::string & url ) const; /// Add a preset to the loader's collection. @@ -48,17 +48,17 @@ class PresetLoader { /// \param rating an integer representing the goodness of the preset /// \returns The unique index assigned to the preset in the collection. Used with loadPreset unsigned int addPresetURL ( const std::string & url, const std::string & presetName, const RatingList & ratings); - + /// Add a preset to the loader's collection. /// \param index insertion index /// \param url an url referencing the preset /// \param presetName a name for the preset /// \param rating an integer representing the goodness of the preset void insertPresetURL (unsigned int index, const std::string & url, const std::string & presetName, const RatingList & ratings); - + /// Clears all presets from the collection - inline void clear() { - _entries.clear(); _presetNames.clear(); + inline void clear() { + _entries.clear(); _presetNames.clear(); _ratings = std::vector(TOTAL_RATING_TYPES, RatingList()); clearRatingsSum(); } @@ -66,8 +66,8 @@ class PresetLoader { inline void clearRatingsSum() { _ratingsSums = std::vector(TOTAL_RATING_TYPES, 0); } - - const std::vector & getPresetRatings() const; + + const std::vector & getPresetRatings() const; const std::vector & getPresetRatingsSums() const; /// Removes a preset from the loader @@ -76,29 +76,29 @@ class PresetLoader { /// Sets the rating of a preset to a new value void setRating(unsigned int index, int rating, const PresetRatingType ratingType); - + /// Get a preset rating given an index int getPresetRating ( unsigned int index, const PresetRatingType ratingType) const; - + /// Get a preset url given an index const std::string & getPresetURL ( unsigned int index) const; - + /// Get a preset name given an index const std::string & getPresetName ( unsigned int index) const; - - /// Returns the number of presets in the active directory + + /// Returns the number of presets in the active directory inline std::size_t size() const { return _entries.size(); } - - /// Sets the directory where the loader will search for files + + /// Sets the directory where the loader will search for files void setScanDirectory(std::string pathname); /// Returns the directory path associated with this preset chooser inline const std::string & directoryName() const { return _dirname; } - + /// Rescans the active preset directory void rescan(); void setPresetName(unsigned int index, std::string name); @@ -115,7 +115,7 @@ class PresetLoader { // Indexed by ratingType, preset position. std::vector _ratings; - + }; diff --git a/src/libprojectM/Renderer/FBO.hpp b/src/libprojectM/Renderer/FBO.hpp index 78f5ac4ce..92576283d 100755 --- a/src/libprojectM/Renderer/FBO.hpp +++ b/src/libprojectM/Renderer/FBO.hpp @@ -1,4 +1,4 @@ -/** + /** * projectM -- Milkdrop-esque visualisation SDK * Copyright (C)2003-2007 projectM Team * @@ -28,35 +28,7 @@ #ifndef _RENDERTARGET_H #define _RENDERTARGET_H - -#ifdef EMSCRIPTEN -#include -#endif - -#ifdef USE_FBO -#ifdef USE_INCLUDED_GLEW -#include "glew.h" -#else -#include -#endif -#endif - -#ifdef __APPLE__ -#include -#endif /** MACOS */ - -#ifdef WIN32 -#include -#endif /** WIN32 */ - -#ifdef __linux__ -#ifdef USE_GLES1 -#include -#else -#include -#include -#endif -#endif +#include typedef enum { SCALE_NEAREST, SCALE_MAGNIFY, SCALE_MINIFY } TextureScale; @@ -66,7 +38,7 @@ class RenderTarget { public: /** Texture size */ int texsize; - + int useFBO; int renderToTexture; @@ -90,7 +62,7 @@ public: /** Render target texture ID for non-pbuffer systems */ GLuint textureID[3]; #ifdef USE_FBO - GLuint fbuffer[2]; + GLuint fbuffer[2]; GLuint depthb[2]; #endif }; diff --git a/src/libprojectM/Renderer/Filters.cpp b/src/libprojectM/Renderer/Filters.cpp index 3e831f9d7..0cedcd08e 100644 --- a/src/libprojectM/Renderer/Filters.cpp +++ b/src/libprojectM/Renderer/Filters.cpp @@ -6,19 +6,7 @@ */ #include "Common.hpp" - -#ifdef USE_GLES1 -#include -#else -#ifdef __APPLE__ -#include -#include -#else -#include -#include -#endif -#endif - +#include "projectM-opengl.h" #include "Filters.hpp" void Brighten::Draw(RenderContext &context) @@ -95,4 +83,3 @@ void Solarize::Draw(RenderContext &context) glDisableClientState(GL_VERTEX_ARRAY); } - diff --git a/src/libprojectM/Renderer/MilkdropWaveform.cpp b/src/libprojectM/Renderer/MilkdropWaveform.cpp index 77144d938..1fbc85dac 100644 --- a/src/libprojectM/Renderer/MilkdropWaveform.cpp +++ b/src/libprojectM/Renderer/MilkdropWaveform.cpp @@ -5,22 +5,8 @@ * Author: pete */ #include - -#ifdef __linux__ -#include -#endif -#ifdef EMSCRIPTEN -#include -#endif -#ifdef WIN32 -#include "glew.h" -#endif -#ifdef __APPLE__ -#include -#endif - +#include "projectM-opengl.h" #include - #include "MilkdropWaveform.hpp" #include "math.h" #include "BeatDetect.hpp" diff --git a/src/libprojectM/Renderer/Renderable.cpp b/src/libprojectM/Renderer/Renderable.cpp index a905c7ba1..71609e66b 100644 --- a/src/libprojectM/Renderer/Renderable.cpp +++ b/src/libprojectM/Renderer/Renderable.cpp @@ -1,22 +1,5 @@ #include "Common.hpp" - -#ifdef USE_GLES1 - #ifdef EMSCRIPTEN - #include - #else - #include - #endif -#else -#ifdef __APPLE__ -#include -#include -#else -#include -#include -#endif -#endif - #include "Renderable.hpp" #include @@ -191,7 +174,7 @@ void Shape::Draw(RenderContext &context) delete[] colors; delete[] tex; - delete[] points; + delete[] points; } else {//Untextured (use color values) @@ -345,7 +328,7 @@ void Border::Draw(RenderContext &context) glRectd(texof-iff, of, texof, texof); glRectd(of+iff, texof, texof-iff, texof-iff); #endif - + float pointsE[4][2] = {{of,of},{of,texof},{of+iff,of},{of+iff,texof}}; glVertexPointer(2,GL_FLOAT,0,pointsE); glDrawArrays(GL_TRIANGLE_STRIP,0,4); diff --git a/src/libprojectM/Renderer/Renderable.hpp b/src/libprojectM/Renderer/Renderable.hpp index b2aa72f83..92622ed73 100644 --- a/src/libprojectM/Renderer/Renderable.hpp +++ b/src/libprojectM/Renderer/Renderable.hpp @@ -3,6 +3,8 @@ #include #include #include "TextureManager.hpp" +#include "projectM-opengl.h" + class BeatDetect; diff --git a/src/libprojectM/Renderer/Renderer.hpp b/src/libprojectM/Renderer/Renderer.hpp index 437c454f4..6191da935 100644 --- a/src/libprojectM/Renderer/Renderer.hpp +++ b/src/libprojectM/Renderer/Renderer.hpp @@ -6,17 +6,11 @@ #include "Common.hpp" #include #include - -#ifdef USE_GLES1 - #include -#else - #ifdef __APPLE__ - #include - #else - #include - #include - #endif -#endif +#include "projectM-opengl.h" +#include "Pipeline.hpp" +#include "PerPixelMesh.hpp" +#include "Transformation.hpp" +#include "ShaderEngine.hpp" #ifdef USE_FTGL #ifdef WIN32 @@ -28,15 +22,6 @@ #endif #endif /** USE_FTGL */ -#ifdef __linux__ - #include -#endif - - -#include "Pipeline.hpp" -#include "PerPixelMesh.hpp" -#include "Transformation.hpp" -#include "ShaderEngine.hpp" class UserTexture; class BeatDetect; diff --git a/src/libprojectM/Renderer/ShaderEngine.hpp b/src/libprojectM/Renderer/ShaderEngine.hpp index 754289625..c11ff4702 100644 --- a/src/libprojectM/Renderer/ShaderEngine.hpp +++ b/src/libprojectM/Renderer/ShaderEngine.hpp @@ -9,19 +9,7 @@ #define SHADERENGINE_HPP_ #include "Common.hpp" - -#ifdef USE_GLES1 -#include -#else -#ifdef __APPLE__ -#include -#include -#else -#include -#include -#endif -#endif - +#include "projectM-opengl.h" #ifdef USE_CG #include /* Can't include this? Is Cg Toolkit installed! */ @@ -110,4 +98,3 @@ public: }; #endif /* SHADERENGINE_HPP_ */ - diff --git a/src/libprojectM/Renderer/TextureManager.cpp b/src/libprojectM/Renderer/TextureManager.cpp index b017e44ba..c853caf45 100644 --- a/src/libprojectM/Renderer/TextureManager.cpp +++ b/src/libprojectM/Renderer/TextureManager.cpp @@ -1,15 +1,4 @@ -#ifdef __linux__ -#include -#endif -#ifdef EMSCRIPTEN -#include -#endif -#ifdef WIN32 -#include "glew.h" -#endif -#ifdef __APPLE__ -#include -#endif +#include "projectM-opengl.h" #ifdef USE_DEVIL #include @@ -21,7 +10,7 @@ #include "win32-dirent.h" #endif -#ifdef __linux__ +#ifdef __unix__ #include #endif #ifdef EMSCRIPTEN diff --git a/src/libprojectM/Renderer/VideoEcho.cpp b/src/libprojectM/Renderer/VideoEcho.cpp index 66d3ea5fa..6ac805c1a 100644 --- a/src/libprojectM/Renderer/VideoEcho.cpp +++ b/src/libprojectM/Renderer/VideoEcho.cpp @@ -5,20 +5,6 @@ * Author: pete */ -#include "Common.hpp" - -#ifdef USE_GLES1 -#include -#else -#ifdef __APPLE__ -#include -#include -#else -#include -#include -#endif -#endif - #include "VideoEcho.hpp" VideoEcho::VideoEcho(): a(0), zoom(1), orientation(Normal) diff --git a/src/libprojectM/Renderer/VideoEcho.hpp b/src/libprojectM/Renderer/VideoEcho.hpp index 13f027e35..a10606a11 100644 --- a/src/libprojectM/Renderer/VideoEcho.hpp +++ b/src/libprojectM/Renderer/VideoEcho.hpp @@ -8,7 +8,9 @@ #ifndef VIDEOECHO_HPP_ #define VIDEOECHO_HPP_ +#include "projectM-opengl.h" #include "Renderable.hpp" +#include "Common.hpp" enum Orientation { diff --git a/src/libprojectM/Renderer/Waveform.cpp b/src/libprojectM/Renderer/Waveform.cpp index 181e0464b..6ff47859e 100644 --- a/src/libprojectM/Renderer/Waveform.cpp +++ b/src/libprojectM/Renderer/Waveform.cpp @@ -5,19 +5,7 @@ * Author: pete */ -#ifdef __linux__ -#include -#endif -#ifdef WIN32 -#include "glew.h" -#endif -#ifdef __APPLE__ -#include -#endif -#ifdef EMSCRIPTEN -#include -#endif - +#include "projectM-opengl.h" #include "Waveform.hpp" #include #include "BeatDetect.hpp" @@ -124,6 +112,3 @@ void Waveform::Draw(RenderContext &context) delete[] value2; } - - - diff --git a/src/libprojectM/projectM-opengl.h b/src/libprojectM/projectM-opengl.h new file mode 100644 index 000000000..b10b52155 --- /dev/null +++ b/src/libprojectM/projectM-opengl.h @@ -0,0 +1,20 @@ +/** + Include appropriate OpenGL headers for this platform. +**/ + +#ifndef __PROJECTM_OPENGL_H__ +#define __PROJECTM_OPENGL_H__ + +#ifdef __APPLE__ +# include +#elif defined(_WIN32) +# include +#else /* linux/unix/other */ +# ifdef USE_GLES1 +# include +# else +# include +# endif +#endif + +#endif // __PROJECTM_OPENGL_H__ diff --git a/src/libprojectM/projectM.cpp b/src/libprojectM/projectM.cpp index 130b6be2d..8ba6ceca3 100755 --- a/src/libprojectM/projectM.cpp +++ b/src/libprojectM/projectM.cpp @@ -30,7 +30,7 @@ #include "timer.h" #include -#ifdef __linux__ +#ifdef __unix__ #include "time.h" #endif @@ -179,7 +179,7 @@ void projectM::readConfig (const std::string & configFile ) ( "Smooth Preset Duration", config.read("Smooth Transition Duration", 10)); _settings.presetDuration = config.read ( "Preset Duration", 15 ); - #ifdef __linux__ + #ifdef __unix__ _settings.presetURL = config.read ( "Preset Path", "/usr/local/share/projectM/presets" ); #endif @@ -199,7 +199,7 @@ void projectM::readConfig (const std::string & configFile ) ( "Menu Font", "../Resources/fonts/VeraMono.ttf"); #endif - #ifdef __linux__ + #ifdef __unix__ _settings.titleFontURL = config.read ( "Title Font", "/usr/local/share/projectM/fonts/Vera.tff" ); _settings.menuFontURL = config.read @@ -908,5 +908,3 @@ void projectM::getMeshSize(int *w, int *h) { *w = _settings.meshX; *h = _settings.meshY; } - - diff --git a/src/projectM-sdl/pmSDL.cpp b/src/projectM-sdl/pmSDL.cpp index 030f42a34..6cc913168 100644 --- a/src/projectM-sdl/pmSDL.cpp +++ b/src/projectM-sdl/pmSDL.cpp @@ -30,11 +30,15 @@ void projectMSDL::audioInputCallbackS16(void *userdata, unsigned char *stream, i SDL_AudioDeviceID projectMSDL::selectAudioInput(int count) { // ask the user which capture device to use - printf("Please select which audio input to use:\n"); + // printf("Please select which audio input to use:\n"); + printf("Detected devices\n"); for (int i = 0; i < count; i++) { printf("%i: 🎤%s", i, SDL_GetAudioDeviceName(i, true)); } SDL_AudioDeviceID device_id; + + return 0; + scanf("%u", &device_id); return device_id; } diff --git a/src/projectM-sdl/pmSDL.hpp b/src/projectM-sdl/pmSDL.hpp index abde695fa..bacf58fcd 100644 --- a/src/projectM-sdl/pmSDL.hpp +++ b/src/projectM-sdl/pmSDL.hpp @@ -9,20 +9,7 @@ #ifndef pmSDL_hpp #define pmSDL_hpp - - -#ifdef __linux__ -#ifdef USE_GLES1 -#include -#else -#include -#endif -#endif - -#ifdef __APPLE__ -#include -#endif - +#include "projectM-opengl.h" #include #include #include diff --git a/src/projectM-test/projectM-test-memleak.cpp b/src/projectM-test/projectM-test-memleak.cpp index c498197b2..51e72f9c4 100644 --- a/src/projectM-test/projectM-test-memleak.cpp +++ b/src/projectM-test/projectM-test-memleak.cpp @@ -25,7 +25,7 @@ #include "ConfigFile.h" #include "getConfigFilename.h" -#ifdef __linux__ +#ifdef __unix__ #include #endif #ifdef __APPLE__ @@ -204,4 +204,3 @@ void textureTest() { glMatrixMode(GL_MODELVIEW); glDisable(GL_DEPTH_TEST); } - diff --git a/src/projectM-test/projectM-test-texture.cpp b/src/projectM-test/projectM-test-texture.cpp index a5953c142..974582ee5 100644 --- a/src/projectM-test/projectM-test-texture.cpp +++ b/src/projectM-test/projectM-test-texture.cpp @@ -25,7 +25,7 @@ #include "ConfigFile.h" #include "getConfigFilename.h" -#ifdef __linux__ +#ifdef __unix__ #include #endif #ifdef __APPLE__ @@ -204,4 +204,3 @@ void textureTest() { glMatrixMode(GL_MODELVIEW); glDisable(GL_DEPTH_TEST); } - diff --git a/src/projectM-test/projectM-test.cpp b/src/projectM-test/projectM-test.cpp index 64e211404..27aef19b7 100644 --- a/src/projectM-test/projectM-test.cpp +++ b/src/projectM-test/projectM-test.cpp @@ -26,7 +26,7 @@ #include "getConfigFilename.h" #include -#ifdef __linux__ +#ifdef __unix__ #include #endif #ifdef __APPLE__ @@ -225,4 +225,3 @@ void textureTest() { glMatrixMode(GL_MODELVIEW); glDisable(GL_DEPTH_TEST); } -