0

- The underwater effect is now... um... a decent one.

- Updated flibitEFX with an EFXFilter for underwater.
- Updated the LWJGL audio rendering to use EFX filters.
This commit is contained in:
Ethan Lee
2012-02-02 17:06:39 -05:00
parent e4d6da6dc2
commit 65bbba72bb
3 changed files with 14 additions and 4 deletions

Binary file not shown.

View File

@@ -291,7 +291,7 @@ public class Channel {
//stack variable
private static float[] entityOrigin = {0, 0, 0};
static void playAllSounds(FloatBuffer listenerOrigin, int currentEffectIndex) {
static void playAllSounds(FloatBuffer listenerOrigin, int currentEffectIndex, int currentFilterIndex) {
FloatBuffer sourceOrigin = sourceOriginBuffer;
Channel ch;
int sourceId;
@@ -326,6 +326,7 @@ public class Channel {
AL10.alSourcef (sourceId, AL10.AL_ROLLOFF_FACTOR, ch.rolloff);
AL10.alSource3f(sourceId, AL10.AL_POSITION, sourceOrigin.get(), sourceOrigin.get(), sourceOrigin.get());
AL11.alSource3i(sourceId, EFX10.AL_AUXILIARY_SEND_FILTER, currentEffectIndex, 0, EFX10.AL_FILTER_NULL);
AL10.alSourcei(sourceId, EFX10.AL_DIRECT_FILTER, currentFilterIndex);
AL10.alSourcePlay(sourceId);
sourceOrigin.rewind();
ch.modified = false;

View File

@@ -43,6 +43,7 @@ import java.nio.IntBuffer;
import java.nio.ShortBuffer;
import com.flibitijibibo.flibitEFX.EFXEffectUnderwater;
import com.flibitijibibo.flibitEFX.EFXFilterUnderwater;
import org.lwjgl.LWJGLException;
import org.lwjgl.openal.AL;
import org.lwjgl.openal.AL10;
@@ -68,7 +69,9 @@ public final class LWJGLSoundImpl implements Sound {
/** EFX Variables */
private int currentEffectIndex;
private int currentFilterIndex;
private EFXEffectUnderwater underwaterEffect;
private EFXFilterUnderwater underwaterFilter;
// singleton
private LWJGLSoundImpl() {
@@ -154,6 +157,7 @@ public final class LWJGLSoundImpl implements Sound {
{
Com.Printf("... using EFX effects:\n");
underwaterEffect = new EFXEffectUnderwater();
underwaterFilter = new EFXFilterUnderwater();
}
@@ -161,6 +165,7 @@ public final class LWJGLSoundImpl implements Sound {
{
// Unload EFX Effects
underwaterEffect.killEffect();
underwaterFilter.killFilter();
// Release the context and the device.
AL.destroy();
@@ -260,14 +265,18 @@ public final class LWJGLSoundImpl implements Sound {
AL10.alListenerf(AL10.AL_GAIN, s_volume.value);
// Detect EFX Conditions
if ((GameBase.gi.pointcontents.pointcontents(origin)& Defines.MASK_WATER)!= 0)
if ((GameBase.gi.pointcontents.pointcontents(origin)& Defines.MASK_WATER)!= 0) {
currentEffectIndex = underwaterEffect.getIndex();
else
currentFilterIndex = underwaterFilter.getIndex();
}
else {
currentEffectIndex = EFX10.AL_EFFECTSLOT_NULL;
currentFilterIndex = EFX10.AL_FILTER_NULL;
}
Channel.addLoopSounds();
Channel.addPlaySounds();
Channel.playAllSounds(listenerOrigin, currentEffectIndex);
Channel.playAllSounds(listenerOrigin, currentEffectIndex, currentFilterIndex);
}
/* (non-Javadoc)