parent
e854c27358
commit
828f61a3aa
|
@ -9,10 +9,9 @@ import org.lwjgl.opengl.*;
|
||||||
import org.lwjgl.input.*;
|
import org.lwjgl.input.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $Id$
|
* $Id$<br>This test
|
||||||
* <br>
|
* demonstrates OpenAL positioning Based on the example by Chad Armstrong
|
||||||
* This test demonstrates OpenAL positioning
|
* (http://www.edenwaith.com/products/pige/tutorials/openal.php)
|
||||||
* Based on the example by Chad Armstrong (http://www.edenwaith.com/products/pige/tutorials/openal.php)
|
|
||||||
*
|
*
|
||||||
* @author Brian Matzon <brian@matzon.dk>
|
* @author Brian Matzon <brian@matzon.dk>
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
|
@ -50,14 +49,14 @@ public class PositionTest extends BasicTest {
|
||||||
private IntBuffer soundSources = createIntBuffer(3);
|
private IntBuffer soundSources = createIntBuffer(3);
|
||||||
|
|
||||||
/** Position of listener */
|
/** Position of listener */
|
||||||
private FloatBuffer listenerPosition = createFloatBuffer(3).put(new float[] { 0.0f, 0.0f, 2.0f });
|
private FloatBuffer listenerPosition = createFloatBuffer(3).put(new float[] { 0.0f, 0.0f, 0.0f });
|
||||||
|
|
||||||
/** Velocity of listener */
|
/** Velocity of listener */
|
||||||
private FloatBuffer listenerVelocity = createFloatBuffer(3).put(new float[] { 0.0f, 0.0f, 0.0f });
|
private FloatBuffer listenerVelocity = createFloatBuffer(3).put(new float[] { 0.0f, 0.0f, 0.0f });
|
||||||
|
|
||||||
/** Orientation of listener */
|
/** Orientation of listener */
|
||||||
private FloatBuffer listenerOrientation =
|
private FloatBuffer listenerOrientation =
|
||||||
createFloatBuffer(6).put(new float[] { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f });
|
createFloatBuffer(6).put(new float[] { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f });
|
||||||
|
|
||||||
/** Position of left sound */
|
/** Position of left sound */
|
||||||
private FloatBuffer leftPosition = createFloatBuffer(3).put(new float[] { -2.0f, 0.0f, 0.0f });
|
private FloatBuffer leftPosition = createFloatBuffer(3).put(new float[] { -2.0f, 0.0f, 0.0f });
|
||||||
|
@ -197,7 +196,7 @@ public class PositionTest extends BasicTest {
|
||||||
AL.alSourcei(soundSources.get(RIGHT), AL.AL_BUFFER, soundBuffers.get(RIGHT));
|
AL.alSourcei(soundSources.get(RIGHT), AL.AL_BUFFER, soundBuffers.get(RIGHT));
|
||||||
AL.alSourcei(soundSources.get(RIGHT), AL.AL_LOOPING, AL.AL_TRUE);
|
AL.alSourcei(soundSources.get(RIGHT), AL.AL_LOOPING, AL.AL_TRUE);
|
||||||
|
|
||||||
Sys.log("Soundfiles loaded successfully, initializing OpenAL environment");
|
Sys.log("Soundfiles loaded successfully");
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
|
|
||||||
// Setup Keyboard
|
// Setup Keyboard
|
||||||
|
@ -212,13 +211,28 @@ public class PositionTest extends BasicTest {
|
||||||
* Runs the actual demonstration
|
* Runs the actual demonstration
|
||||||
*/
|
*/
|
||||||
private void run() {
|
private void run() {
|
||||||
|
boolean firstRun = true;
|
||||||
|
|
||||||
System.out.println("Press 1/4 (left), 2/5 (center) or 3/6 (right) to toggle sound");
|
System.out.println("Press 1/4 (left), 2/5 (center) or 3/6 (right) to toggle sound");
|
||||||
System.out.println("Press LEFT/RIGHT to move along x axis");
|
System.out.println("Press LEFT/RIGHT to move along x axis");
|
||||||
System.out.println("Press SHIFT and either LEFT/RIGHT to move along y axis");
|
System.out.println("Press SHIFT and either UP/DOWN to move along y axis");
|
||||||
System.out.println("Press UP/DOWN to move along z axis");
|
System.out.println("Press UP/DOWN to move along z axis");
|
||||||
System.out.println("Press ESC to exit demo");
|
System.out.println("Press ESC to exit demo");
|
||||||
|
|
||||||
|
Sys.log(
|
||||||
|
"Listener position: "
|
||||||
|
+ listenerPosition.get(0)
|
||||||
|
+ ", "
|
||||||
|
+ listenerPosition.get(1)
|
||||||
|
+ ", "
|
||||||
|
+ listenerPosition.get(2));
|
||||||
|
Sys.log(
|
||||||
|
"Left position: " + leftPosition.get(0) + ", " + leftPosition.get(1) + ", " + leftPosition.get(2));
|
||||||
|
Sys.log(
|
||||||
|
"Center position: " + centerPosition.get(0) + ", " + centerPosition.get(1) + ", " + centerPosition.get(2));
|
||||||
|
Sys.log(
|
||||||
|
"Right position: " + rightPosition.get(0) + ", " + rightPosition.get(1) + ", " + rightPosition.get(2));
|
||||||
|
|
||||||
while (!finished) {
|
while (!finished) {
|
||||||
// handle any input
|
// handle any input
|
||||||
handleInput();
|
handleInput();
|
||||||
|
@ -231,6 +245,19 @@ public class PositionTest extends BasicTest {
|
||||||
|
|
||||||
// paint the content and flip buffer
|
// paint the content and flip buffer
|
||||||
Window.paint();
|
Window.paint();
|
||||||
|
|
||||||
|
// start sound after first paint, since we don't want
|
||||||
|
// the delay before something is painted on the screen
|
||||||
|
if (firstRun) {
|
||||||
|
firstRun = false;
|
||||||
|
|
||||||
|
// start sounds with delays
|
||||||
|
AL.alSourcePlay(soundSources.get(LEFT));
|
||||||
|
pause(300);
|
||||||
|
AL.alSourcePlay(soundSources.get(CENTER));
|
||||||
|
pause(500);
|
||||||
|
AL.alSourcePlay(soundSources.get(RIGHT));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,7 +408,8 @@ public class PositionTest extends BasicTest {
|
||||||
/**
|
/**
|
||||||
* main entry point
|
* main entry point
|
||||||
*
|
*
|
||||||
* @param args String array containing arguments
|
* @param args
|
||||||
|
* String array containing arguments
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
PositionTest positionTest = new PositionTest();
|
PositionTest positionTest = new PositionTest();
|
||||||
|
@ -389,18 +417,16 @@ public class PositionTest extends BasicTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minute implementation of GLUT:
|
* Minute implementation of GLUT: <br>COPYRIGHT:
|
||||||
* <br>
|
|
||||||
* COPYRIGHT:
|
|
||||||
*
|
*
|
||||||
* The OpenGL Utility Toolkit distribution for Win32 (Windows NT &
|
* The OpenGL Utility Toolkit distribution for Win32 (Windows NT & Windows
|
||||||
* Windows 95) contains source code modified from the original source
|
* 95) contains source code modified from the original source code for GLUT
|
||||||
* code for GLUT version 3.3 which was developed by Mark J. Kilgard. The
|
* version 3.3 which was developed by Mark J. Kilgard. The original source
|
||||||
* original source code for GLUT is Copyright 1997 by Mark J. Kilgard.
|
* code for GLUT is Copyright 1997 by Mark J. Kilgard. GLUT for Win32 is
|
||||||
* GLUT for Win32 is Copyright 1997 by Nate Robins and is not in the
|
* Copyright 1997 by Nate Robins and is not in the public domain, but it is
|
||||||
* public domain, but it is freely distributable without licensing fees.
|
* freely distributable without licensing fees. It is provided without
|
||||||
* It is provided without guarantee or warrantee expressed or implied.
|
* guarantee or warrantee expressed or implied. It was ported with the
|
||||||
* It was ported with the permission of Mark J. Kilgard by Nate Robins.
|
* permission of Mark J. Kilgard by Nate Robins.
|
||||||
*
|
*
|
||||||
* THIS SOURCE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
|
* THIS SOURCE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||||
* EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
* EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
@ -425,7 +451,6 @@ public class PositionTest extends BasicTest {
|
||||||
};
|
};
|
||||||
float v[][] = new float[8][3];
|
float v[][] = new float[8][3];
|
||||||
|
|
||||||
|
|
||||||
public void glutWireCube(float size) {
|
public void glutWireCube(float size) {
|
||||||
drawBox(size, GL.GL_LINE_LOOP);
|
drawBox(size, GL.GL_LINE_LOOP);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue