Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ runs:
mingw-w64-ucrt-x86_64-flac
mingw-w64-ucrt-x86_64-fluidsynth
mingw-w64-ucrt-x86_64-gcc
mingw-w64-ucrt-x86_64-glm
mingw-w64-ucrt-x86_64-gtk2
mingw-w64-ucrt-x86_64-json-glib
mingw-w64-ucrt-x86_64-lame
mingw-w64-ucrt-x86_64-libbs2b
mingw-w64-ucrt-x86_64-libcdio-paranoia
mingw-w64-ucrt-x86_64-libcue
mingw-w64-ucrt-x86_64-libepoxy
mingw-w64-ucrt-x86_64-libmodplug
mingw-w64-ucrt-x86_64-libopenmpt
mingw-w64-ucrt-x86_64-libsamplerate
Expand Down
6 changes: 4 additions & 2 deletions .github/actions/install-dependencies/install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ ubuntu_packages='gettext libadplug-dev libasound2-dev libavformat-dev
libmpg123-dev libneon27-gnutls-dev libnotify-dev libopenmpt-dev
libopusfile-dev libpipewire-0.3-dev libpulse-dev
libsamplerate0-dev libsdl2-dev libsidplayfp-dev libsndfile1-dev
libsndio-dev libsoxr-dev libvorbis-dev libwavpack-dev libxml2-dev'
libsndio-dev libsoxr-dev libvorbis-dev libwavpack-dev libxml2-dev
libepoxy-dev libglm-dev'

ubuntu_qt5_packages='libqt5opengl5-dev libqt5svg5-dev libqt5x11extras5-dev
qtbase5-dev qtmultimedia5-dev'
ubuntu_qt6_packages='qt6-base-dev qt6-multimedia-dev qt6-svg-dev'

macos_packages='adplug faad2 ffmpeg libbs2b libcue libmms libmodplug libnotify
libopenmpt libsamplerate libsoxr neon opusfile sdl3 wavpack'
libopenmpt libsamplerate libsoxr neon opusfile sdl3 wavpack
libepoxy glm'

case "$os" in
ubuntu-22.04)
Expand Down
2 changes: 2 additions & 0 deletions config.h.meson
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#mesondefine USE_QT
#mesondefine USE_GTK
#mesondefine USE_GTK3
#mesondefine USE_GTKGLAREA
#mesondefine USE_MODERNGL
#mesondefine USE_GTK_OR_QT

#define GLIB_VERSION_MIN_REQUIRED GLIB_VERSION_2_32
Expand Down
23 changes: 20 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -495,18 +495,35 @@ dnl Optional plugins (GTK-only)
dnl ===========================

test_glspectrum () {
if test $HAVE_DARWIN = yes ; then
PKG_CHECK_MODULES(EPOXY, epoxy, [have_epoxy=yes], [have_epoxy=no])
AC_LANG_PUSH([C++])
AC_CHECK_HEADER([glm/glm.hpp], [have_glm=yes], [have_glm=no])
AC_LANG_POP([C++])

GL_LIBS=""

if test $have_glm = yes && test $have_epoxy = yes ; then
GL_LIBS="$EPOXY_LIBS"
AC_DEFINE(USE_MODERNGL, [1], [Define if Modern GL should be used])
fi

if test "x$USE_MODERNGL" = "xyes" && test "x$USE_GTK2" = "xno" ; then
have_glspectrum=yes
GL_LIBS="$GL_LIBS -lGL"
AC_DEFINE(USE_GTKGLAREA, [1], [Define if GtkGLArea should be used])
elif test $HAVE_DARWIN = yes ; then
have_glspectrum=no
elif test $HAVE_MSWINDOWS = yes ; then
have_glspectrum=yes
GL_LIBS="-lopengl32"
GL_LIBS="$GL_LIBS -lopengl32"
else
AC_CHECK_LIB(GL, glXCreateContext, [
have_glspectrum=yes
GL_LIBS="-lGL -lX11"
GL_LIBS="$GL_LIBS -lGL -lX11"
], [have_glspectrum=no])
fi
AC_SUBST(GL_LIBS)
AC_SUBST(GL_CFLAGS, [$EPOXY_CFLAGS])
}

ENABLE_PLUGIN_WITH_TEST(glspectrum,
Expand Down
4 changes: 2 additions & 2 deletions src/glspectrum/Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
PLUGIN = gl-spectrum${PLUGIN_SUFFIX}

SRCS = gl-spectrum.cc
SRCS = gl-spectrum.cc modern_renderer.cc

include ../../buildsys.mk
include ../../extra.mk

plugindir := ${plugindir}/${VISUALIZATION_PLUGIN_DIR}

LD = ${CXX}
CFLAGS += ${PLUGIN_CFLAGS}
CFLAGS += ${PLUGIN_CFLAGS} ${GL_CFLAGS}
CPPFLAGS += ${PLUGIN_CPPFLAGS} -I../.. ${GTK_CFLAGS}
LIBS += -lm ${GTK_LIBS} ${GL_LIBS}
116 changes: 100 additions & 16 deletions src/glspectrum/gl-spectrum.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,22 @@
#include <libaudcore/i18n.h>
#include <libaudcore/plugin.h>
#include <libaudgui/gtk-compat.h>
#include <libaudcore/runtime.h>

#include <gdk/gdk.h>
#include <gtk/gtk.h>

#include <GL/gl.h>

#ifdef USE_MODERNGL
#include "modern_renderer.h"
#endif

#ifdef USE_GTKGLAREA
#undef GDK_WINDOWING_X11
#undef GDK_WINDOWING_WIN32
#endif

#ifdef GDK_WINDOWING_X11
#include <GL/glx.h>
#include <gdk/gdkx.h>
Expand Down Expand Up @@ -82,6 +92,10 @@ EXPORT GLSpectrum aud_plugin_instance;
static float logscale[NUM_BANDS + 1];
static float colors[NUM_BANDS][NUM_BANDS][3];

#ifdef USE_MODERNGL
static ModernRenderer * modern_renderer = nullptr;
#endif

#ifdef GDK_WINDOWING_X11
static Display * s_display;
static Window s_xwindow;
Expand Down Expand Up @@ -265,7 +279,16 @@ static gboolean draw_cb (GtkWidget * widget)

glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

draw_bars ();
#ifdef USE_MODERNGL
if (modern_renderer)
{
modern_renderer->render ((float *)s_bars, s_pos, s_angle);
}
else
#endif
{
draw_bars ();
}

#ifdef GDK_WINDOWING_X11
glXSwapBuffers (s_display, s_xwindow);
Expand All @@ -281,16 +304,26 @@ static gboolean draw_cb (GtkWidget * widget)
static void aspect_viewport(GLint width, GLint height)
{
glViewport (0, 0, width, height);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glFrustum (-1.1f, 1, -1.5f, 1, 2, 10);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();

#ifdef USE_GTKGLAREA
if (!modern_renderer)
#endif
{
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glFrustum (-1.1f, 1, -1.5f, 1, 2, 10);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
}
}

static void widget_realized ()
{
#ifdef USE_GTKGLAREA
gtk_gl_area_make_current ((GtkGLArea *) s_widget);
#else
GdkWindow * window = gtk_widget_get_window (s_widget);
#endif

#ifdef GDK_WINDOWING_X11
GdkScreen * screen = gdk_window_get_screen (window);
Expand Down Expand Up @@ -364,23 +397,50 @@ static void widget_realized ()
wglMakeCurrent (s_hdc, s_glrc);
#endif

/* Initialize OpenGL */
GtkAllocation alloc;
gtk_widget_get_allocation (s_widget, & alloc);
#ifdef USE_MODERNGL
ModernRenderer* renderer =
new ModernRenderer (NUM_BANDS, BAR_SPACING, BAR_WIDTH, (float *)colors);

if (renderer->is_initialized ())
{
modern_renderer = renderer;
}
else
{
delete renderer;

AUDWARN ("Falling back to legacy OpenGL.\n");
}

if (!modern_renderer)
#endif
{
/* Initialize OpenGL */
GtkAllocation alloc;
gtk_widget_get_allocation (s_widget, & alloc);

aspect_viewport (alloc.width, alloc.height);
aspect_viewport (alloc.width, alloc.height);

glEnable (GL_DEPTH_TEST);
glDepthFunc (GL_LESS);
glDepthMask (GL_TRUE);
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
glClearColor (0, 0, 0, 1);
glEnable (GL_DEPTH_TEST);
glDepthFunc (GL_LESS);
glDepthMask (GL_TRUE);
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
glClearColor (0, 0, 0, 1);
}
}

static void widget_destroyed ()
{
s_widget = nullptr;

#if defined(USE_MODERNGL) && !defined(USE_GTKGLAREA)
if (modern_renderer)
{
delete modern_renderer;
modern_renderer = nullptr;
}
#endif

#ifdef GDK_WINDOWING_X11
if (s_context)
{
Expand Down Expand Up @@ -415,14 +475,38 @@ static void widget_resize (GtkWidget * widget, GdkEvent * event, gpointer data)
aspect_viewport (event->configure.width, event->configure.height);
}

#ifdef USE_GTKGLAREA
static void widget_unrealized (GtkGLArea * s_widget)
{
/* Make sure that GL context is active before deleting OpenGL stuff */
gtk_gl_area_make_current (s_widget);

if (modern_renderer)
{
delete modern_renderer;
modern_renderer = nullptr;
}
}
#endif

void * GLSpectrum::get_gtk_widget ()
{
if (s_widget)
return s_widget;

s_widget = gtk_drawing_area_new ();
s_widget =
#ifdef USE_GTKGLAREA
gtk_gl_area_new ();

gtk_gl_area_set_has_depth_buffer((GtkGLArea *) s_widget, true);

g_signal_connect (s_widget, "render", (GCallback) draw_cb, nullptr);
g_signal_connect (s_widget, "unrealize", (GCallback) widget_unrealized, nullptr);
#else
gtk_drawing_area_new ();

g_signal_connect (s_widget, AUDGUI_DRAW_SIGNAL, (GCallback) draw_cb, nullptr);
#endif
g_signal_connect (s_widget, "realize", (GCallback) widget_realized, nullptr);
g_signal_connect (s_widget, "destroy", (GCallback) widget_destroyed, nullptr);
g_signal_connect (s_widget, "configure-event", (GCallback) widget_resize, nullptr);
Expand Down
20 changes: 17 additions & 3 deletions src/glspectrum/meson.build
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
opengl_dep = dependency('GL', required: false)
have_glspectrum = opengl_dep.found() and (have_windows or x11_dep.found())
epoxy_dep = dependency('epoxy', required: false)
glm_dep = dependency('glm', required: false)

if epoxy_dep.found() and glm_dep.found()
conf.set10('USE_MODERNGL', true)
endif

if conf.has('USE_GTK3') and conf.has('USE_MODERNGL')
conf.set10('USE_GTKGLAREA', true)
endif

have_glspectrum = opengl_dep.found() and (
(have_windows or x11_dep.found()) or
conf.has('USE_GTKGLAREA')
)

if have_glspectrum
shared_module('gl-spectrum',
'gl-spectrum.cc',
dependencies: [audacious_dep, math_dep, gtk_dep, opengl_dep, x11_dep],
'gl-spectrum.cc', 'modern_renderer.cc',
dependencies: [audacious_dep, math_dep, gtk_dep, opengl_dep, x11_dep,
epoxy_dep, glm_dep],
name_prefix: '',
install: true,
install_dir: visualization_plugin_dir
Expand Down
Loading