1
|
diff --git a/configure.ac b/configure.ac
|
2
|
index e22593f..7d5cb42 100644
|
3
|
--- a/configure.ac
|
4
|
+++ b/configure.ac
|
5
|
@@ -946,6 +946,10 @@ if test "x$enable_lyricwiki" != "xno"; then
|
6
|
)
|
7
|
fi
|
8
|
|
9
|
+dnl Check for Opengl support
|
10
|
+dnl ========================
|
11
|
+AX_CHECK_GL
|
12
|
+
|
13
|
dnl OpenGL Spectrum Analyzer
|
14
|
dnl ========================
|
15
|
|
16
|
@@ -955,13 +959,7 @@ AC_ARG_ENABLE(glspectrum,
|
17
|
|
18
|
have_glspectrum=no
|
19
|
if test "x$enable_glspectrum" != "xno"; then
|
20
|
- AC_CHECK_LIB([GL], [glXChooseVisual],
|
21
|
- [have_glspectrum=yes
|
22
|
- VISUALIZATION_PLUGINS="$VISUALIZATION_PLUGINS gl-spectrum"],
|
23
|
- [if test "x$enable_glspectrum" = "xyes"; then
|
24
|
- AC_MSG_ERROR([Cannot find GLX development files, but compilation of OpenGL Spectrum Analyzer has been explicitly requested; please install GLX dev files and run configure again])
|
25
|
- fi]
|
26
|
- )
|
27
|
+ have_glspectrum=yes
|
28
|
fi
|
29
|
|
30
|
dnl *** End of all plugin checks ***
|
31
|
diff --git a/extra.mk.in b/extra.mk.in
|
32
|
index b4d6e0d..bb3ddde 100644
|
33
|
--- a/extra.mk.in
|
34
|
+++ b/extra.mk.in
|
35
|
@@ -84,3 +84,5 @@ XML_CFLAGS ?= @XML_CFLAGS@
|
36
|
XML_LIBS ?= @XML_LIBS@
|
37
|
XRENDER_CFLAGS ?= @XRENDER_CFLAGS@
|
38
|
XRENDER_LIBS ?= @XRENDER_LIBS@
|
39
|
+GL_CFLAGS ?= @GL_CFLAGS@
|
40
|
+GL_LIBS ?= @GL_LIBS@
|
41
|
diff --git a/src/gl-spectrum/Makefile b/src/gl-spectrum/Makefile
|
42
|
index 0d766ea..f985c4e 100644
|
43
|
--- a/src/gl-spectrum/Makefile
|
44
|
+++ b/src/gl-spectrum/Makefile
|
45
|
@@ -7,6 +7,6 @@ include ../../extra.mk
|
46
|
|
47
|
plugindir := ${plugindir}/${VISUALIZATION_PLUGIN_DIR}
|
48
|
|
49
|
-CFLAGS += ${PLUGIN_CFLAGS}
|
50
|
-CPPFLAGS += ${PLUGIN_CPPFLAGS} -I../.. ${GTK_CFLAGS}
|
51
|
-LIBS += -lm ${GTK_LIBS} -lGL
|
52
|
+CFLAGS += ${PLUGIN_CFLAGS} ${GL_CFLAGS}
|
53
|
+CPPFLAGS += ${PLUGIN_CPPFLAGS} -I../.. ${GTK_CFLAGS} ${GL_CFLAGS}
|
54
|
+LIBS += -lm ${GTK_LIBS} ${GL_LIBS}
|
55
|
diff --git a/src/gl-spectrum/gl-spectrum.c b/src/gl-spectrum/gl-spectrum.c
|
56
|
index 111acff..d3abc6f 100644
|
57
|
--- a/src/gl-spectrum/gl-spectrum.c
|
58
|
+++ b/src/gl-spectrum/gl-spectrum.c
|
59
|
@@ -27,11 +27,23 @@
|
60
|
#include <audacious/i18n.h>
|
61
|
#include <audacious/plugin.h>
|
62
|
|
63
|
-#include <gdk/gdkx.h>
|
64
|
+#include <gdk/gdk.h>
|
65
|
#include <gtk/gtk.h>
|
66
|
|
67
|
#include <GL/gl.h>
|
68
|
+
|
69
|
+#ifdef GDK_WINDOWING_X11
|
70
|
#include <GL/glx.h>
|
71
|
+#include <gdk/gdkx.h>
|
72
|
+#endif
|
73
|
+
|
74
|
+#ifdef GDK_WINDOWING_WIN32
|
75
|
+#include <gdk/gdkwin32.h>
|
76
|
+#endif
|
77
|
+
|
78
|
+#ifdef GDK_WINDOWING_QUARTZ
|
79
|
+#include <gdk/gdkquartz.h>
|
80
|
+#endif
|
81
|
|
82
|
#define NUM_BANDS 32
|
83
|
#define DB_RANGE 40
|
84
|
@@ -42,7 +54,10 @@
|
85
|
static float logscale[NUM_BANDS + 1];
|
86
|
static float colors[NUM_BANDS][NUM_BANDS][3];
|
87
|
|
88
|
+#ifdef GDK_WINDOWING_X11
|
89
|
static GLXContext s_context;
|
90
|
+#endif
|
91
|
+
|
92
|
static GtkWidget * s_widget = NULL;
|
93
|
|
94
|
static int s_pos = 0;
|
95
|
@@ -200,10 +215,48 @@ static void draw_bars (void)
|
96
|
|
97
|
static bool_t draw_cb (GtkWidget * widget, cairo_t * cr)
|
98
|
{
|
99
|
+#ifdef GDK_WINDOWING_X11
|
100
|
Display * xdisplay = GDK_SCREEN_XDISPLAY (gdk_screen_get_default ());
|
101
|
Window xwindow = GDK_WINDOW_XID (gtk_widget_get_window (widget));
|
102
|
|
103
|
glXMakeCurrent (xdisplay, xwindow, s_context);
|
104
|
+#endif
|
105
|
+
|
106
|
+#ifdef GDK_WINDOWING_WIN32
|
107
|
+ PIXELFORMATDESCRIPTOR pfd= // Pixel Format Descriptor
|
108
|
+ {
|
109
|
+ sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
|
110
|
+ 1, // Version Number (?)
|
111
|
+ PFD_DRAW_TO_WINDOW | // Format Must Support Window
|
112
|
+ PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
|
113
|
+ PFD_DOUBLEBUFFER, // Must Support Double Buffering
|
114
|
+ PFD_TYPE_RGBA, // Request An RGBA Format
|
115
|
+ 24, // Select A 8:8:8 Bit Color Depth
|
116
|
+ 0, 0, 0, 0, 0, 0, // Color Bits Ignored (?)
|
117
|
+ 0, // No Alpha Buffer
|
118
|
+ 0, // Shift Bit Ignored (?)
|
119
|
+ 0, // No Accumulation Buffer
|
120
|
+ 0, 0, 0, 0, // Accumulation Bits Ignored (?)
|
121
|
+ 16, // 16Bit Z-Buffer (Depth Buffer)
|
122
|
+ 0, // No Stencil Buffer
|
123
|
+ 0, // No Auxiliary Buffer (?)
|
124
|
+ PFD_MAIN_PLANE, // Main Drawing Layer
|
125
|
+ 0, // Reserved (?)
|
126
|
+ 0, 0, 0 // Layer Masks Ignored (?)
|
127
|
+ };
|
128
|
+
|
129
|
+ GdkWindow *window = gtk_widget_get_window(widget);
|
130
|
+ HWND hWnd = GDK_WINDOW_HWND(window);
|
131
|
+ HDC hDC = GetDC(hWnd);
|
132
|
+ HGLRC hRC = wglCreateContext(hDC);
|
133
|
+ GLuint Found;
|
134
|
+
|
135
|
+ Found = ChoosePixelFormat(hDC, &pfd);
|
136
|
+ if (Found)
|
137
|
+ SetPixelFormat(hDC, Found, &pfd);
|
138
|
+
|
139
|
+ wglMakeCurrent(hDC, hRC);
|
140
|
+#endif
|
141
|
|
142
|
GtkAllocation alloc;
|
143
|
gtk_widget_get_allocation (widget, & alloc);
|
144
|
@@ -235,7 +288,21 @@ static bool_t draw_cb (GtkWidget * widget, cairo_t * cr)
|
145
|
glDisable (GL_BLEND);
|
146
|
glDepthMask (GL_TRUE);
|
147
|
|
148
|
+#ifdef GDK_WINDOWING_X11
|
149
|
glXSwapBuffers (xdisplay, xwindow);
|
150
|
+#endif
|
151
|
+
|
152
|
+#ifdef GDK_WINDOWING_WIN32
|
153
|
+ SwapBuffers(hDC);
|
154
|
+
|
155
|
+ wglMakeCurrent(hDC, NULL);
|
156
|
+
|
157
|
+ // Kill The RC
|
158
|
+ wglDeleteContext(hRC);
|
159
|
+
|
160
|
+ // Free The DC
|
161
|
+ ReleaseDC(hWnd, hDC);
|
162
|
+#endif
|
163
|
|
164
|
return TRUE;
|
165
|
}
|
166
|
@@ -250,6 +317,7 @@ static /* GtkWidget * */ void * get_widget (void)
|
167
|
g_signal_connect (s_widget, "draw", (GCallback) draw_cb, NULL);
|
168
|
g_signal_connect (s_widget, "destroy", (GCallback) gtk_widget_destroyed, & s_widget);
|
169
|
|
170
|
+#ifdef GDK_WINDOWING_X11
|
171
|
GdkScreen * screen = gdk_screen_get_default ();
|
172
|
Display * xdisplay = GDK_SCREEN_XDISPLAY (screen);
|
173
|
int nscreen = GDK_SCREEN_XNUMBER (screen);
|
174
|
@@ -272,6 +340,7 @@ static /* GtkWidget * */ void * get_widget (void)
|
175
|
/* Fix up visual/colormap */
|
176
|
GdkVisual * visual = gdk_x11_screen_lookup_visual (screen, xvinfo->visualid);
|
177
|
gtk_widget_set_visual (s_widget, visual);
|
178
|
+#endif
|
179
|
|
180
|
/* Disable GTK double buffering */
|
181
|
gtk_widget_set_double_buffered (s_widget, FALSE);
|