From 3dfc8c249ed7a0de413d99f3dc7112e5f8263542 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 18 Nov 2012 00:34:25 +0200 Subject: [PATCH] Make Listener a singleton instead of all-static --- source/listener.cpp | 6 ++++++ source/listener.h | 17 +++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/source/listener.cpp b/source/listener.cpp index cd43e46..74c50c9 100644 --- a/source/listener.cpp +++ b/source/listener.cpp @@ -3,6 +3,12 @@ namespace Msp { namespace AL { +Listener &Listener::instance() +{ + static Listener listener; + return listener; +} + void Listener::attribute(ALenum attr, float v) { alListenerf(attr, v); diff --git a/source/listener.h b/source/listener.h index 63f6ccf..98e1638 100644 --- a/source/listener.h +++ b/source/listener.h @@ -7,19 +7,20 @@ namespace Msp { namespace AL { /** -Represents the listener in the 3D environment. There is only one listener in -OpenAL - this class is not instantiable and all of its functions are static. +Represents the listener in the 3D environment. This class is a singleton. */ class Listener { private: - Listener(); + Listener() { } public: - static void attribute(ALenum, float); - static void attribute(ALenum, float, float, float); - static void attribute(ALenum, const float *); - static void set_position(float, float, float); - static void set_gain(float); + static Listener &instance(); + + void attribute(ALenum, float); + void attribute(ALenum, float, float, float); + void attribute(ALenum, const float *); + void set_position(float, float, float); + void set_gain(float); }; } // namespace AL -- 2.45.2