Skip to content

Commit 5792fb3

Browse files
authored
Cross-platform GL include (#41)
* qt autoconf * WIP: Qt5 makefile * go away cmake * testing bsd define * readme * replacing __linux__ with __unix__ * sdl/libGLU * Revert "WIP: Qt5 makefile" This reverts commit aaa4456. * Revert "qt autoconf" This reverts commit a82dae3. * Revert "go away cmake" This reverts commit 1392d5e. * fix amflags for m4 dir * opengl header * opengl header * use one header for dealing with cross-platform GL includes * include opengl header in dist * fix _WIN32 (maybe?)
1 parent c16edd5 commit 5792fb3

24 files changed

+95
-223
lines changed

Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
ACLOCAL_AMFLAGS = -I m4
12
SUBDIRS=src
23
PRESETSDIR = presets
34
EXTRA_DIST=README.md AUTHORS.txt presets fonts src/libprojectM/Renderer/blur.cg src/libprojectM/Renderer/projectM.cg $(PRESETSDIR)

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ Silverjuke (FOSS Jukebox)
5959
## Linux (debian/ubuntu)
6060
* `sudo apt-get install autoconf libtool libsdl2-dev libglew-dev libftgl-dev libsdl2-dev libdevil-dev`
6161

62+
## FreeBSD
63+
* `pkg install gcc autoconf automake libtool mesa-libs libGLU sdl2`
64+
6265
## Mac OS X
6366
* [Prebuilt iTunes plugin installer](https://github.com/projectM-visualizer/projectm/releases)
6467
* [OSX Build instructions](https://github.com/projectM-visualizer/projectm/raw/master/BUILDING_OSX.txt)

src/libprojectM/Common.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ extern FILE *fmemopen(void *buf, size_t len, const char *pMode);
6161
#define STRING_LINE_SIZE 1024
6262

6363

64-
#ifdef __linux__
64+
#ifdef __unix__
6565
#include <cstdlib>
6666
#define projectM_isnan std::isnan
6767
#endif
@@ -79,7 +79,7 @@ extern FILE *fmemopen(void *buf, size_t len, const char *pMode);
7979
#define projectM_isnan(x) ((x) != (x))
8080
#endif
8181

82-
#ifdef __linux__
82+
#ifdef __unix__
8383
#define projectM_fmax fmax
8484
#endif
8585

@@ -91,7 +91,7 @@ extern FILE *fmemopen(void *buf, size_t len, const char *pMode);
9191
#define projectM_fmax(x,y) ((x) >= (y) ? (x): (y))
9292
#endif
9393

94-
#ifdef __linux__
94+
#ifdef __unix__
9595
#define projectM_fmin fmin
9696
#endif
9797

@@ -245,5 +245,3 @@ enum PresetRatingType {
245245
typedef std::vector<int> RatingList;
246246

247247
#endif
248-
249-

src/libprojectM/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ libprojectM_la_SOURCES = ConfigFile.cpp Preset.cpp PresetLoader.cpp timer.cpp \
2929
IdleTextures.hpp PresetChooser.hpp TimeKeeper.hpp\
3030
KeyHandler.hpp PresetFactory.hpp projectM.hpp\
3131
PCM.hpp PresetFactoryManager.hpp\
32-
projectM.hpp \
32+
projectM.hpp projectM-opengl.h \
3333
ConfigFile.h glew.h\
3434
carbontoprojectM.h glxew.h\
3535
cocoatoprojectM.h lvtoprojectM.h\

src/libprojectM/PresetLoader.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <sstream>
1717
#include <set>
1818

19-
#ifdef __linux__
19+
#ifdef __unix__
2020
extern "C"
2121
{
2222
#include <errno.h>
@@ -63,7 +63,7 @@ void PresetLoader::rescan()
6363

6464
// Clear the directory entry collection
6565
clear();
66-
66+
6767
// If directory already opened, close it first
6868
if ( _dir )
6969
{
@@ -121,7 +121,7 @@ void PresetLoader::rescan()
121121
// Give all presets equal rating of 3 - why 3? I don't know
122122
_ratings = std::vector<RatingList>(TOTAL_RATING_TYPES, RatingList( _presetNames.size(), 3 ));
123123
_ratingsSums = std::vector<int>(TOTAL_RATING_TYPES, 3 * _presetNames.size());
124-
124+
125125

126126
assert ( _entries.size() == _presetNames.size() );
127127

@@ -194,10 +194,10 @@ void PresetLoader::handleDirectoryError()
194194
void PresetLoader::setRating(unsigned int index, int rating, const PresetRatingType ratingType)
195195
{
196196
assert ( index >=0 );
197-
197+
198198
const unsigned int ratingTypeIndex = static_cast<unsigned int>(ratingType);
199199
assert (index < _ratings[ratingTypeIndex].size());
200-
200+
201201
_ratingsSums[ratingTypeIndex] -= _ratings[ratingTypeIndex][index];
202202

203203
_ratings[ratingTypeIndex][index] = rating;
@@ -219,7 +219,7 @@ unsigned int PresetLoader::addPresetURL ( const std::string & url, const std::st
219219

220220
for (int i = 0; i < ratings.size(); i++)
221221
_ratingsSums[i] += ratings[i];
222-
222+
223223
return _entries.size()-1;
224224
}
225225

@@ -228,12 +228,12 @@ void PresetLoader::removePreset ( unsigned int index )
228228

229229
_entries.erase ( _entries.begin() + index );
230230
_presetNames.erase ( _presetNames.begin() + index );
231-
231+
232232
for (int i = 0; i < _ratingsSums.size(); i++) {
233233
_ratingsSums[i] -= _ratings[i][index];
234234
_ratings[i].erase ( _ratings[i].begin() + index );
235235
}
236-
236+
237237

238238
}
239239

@@ -269,15 +269,15 @@ void PresetLoader::insertPresetURL ( unsigned int index, const std::string & url
269269
{
270270
_entries.insert ( _entries.begin() + index, url );
271271
_presetNames.insert ( _presetNames.begin() + index, presetName );
272-
273-
272+
273+
274274

275275
for (int i = 0; i < _ratingsSums.size();i++) {
276276
_ratingsSums[i] += _ratings[i][index];
277277
_ratings[i].insert ( _ratings[i].begin() + index, ratings[i] );
278278
}
279279

280280
assert ( _entries.size() == _presetNames.size() );
281-
282-
281+
282+
283283
}

src/libprojectM/PresetLoader.hpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "win32-dirent.h"
1010
#endif
1111

12-
#ifdef __linux__
12+
#ifdef __unix__
1313
#include <dirent.h>
1414
#endif
1515

@@ -31,15 +31,15 @@ class PresetFactory;
3131

3232
class PresetLoader {
3333
public:
34-
35-
36-
/// Initializes the preset loader with the target directory specified
34+
35+
36+
/// Initializes the preset loader with the target directory specified
3737
PresetLoader(int gx, int gy, std::string dirname);
38-
38+
3939
~PresetLoader();
40-
40+
4141
/// Load a preset by specifying its unique identifier given when the preset url
42-
/// was added to this loader
42+
/// was added to this loader
4343
std::auto_ptr<Preset> loadPreset(unsigned int index) const;
4444
std::auto_ptr<Preset> loadPreset ( const std::string & url ) const;
4545
/// Add a preset to the loader's collection.
@@ -48,26 +48,26 @@ class PresetLoader {
4848
/// \param rating an integer representing the goodness of the preset
4949
/// \returns The unique index assigned to the preset in the collection. Used with loadPreset
5050
unsigned int addPresetURL ( const std::string & url, const std::string & presetName, const RatingList & ratings);
51-
51+
5252
/// Add a preset to the loader's collection.
5353
/// \param index insertion index
5454
/// \param url an url referencing the preset
5555
/// \param presetName a name for the preset
5656
/// \param rating an integer representing the goodness of the preset
5757
void insertPresetURL (unsigned int index, const std::string & url, const std::string & presetName, const RatingList & ratings);
58-
58+
5959
/// Clears all presets from the collection
60-
inline void clear() {
61-
_entries.clear(); _presetNames.clear();
60+
inline void clear() {
61+
_entries.clear(); _presetNames.clear();
6262
_ratings = std::vector<RatingList>(TOTAL_RATING_TYPES, RatingList());
6363
clearRatingsSum();
6464
}
6565

6666
inline void clearRatingsSum() {
6767
_ratingsSums = std::vector<int>(TOTAL_RATING_TYPES, 0);
6868
}
69-
70-
const std::vector<RatingList> & getPresetRatings() const;
69+
70+
const std::vector<RatingList> & getPresetRatings() const;
7171
const std::vector<int> & getPresetRatingsSums() const;
7272

7373
/// Removes a preset from the loader
@@ -76,29 +76,29 @@ class PresetLoader {
7676

7777
/// Sets the rating of a preset to a new value
7878
void setRating(unsigned int index, int rating, const PresetRatingType ratingType);
79-
79+
8080
/// Get a preset rating given an index
8181
int getPresetRating ( unsigned int index, const PresetRatingType ratingType) const;
82-
82+
8383
/// Get a preset url given an index
8484
const std::string & getPresetURL ( unsigned int index) const;
85-
85+
8686
/// Get a preset name given an index
8787
const std::string & getPresetName ( unsigned int index) const;
88-
89-
/// Returns the number of presets in the active directory
88+
89+
/// Returns the number of presets in the active directory
9090
inline std::size_t size() const {
9191
return _entries.size();
9292
}
93-
94-
/// Sets the directory where the loader will search for files
93+
94+
/// Sets the directory where the loader will search for files
9595
void setScanDirectory(std::string pathname);
9696

9797
/// Returns the directory path associated with this preset chooser
9898
inline const std::string & directoryName() const {
9999
return _dirname;
100100
}
101-
101+
102102
/// Rescans the active preset directory
103103
void rescan();
104104
void setPresetName(unsigned int index, std::string name);
@@ -115,7 +115,7 @@ class PresetLoader {
115115

116116
// Indexed by ratingType, preset position.
117117
std::vector<RatingList> _ratings;
118-
118+
119119

120120
};
121121

src/libprojectM/Renderer/FBO.hpp

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/**
22
* projectM -- Milkdrop-esque visualisation SDK
33
* Copyright (C)2003-2007 projectM Team
44
*
@@ -28,35 +28,7 @@
2828
#ifndef _RENDERTARGET_H
2929
#define _RENDERTARGET_H
3030

31-
32-
#ifdef EMSCRIPTEN
33-
#include <GL/gl.h>
34-
#endif
35-
36-
#ifdef USE_FBO
37-
#ifdef USE_INCLUDED_GLEW
38-
#include "glew.h"
39-
#else
40-
#include <GL/glew.h>
41-
#endif
42-
#endif
43-
44-
#ifdef __APPLE__
45-
#include <OpenGL/gl.h>
46-
#endif /** MACOS */
47-
48-
#ifdef WIN32
49-
#include <windows.h>
50-
#endif /** WIN32 */
51-
52-
#ifdef __linux__
53-
#ifdef USE_GLES1
54-
#include <GLES/gl.h>
55-
#else
56-
#include <GL/gl.h>
57-
#include <GL/glx.h>
58-
#endif
59-
#endif
31+
#include <projectM-opengl.h>
6032

6133
typedef enum { SCALE_NEAREST, SCALE_MAGNIFY, SCALE_MINIFY } TextureScale;
6234

@@ -66,7 +38,7 @@ class RenderTarget {
6638
public:
6739
/** Texture size */
6840
int texsize;
69-
41+
7042
int useFBO;
7143
int renderToTexture;
7244

@@ -90,7 +62,7 @@ class RenderTarget {
9062
/** Render target texture ID for non-pbuffer systems */
9163
GLuint textureID[3];
9264
#ifdef USE_FBO
93-
GLuint fbuffer[2];
65+
GLuint fbuffer[2];
9466
GLuint depthb[2];
9567
#endif
9668
};

src/libprojectM/Renderer/Filters.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,7 @@
66
*/
77

88
#include "Common.hpp"
9-
10-
#ifdef USE_GLES1
11-
#include <GLES/gl.h>
12-
#else
13-
#ifdef __APPLE__
14-
#include <OpenGL/gl.h>
15-
#include <OpenGL/glu.h>
16-
#else
17-
#include <GL/gl.h>
18-
#include <GL/glu.h>
19-
#endif
20-
#endif
21-
9+
#include "projectM-opengl.h"
2210
#include "Filters.hpp"
2311

2412
void Brighten::Draw(RenderContext &context)
@@ -95,4 +83,3 @@ void Solarize::Draw(RenderContext &context)
9583

9684
glDisableClientState(GL_VERTEX_ARRAY);
9785
}
98-

src/libprojectM/Renderer/MilkdropWaveform.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,8 @@
55
* Author: pete
66
*/
77
#include <iostream>
8-
9-
#ifdef __linux__
10-
#include <GL/gl.h>
11-
#endif
12-
#ifdef EMSCRIPTEN
13-
#include <GL/gl.h>
14-
#endif
15-
#ifdef WIN32
16-
#include "glew.h"
17-
#endif
18-
#ifdef __APPLE__
19-
#include <OpenGL/gl.h>
20-
#endif
21-
8+
#include "projectM-opengl.h"
229
#include <cmath>
23-
2410
#include "MilkdropWaveform.hpp"
2511
#include "math.h"
2612
#include "BeatDetect.hpp"

0 commit comments

Comments
 (0)