aboutsummaryrefslogtreecommitdiffstats
path: root/unit_tests/src/OpenALTest.java
diff options
context:
space:
mode:
authorathomas <[email protected]>2003-06-07 00:24:00 +0000
committerathomas <[email protected]>2003-06-07 00:24:00 +0000
commit5f9e58c5b1a23119a63dfb1e76e73349858439db (patch)
tree15dd6447e3a3d51aa527a75d2640a20537c1adde /unit_tests/src/OpenALTest.java
parent52acaea03c9dd7512fcc17f4ce16d1e86f4512eb (diff)
Initial check-in of project files
git-svn-id: file:///home/mbien/NetBeansProjects/JOGAMP/joal-sync/git-svn/../svn-server-sync/joal/trunk@21 03bf7f67-59de-4072-a415-9a990d468a3f
Diffstat (limited to 'unit_tests/src/OpenALTest.java')
-rw-r--r--unit_tests/src/OpenALTest.java93
1 files changed, 93 insertions, 0 deletions
diff --git a/unit_tests/src/OpenALTest.java b/unit_tests/src/OpenALTest.java
new file mode 100644
index 0000000..6bd4978
--- /dev/null
+++ b/unit_tests/src/OpenALTest.java
@@ -0,0 +1,93 @@
+import java.nio.IntBuffer;
+
+import net.java.games.joal.AL;
+import net.java.games.joal.ALC;
+import net.java.games.joal.ALFactory;
+import net.java.games.joal.eax.EAX;
+import net.java.games.joal.eax.EAXFactory;
+import net.java.games.joal.util.BufferUtils;
+import net.java.games.joal.util.WAVData;
+import net.java.games.joal.util.WAVLoader;
+
+/**
+ * @author Athomas Goldberg
+ *
+ */
+public class OpenALTest {
+ public static void main(String[] args) {
+ ALFactory.initialize();
+
+ ALC alc = ALFactory.getALC();
+ ALC.Device device = alc.alcOpenDevice("DirectSound3D");
+ ALC.Context context = alc.alcCreateContext(device, null);
+ alc.alcMakeContextCurrent(context);
+ AL al = ALFactory.getAL();
+ boolean eaxPresent = al.alIsExtensionPresent("EAX2.0");
+ System.out.println("EAX present:" + eaxPresent);
+ EAX eax = EAXFactory.getEAX();
+
+ try {
+ int[] buffers = new int[1];
+ al.alGenBuffers(1, buffers);
+
+ WAVData wd = WAVLoader.loadFromFile("lewiscarroll.wav");
+ al.alBufferData(buffers[0], wd.format, wd.data, wd.size, wd.freq);
+
+ int[] sources = new int[1];
+ al.alGenSources(1, sources);
+ al.alSourcei(sources[0], AL.AL_BUFFER, buffers[0]);
+ System.out.println(
+ "Looping 1: "
+ + (al.alGetSourcei(sources[0], AL.AL_LOOPING) == AL.AL_TRUE));
+ int[] loopArray = new int[1];
+ al.alGetSourcei(sources[0], AL.AL_LOOPING, loopArray);
+ System.out.println("Looping 2: " + (loopArray[0] == AL.AL_TRUE));
+ int[] loopBuffer = new int[1];
+ al.alGetSourcei(sources[0], AL.AL_LOOPING, loopBuffer);
+ System.out.println("Looping 3: " + (loopBuffer[0] == AL.AL_TRUE));
+
+ if (eaxPresent) {
+ IntBuffer env = BufferUtils.newIntBuffer(1);
+ env.put(EAX.EAX_ENVIRONMENT_BATHROOM);
+ eax.setListenerProperty(
+ EAX.DSPROPERTY_EAXLISTENER_ENVIRONMENT,
+ env);
+ }
+
+ al.alSourcePlay(sources[0]);
+
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ }
+
+ al.alSource3f(sources[0], AL.AL_POSITION, 2f, 2f, 2f);
+
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ }
+
+ al.alListener3f(AL.AL_POSITION, 3f, 3f, 3f);
+
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ }
+
+ al.alSource3f(sources[0], AL.AL_POSITION, 0, 0, 0);
+
+ try {
+ Thread.sleep(10000);
+ } catch (InterruptedException e) {
+ }
+
+ al.alSourceStop(sources[0]);
+ al.alDeleteSources(1, sources);
+ alc.alcDestroyContext(context);
+ alc.alcCloseDevice(device);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}