Procházet zdrojové kódy

Added method to remove loaded sound

Thomas Buck před 10 roky
rodič
revize
b3f067cf83
2 změnil soubory, kde provedl 18 přidání a 0 odebrání
  1. 6
    0
      include/Sound.h
  2. 12
    0
      src/Sound.cpp

+ 6
- 0
include/Sound.h Zobrazit soubor

76
     int addWave(unsigned char *wav, unsigned int length, int *source, unsigned int flags);
76
     int addWave(unsigned char *wav, unsigned int length, int *source, unsigned int flags);
77
 
77
 
78
     /*!
78
     /*!
79
+     * \brief Remove a loaded sound
80
+     * \param source valid source id
81
+     */
82
+    void remove(int source);
83
+
84
+    /*!
79
      * \brief Play sound source
85
      * \brief Play sound source
80
      * \param source sound source to play
86
      * \param source sound source to play
81
      */
87
      */

+ 12
- 0
src/Sound.cpp Zobrazit soubor

229
 }
229
 }
230
 
230
 
231
 
231
 
232
+void Sound::remove(int source) {
233
+    assert(source >= 0);
234
+    assert(source < mNext);
235
+
236
+    alDeleteSources(1, &mSource[source]);
237
+    alDeleteBuffers(1, &mBuffer[source]);
238
+
239
+    if (source == (mNext - 1))
240
+        mNext--;
241
+}
242
+
243
+
232
 void Sound::play(int source)
244
 void Sound::play(int source)
233
 {
245
 {
234
     assert(mInit == true);
246
     assert(mInit == true);

Loading…
Zrušit
Uložit