0

- EFX is now in LWJake2.

- The underwater effect is placeholder, but it does what it does.
- Added flibitEFX.jar to the libraries.
	- This is a library derived from the flibit2D engine. It stores EFX
preset effects, which can be accessed with the getIndex() method.
This commit is contained in:
Ethan Lee
2012-02-02 01:02:51 -05:00
parent a8b51547a9
commit 94dabe3de5
5 changed files with 41 additions and 74 deletions

View File

@@ -8,5 +8,6 @@
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="lib" path="lib/lwjgl_util.jar"/> <classpathentry kind="lib" path="lib/lwjgl_util.jar"/>
<classpathentry kind="lib" path="lib/flibitEFX.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

15
doc/license.flibitEFX Normal file
View File

@@ -0,0 +1,15 @@
/*
* Copyright (C) 2011 Ethan "flibitijibibo" Lee
*
* flibitEFX is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* flibitEFX is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License
* along with flibitEFX. If not, see <http://www.gnu.org/licenses/>.
*/

BIN
lib/flibitEFX.jar Normal file

Binary file not shown.

View File

@@ -37,6 +37,8 @@ import java.util.Iterator;
import java.util.Map; import java.util.Map;
import org.lwjgl.openal.AL10; import org.lwjgl.openal.AL10;
import org.lwjgl.openal.AL11;
import org.lwjgl.openal.EFX10;
/** /**
* Channel * Channel
@@ -52,7 +54,7 @@ public class Channel {
private static Channel[] channels = new Channel[MAX_CHANNELS]; private static Channel[] channels = new Channel[MAX_CHANNELS];
private static IntBuffer sources = Lib.newIntBuffer(MAX_CHANNELS); private static IntBuffer sources = Lib.newIntBuffer(MAX_CHANNELS);
// a reference of L:WJGLSoundImpl.buffers // a reference of LWJGLSoundImpl.buffers
private static IntBuffer buffers; private static IntBuffer buffers;
private static Map looptable = new Hashtable(MAX_CHANNELS); private static Map looptable = new Hashtable(MAX_CHANNELS);
@@ -289,7 +291,7 @@ public class Channel {
//stack variable //stack variable
private static float[] entityOrigin = {0, 0, 0}; private static float[] entityOrigin = {0, 0, 0};
static void playAllSounds(FloatBuffer listenerOrigin) { static void playAllSounds(FloatBuffer listenerOrigin, int currentEffectIndex) {
FloatBuffer sourceOrigin = sourceOriginBuffer; FloatBuffer sourceOrigin = sourceOriginBuffer;
Channel ch; Channel ch;
int sourceId; int sourceId;
@@ -323,6 +325,7 @@ public class Channel {
} }
AL10.alSourcef (sourceId, AL10.AL_ROLLOFF_FACTOR, ch.rolloff); AL10.alSourcef (sourceId, AL10.AL_ROLLOFF_FACTOR, ch.rolloff);
AL10.alSource3f(sourceId, AL10.AL_POSITION, sourceOrigin.get(), sourceOrigin.get(), sourceOrigin.get()); 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.alSourcePlay(sourceId); AL10.alSourcePlay(sourceId);
sourceOrigin.rewind(); sourceOrigin.rewind();
ch.modified = false; ch.modified = false;

View File

@@ -21,6 +21,7 @@ package lwjake2.sound.lwjgl;
import lwjake2.Defines; import lwjake2.Defines;
import lwjake2.Globals; import lwjake2.Globals;
import lwjake2.game.Cmd; import lwjake2.game.Cmd;
import lwjake2.game.GameBase;
import lwjake2.game.cvar_t; import lwjake2.game.cvar_t;
import lwjake2.game.entity_state_t; import lwjake2.game.entity_state_t;
import lwjake2.qcommon.Com; import lwjake2.qcommon.Com;
@@ -41,17 +42,13 @@ import java.nio.FloatBuffer;
import java.nio.IntBuffer; import java.nio.IntBuffer;
import java.nio.ShortBuffer; import java.nio.ShortBuffer;
import com.flibitijibibo.flibitEFX.EFXUnderwater;
import org.lwjgl.LWJGLException; import org.lwjgl.LWJGLException;
import org.lwjgl.openal.AL; import org.lwjgl.openal.AL;
import org.lwjgl.openal.AL10; import org.lwjgl.openal.AL10;
import org.lwjgl.openal.ALC10; import org.lwjgl.openal.ALC10;
import org.lwjgl.openal.EFX10;
import org.lwjgl.openal.OpenALException; import org.lwjgl.openal.OpenALException;
/*
Old EAX Code. If possible, replace with EFX10 - flibit
import org.lwjgl.openal.eax.EAX;
import org.lwjgl.openal.eax.EAX20;
import org.lwjgl.openal.eax.EAXListenerProperties;
*/
/** /**
* LWJGLSoundImpl * LWJGLSoundImpl
@@ -64,14 +61,15 @@ public final class LWJGLSoundImpl implements Sound {
S.register(new LWJGLSoundImpl()); S.register(new LWJGLSoundImpl());
}; };
// Replace with an EFX equivalent - flibit
// private boolean hasEAX;
private cvar_t s_volume; private cvar_t s_volume;
// the last 4 buffers are used for cinematics streaming // the last 4 buffers are used for cinematics streaming
private IntBuffer buffers = Lib.newIntBuffer(MAX_SFX + STREAM_QUEUE); private IntBuffer buffers = Lib.newIntBuffer(MAX_SFX + STREAM_QUEUE);
/** EFX Variables */
private int currentEffectIndex;
private EFXUnderwater underwaterEffect;
// singleton // singleton
private LWJGLSoundImpl() { private LWJGLSoundImpl() {
} }
@@ -84,7 +82,7 @@ public final class LWJGLSoundImpl implements Sound {
try { try {
initOpenAL(); initOpenAL();
checkError(); checkError();
// initOpenALExtensions(); <- If possible, replace with EFX10 - flibit initOpenALExtensions();
} catch (OpenALException e) { } catch (OpenALException e) {
Com.Printf(e.getMessage() + '\n'); Com.Printf(e.getMessage() + '\n');
return false; return false;
@@ -151,44 +149,18 @@ public final class LWJGLSoundImpl implements Sound {
} }
} }
/* /** Initializes OpenAL EFX effects. */
private void initOpenALExtensions()
This is old EAX code. If possible, replace with EFX10 - flibit
private void initOpenALExtensions() throws OpenALException
{ {
if (AL10.alIsExtensionPresent("EAX2.0")) Com.Printf("... using EFX effects:\n");
{ underwaterEffect = new EFXUnderwater();
try {
EAX.create();
Com.Printf("... using EAX2.0\n");
hasEAX=true;
} catch (LWJGLException e) {
Com.Printf("... can't create EAX2.0\n");
hasEAX=false;
}
}
else
{
Com.Printf("... EAX2.0 not found\n");
hasEAX=false;
}
} }
*/
void exitOpenAL() void exitOpenAL()
{ {
/* // Unload EFX Effects
underwaterEffect.killEffect();
This is old EAX code. If possible, replace with EFX10 - flibit
// Release the EAX context.
if (hasEAX){
EAX.destroy();
}
*/
// Release the context and the device. // Release the context and the device.
AL.destroy(); AL.destroy();
@@ -287,41 +259,17 @@ public final class LWJGLSoundImpl implements Sound {
// set the master volume // set the master volume
AL10.alListenerf(AL10.AL_GAIN, s_volume.value); AL10.alListenerf(AL10.AL_GAIN, s_volume.value);
/* // Detect EFX Conditions
if ((GameBase.gi.pointcontents.pointcontents(origin)& Defines.MASK_WATER)!= 0)
This is old EAX code. If possible, replace with EFX10 - flibit currentEffectIndex = underwaterEffect.getIndex();
else
if (hasEAX){ currentEffectIndex = EFX10.AL_EFFECTSLOT_NULL;
if ((GameBase.gi.pointcontents.pointcontents(origin)& Defines.MASK_WATER)!= 0) {
changeEnvironment(EAX20.EAX_ENVIRONMENT_UNDERWATER);
} else {
changeEnvironment(EAX20.EAX_ENVIRONMENT_GENERIC);
}
}
*/
Channel.addLoopSounds(); Channel.addLoopSounds();
Channel.addPlaySounds(); Channel.addPlaySounds();
Channel.playAllSounds(listenerOrigin); Channel.playAllSounds(listenerOrigin, currentEffectIndex);
} }
/*
This is old EAX code. If possible, replace with EFX10 - flibit
private IntBuffer eaxEnv = Lib.newIntBuffer(1);
private int currentEnv = EAX20.EAX_ENVIRONMENT_UNDERWATER;
private void changeEnvironment(int env) {
if (env == currentEnv) return;
currentEnv = env;
eaxEnv.put(0, currentEnv);
EAX20.eaxSet(EAX20.LISTENER_GUID, EAXListenerProperties.EAXLISTENER_ENVIRONMENT | EAXListenerProperties.EAXLISTENER_DEFERRED, 0, eaxEnv, 4);
}
*/
/* (non-Javadoc) /* (non-Javadoc)
* @see jake2.sound.SoundImpl#StopAllSounds() * @see jake2.sound.SoundImpl#StopAllSounds()
*/ */