- 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:
@@ -8,5 +8,6 @@
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="lib/lwjgl_util.jar"/>
|
||||
<classpathentry kind="lib" path="lib/flibitEFX.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
15
doc/license.flibitEFX
Normal file
15
doc/license.flibitEFX
Normal 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
BIN
lib/flibitEFX.jar
Normal file
Binary file not shown.
@@ -37,6 +37,8 @@ import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.lwjgl.openal.AL10;
|
||||
import org.lwjgl.openal.AL11;
|
||||
import org.lwjgl.openal.EFX10;
|
||||
|
||||
/**
|
||||
* Channel
|
||||
@@ -52,7 +54,7 @@ public class Channel {
|
||||
|
||||
private static Channel[] channels = new Channel[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 Map looptable = new Hashtable(MAX_CHANNELS);
|
||||
|
||||
@@ -289,7 +291,7 @@ public class Channel {
|
||||
//stack variable
|
||||
private static float[] entityOrigin = {0, 0, 0};
|
||||
|
||||
static void playAllSounds(FloatBuffer listenerOrigin) {
|
||||
static void playAllSounds(FloatBuffer listenerOrigin, int currentEffectIndex) {
|
||||
FloatBuffer sourceOrigin = sourceOriginBuffer;
|
||||
Channel ch;
|
||||
int sourceId;
|
||||
@@ -323,6 +325,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.alSourcePlay(sourceId);
|
||||
sourceOrigin.rewind();
|
||||
ch.modified = false;
|
||||
|
||||
@@ -21,6 +21,7 @@ package lwjake2.sound.lwjgl;
|
||||
import lwjake2.Defines;
|
||||
import lwjake2.Globals;
|
||||
import lwjake2.game.Cmd;
|
||||
import lwjake2.game.GameBase;
|
||||
import lwjake2.game.cvar_t;
|
||||
import lwjake2.game.entity_state_t;
|
||||
import lwjake2.qcommon.Com;
|
||||
@@ -41,17 +42,13 @@ import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
|
||||
import com.flibitijibibo.flibitEFX.EFXUnderwater;
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.openal.AL;
|
||||
import org.lwjgl.openal.AL10;
|
||||
import org.lwjgl.openal.ALC10;
|
||||
import org.lwjgl.openal.EFX10;
|
||||
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
|
||||
@@ -63,15 +60,16 @@ public final class LWJGLSoundImpl implements Sound {
|
||||
static {
|
||||
S.register(new LWJGLSoundImpl());
|
||||
};
|
||||
|
||||
// Replace with an EFX equivalent - flibit
|
||||
// private boolean hasEAX;
|
||||
|
||||
private cvar_t s_volume;
|
||||
|
||||
// the last 4 buffers are used for cinematics streaming
|
||||
private IntBuffer buffers = Lib.newIntBuffer(MAX_SFX + STREAM_QUEUE);
|
||||
|
||||
/** EFX Variables */
|
||||
private int currentEffectIndex;
|
||||
private EFXUnderwater underwaterEffect;
|
||||
|
||||
// singleton
|
||||
private LWJGLSoundImpl() {
|
||||
}
|
||||
@@ -84,7 +82,7 @@ public final class LWJGLSoundImpl implements Sound {
|
||||
try {
|
||||
initOpenAL();
|
||||
checkError();
|
||||
// initOpenALExtensions(); <- If possible, replace with EFX10 - flibit
|
||||
initOpenALExtensions();
|
||||
} catch (OpenALException e) {
|
||||
Com.Printf(e.getMessage() + '\n');
|
||||
return false;
|
||||
@@ -151,44 +149,18 @@ public final class LWJGLSoundImpl implements Sound {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
This is old EAX code. If possible, replace with EFX10 - flibit
|
||||
|
||||
private void initOpenALExtensions() throws OpenALException
|
||||
/** Initializes OpenAL EFX effects. */
|
||||
private void initOpenALExtensions()
|
||||
{
|
||||
if (AL10.alIsExtensionPresent("EAX2.0"))
|
||||
{
|
||||
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;
|
||||
}
|
||||
Com.Printf("... using EFX effects:\n");
|
||||
underwaterEffect = new EFXUnderwater();
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
void exitOpenAL()
|
||||
{
|
||||
/*
|
||||
|
||||
This is old EAX code. If possible, replace with EFX10 - flibit
|
||||
|
||||
// Release the EAX context.
|
||||
if (hasEAX){
|
||||
EAX.destroy();
|
||||
}
|
||||
*/
|
||||
// Unload EFX Effects
|
||||
underwaterEffect.killEffect();
|
||||
|
||||
// Release the context and the device.
|
||||
AL.destroy();
|
||||
@@ -287,40 +259,16 @@ public final class LWJGLSoundImpl implements Sound {
|
||||
// set the master volume
|
||||
AL10.alListenerf(AL10.AL_GAIN, s_volume.value);
|
||||
|
||||
/*
|
||||
|
||||
This is old EAX code. If possible, replace with EFX10 - flibit
|
||||
|
||||
if (hasEAX){
|
||||
if ((GameBase.gi.pointcontents.pointcontents(origin)& Defines.MASK_WATER)!= 0) {
|
||||
changeEnvironment(EAX20.EAX_ENVIRONMENT_UNDERWATER);
|
||||
} else {
|
||||
changeEnvironment(EAX20.EAX_ENVIRONMENT_GENERIC);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
// Detect EFX Conditions
|
||||
if ((GameBase.gi.pointcontents.pointcontents(origin)& Defines.MASK_WATER)!= 0)
|
||||
currentEffectIndex = underwaterEffect.getIndex();
|
||||
else
|
||||
currentEffectIndex = EFX10.AL_EFFECTSLOT_NULL;
|
||||
|
||||
Channel.addLoopSounds();
|
||||
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)
|
||||
* @see jake2.sound.SoundImpl#StopAllSounds()
|
||||
|
||||
Reference in New Issue
Block a user