Kaynağa Gözat

fix non-spatialized mono (#219)

Mathieu Capdegelle 8 yıl önce
ebeveyn
işleme
5a6e97fb7d
2 değiştirilmiş dosya ile 7 ekleme ve 0 silme
  1. 5 0
      hxd/snd/Driver.hx
  2. 2 0
      hxd/snd/effect/Spatialization.hx

+ 5 - 0
hxd/snd/Driver.hx

@@ -119,6 +119,7 @@ class Driver {
 		var bytes = haxe.io.Bytes.alloc(4 * AL_NUM_SOURCES);
 		AL.genSources(AL_NUM_SOURCES, bytes);
 		sources = [for (i in 0...AL_NUM_SOURCES) new Source(ALSource.ofInt(bytes.getInt32(i * 4)))];
+		for (s in sources) AL.sourcei(s.inst, AL.SOURCE_RELATIVE, AL.TRUE);
 
 		cachedBytes = haxe.io.Bytes.alloc(4 * 3 * 2);
 	}
@@ -420,6 +421,10 @@ class Driver {
 			s.playing = false;
 			AL.sourceStop(s.inst);
 		}
+		AL.sourcei(s.inst,  AL.SOURCE_RELATIVE, AL.TRUE);
+		AL.source3f(s.inst, AL.POSITION,  0, 0, 0);
+		AL.source3f(s.inst, AL.VELOCITY,  0, 0, 0);
+		AL.source3f(s.inst, AL.DIRECTION, 0, 0, 0);
 		syncBuffers(s, null);
 	}
 

+ 2 - 0
hxd/snd/effect/Spatialization.hx

@@ -37,6 +37,8 @@ class Spatialization extends Effect {
 
 	#if hlsdl
 	override function apply(channel : Channel, s : Driver.Source) {
+		AL.sourcei(s.inst,  AL.SOURCE_RELATIVE, AL.FALSE);
+
 		AL.source3f(s.inst, AL.POSITION,  position.x,  position.y,  position.z);
 		AL.source3f(s.inst, AL.VELOCITY,  velocity.x,  velocity.y,  velocity.z);
 		AL.source3f(s.inst, AL.DIRECTION, direction.x, direction.y, direction.z);