minor updates
This commit is contained in:
parent
30d3ea27fe
commit
760bb65d5a
|
@ -33,6 +33,7 @@ package org.lwjgl.test.openal;
|
||||||
|
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
|
|
||||||
|
import org.lwjgl.BufferUtils;
|
||||||
import org.lwjgl.openal.ALC;
|
import org.lwjgl.openal.ALC;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,7 +61,7 @@ public class ALCTest extends BasicTest {
|
||||||
int lastError = ALC.ALC_NO_ERROR;
|
int lastError = ALC.ALC_NO_ERROR;
|
||||||
|
|
||||||
//create attribute list for context creation
|
//create attribute list for context creation
|
||||||
IntBuffer buffer = createIntBuffer(7);
|
IntBuffer buffer = BufferUtils.createIntBuffer(7);
|
||||||
|
|
||||||
if ((lastError = ALC.alcGetError()) != ALC.ALC_NO_ERROR) {
|
if ((lastError = ALC.alcGetError()) != ALC.ALC_NO_ERROR) {
|
||||||
System.out.println("ALC Error: " + ALC.alcGetString(lastError));
|
System.out.println("ALC Error: " + ALC.alcGetString(lastError));
|
||||||
|
|
|
@ -31,13 +31,12 @@
|
||||||
*/
|
*/
|
||||||
package org.lwjgl.test.openal;
|
package org.lwjgl.test.openal;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.nio.ByteOrder;
|
|
||||||
import java.nio.FloatBuffer;
|
import java.nio.FloatBuffer;
|
||||||
import java.nio.IntBuffer;
|
|
||||||
|
|
||||||
|
import org.lwjgl.BufferUtils;
|
||||||
import org.lwjgl.openal.AL;
|
import org.lwjgl.openal.AL;
|
||||||
import org.lwjgl.openal.AL10;
|
import org.lwjgl.openal.AL10;
|
||||||
|
import org.lwjgl.opengl.DisplayMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $Id$
|
* $Id$
|
||||||
|
@ -70,34 +69,6 @@ public abstract class BasicTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an integer buffer to hold specified ints
|
|
||||||
* - strictly a utility method
|
|
||||||
*
|
|
||||||
* @param size how many int to contain
|
|
||||||
* @return created IntBuffer
|
|
||||||
*/
|
|
||||||
protected IntBuffer createIntBuffer(int size) {
|
|
||||||
ByteBuffer temp = ByteBuffer.allocateDirect(4 * size);
|
|
||||||
temp.order(ByteOrder.nativeOrder());
|
|
||||||
|
|
||||||
return temp.asIntBuffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a float buffer to hold specified floats
|
|
||||||
* - strictly a utility method
|
|
||||||
*
|
|
||||||
* @param size how many floats to contain
|
|
||||||
* @return created FloatBuffer
|
|
||||||
*/
|
|
||||||
protected FloatBuffer createFloatBuffer(int size) {
|
|
||||||
ByteBuffer temp = ByteBuffer.allocateDirect(4 * size);
|
|
||||||
temp.order(ByteOrder.nativeOrder());
|
|
||||||
|
|
||||||
return temp.asFloatBuffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a float buffer to hold specified float array
|
* Creates a float buffer to hold specified float array
|
||||||
* - strictly a utility method
|
* - strictly a utility method
|
||||||
|
@ -106,7 +77,7 @@ public abstract class BasicTest {
|
||||||
* @return created FloatBuffer
|
* @return created FloatBuffer
|
||||||
*/
|
*/
|
||||||
protected FloatBuffer createFloatBuffer(float[] data) {
|
protected FloatBuffer createFloatBuffer(float[] data) {
|
||||||
FloatBuffer temp = createFloatBuffer(data.length).put(data);
|
FloatBuffer temp = BufferUtils.createFloatBuffer(data.length).put(data);
|
||||||
temp.flip();
|
temp.flip();
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
@ -133,4 +104,26 @@ public abstract class BasicTest {
|
||||||
alExit();
|
alExit();
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the display mode for fullscreen mode
|
||||||
|
*/
|
||||||
|
protected boolean setDisplayMode() {
|
||||||
|
// get modes
|
||||||
|
DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, 60, 60);
|
||||||
|
|
||||||
|
try {
|
||||||
|
org.lwjgl.util.Display.setDisplayMode(dm, new String[] {
|
||||||
|
"width=" + 640,
|
||||||
|
"height=" + 480,
|
||||||
|
"freq=" + 60,
|
||||||
|
"bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel()
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
|
|
||||||
|
import org.lwjgl.BufferUtils;
|
||||||
import org.lwjgl.Sys;
|
import org.lwjgl.Sys;
|
||||||
import org.lwjgl.openal.AL;
|
import org.lwjgl.openal.AL;
|
||||||
import org.lwjgl.openal.AL10;
|
import org.lwjgl.openal.AL10;
|
||||||
|
@ -55,10 +56,10 @@ import org.lwjgl.openal.eax.EAXListenerProperties;
|
||||||
public class EAXTest extends BasicTest {
|
public class EAXTest extends BasicTest {
|
||||||
|
|
||||||
/** OpenAL buffers */
|
/** OpenAL buffers */
|
||||||
private IntBuffer soundBuffers = createIntBuffer(1);
|
private IntBuffer soundBuffers = BufferUtils.createIntBuffer(1);
|
||||||
|
|
||||||
/** OpenAL sources */
|
/** OpenAL sources */
|
||||||
private IntBuffer soundSources = createIntBuffer(1);
|
private IntBuffer soundSources = BufferUtils.createIntBuffer(1);
|
||||||
|
|
||||||
/** Listener EAX property object */
|
/** Listener EAX property object */
|
||||||
private EAXListenerProperties listenerProperties;
|
private EAXListenerProperties listenerProperties;
|
||||||
|
|
|
@ -33,6 +33,7 @@ package org.lwjgl.test.openal;
|
||||||
|
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
|
|
||||||
|
import org.lwjgl.BufferUtils;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
import org.lwjgl.openal.AL10;
|
import org.lwjgl.openal.AL10;
|
||||||
import org.lwjgl.openal.eax.EAX;
|
import org.lwjgl.openal.eax.EAX;
|
||||||
|
@ -71,6 +72,7 @@ public class MovingSoundTest extends BasicTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setDisplayMode();
|
||||||
Display.create();
|
Display.create();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -92,8 +94,8 @@ public class MovingSoundTest extends BasicTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
//create 1 buffer and 1 source
|
//create 1 buffer and 1 source
|
||||||
IntBuffer buffers = createIntBuffer(1);
|
IntBuffer buffers = BufferUtils.createIntBuffer(1);
|
||||||
IntBuffer sources = createIntBuffer(1);
|
IntBuffer sources = BufferUtils.createIntBuffer(1);
|
||||||
|
|
||||||
// al generate buffers and sources
|
// al generate buffers and sources
|
||||||
buffers.position(0).limit(1);
|
buffers.position(0).limit(1);
|
||||||
|
|
|
@ -37,6 +37,7 @@ import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
|
|
||||||
|
import org.lwjgl.BufferUtils;
|
||||||
import org.lwjgl.openal.AL10;
|
import org.lwjgl.openal.AL10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,8 +84,8 @@ public class PlayTest extends BasicTest {
|
||||||
int lastError;
|
int lastError;
|
||||||
|
|
||||||
//create 1 buffer and 1 source
|
//create 1 buffer and 1 source
|
||||||
IntBuffer buffers = createIntBuffer(1);
|
IntBuffer buffers = BufferUtils.createIntBuffer(1);
|
||||||
IntBuffer sources = createIntBuffer(1);
|
IntBuffer sources = BufferUtils.createIntBuffer(1);
|
||||||
|
|
||||||
// al generate buffers and sources
|
// al generate buffers and sources
|
||||||
buffers.position(0).limit(1);
|
buffers.position(0).limit(1);
|
||||||
|
|
|
@ -37,6 +37,7 @@ import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
|
|
||||||
|
import org.lwjgl.BufferUtils;
|
||||||
import org.lwjgl.openal.AL10;
|
import org.lwjgl.openal.AL10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,8 +84,8 @@ public class PlayTestMemory extends BasicTest {
|
||||||
int lastError;
|
int lastError;
|
||||||
|
|
||||||
//create 1 buffer and 1 source
|
//create 1 buffer and 1 source
|
||||||
IntBuffer buffers = createIntBuffer(1);
|
IntBuffer buffers = BufferUtils.createIntBuffer(1);
|
||||||
IntBuffer sources = createIntBuffer(1);
|
IntBuffer sources = BufferUtils.createIntBuffer(1);
|
||||||
|
|
||||||
// al generate buffers and sources
|
// al generate buffers and sources
|
||||||
buffers.position(0).limit(1);
|
buffers.position(0).limit(1);
|
||||||
|
|
|
@ -34,6 +34,7 @@ package org.lwjgl.test.openal;
|
||||||
import java.nio.FloatBuffer;
|
import java.nio.FloatBuffer;
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
|
|
||||||
|
import org.lwjgl.BufferUtils;
|
||||||
import org.lwjgl.Sys;
|
import org.lwjgl.Sys;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
import org.lwjgl.input.Mouse;
|
import org.lwjgl.input.Mouse;
|
||||||
|
@ -82,10 +83,10 @@ public class PositionTest extends BasicTest {
|
||||||
// ===================================================
|
// ===================================================
|
||||||
|
|
||||||
/** OpenAL buffers */
|
/** OpenAL buffers */
|
||||||
private IntBuffer soundBuffers = createIntBuffer(3);
|
private IntBuffer soundBuffers = BufferUtils.createIntBuffer(3);
|
||||||
|
|
||||||
/** OpenAL sources */
|
/** OpenAL sources */
|
||||||
private IntBuffer soundSources = createIntBuffer(3);
|
private IntBuffer soundSources = BufferUtils.createIntBuffer(3);
|
||||||
|
|
||||||
/** Position of listener */
|
/** Position of listener */
|
||||||
private FloatBuffer listenerPosition = createFloatBuffer(new float[] { 0.0f, 0.0f, 0.0f });
|
private FloatBuffer listenerPosition = createFloatBuffer(new float[] { 0.0f, 0.0f, 0.0f });
|
||||||
|
@ -150,6 +151,7 @@ public class PositionTest extends BasicTest {
|
||||||
int centerY = (Display.getDisplayMode().getHeight() - WINDOW_HEIGHT) / 2;
|
int centerY = (Display.getDisplayMode().getHeight() - WINDOW_HEIGHT) / 2;
|
||||||
|
|
||||||
// setup window
|
// setup window
|
||||||
|
setDisplayMode();
|
||||||
Display.create();
|
Display.create();
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ package org.lwjgl.test.openal;
|
||||||
|
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
|
|
||||||
|
import org.lwjgl.BufferUtils;
|
||||||
import org.lwjgl.openal.AL10;
|
import org.lwjgl.openal.AL10;
|
||||||
import org.lwjgl.openal.OpenALException;
|
import org.lwjgl.openal.OpenALException;
|
||||||
|
|
||||||
|
@ -93,7 +94,7 @@ public class SourceLimitTest extends BasicTest {
|
||||||
int lastError;
|
int lastError;
|
||||||
|
|
||||||
//make bytbuffer that can hold sourcesToCreate sources
|
//make bytbuffer that can hold sourcesToCreate sources
|
||||||
IntBuffer sources = createIntBuffer(sourcesToCreate);
|
IntBuffer sources = BufferUtils.createIntBuffer(sourcesToCreate);
|
||||||
|
|
||||||
//Create sourcesToCreate sources in one fell swoop
|
//Create sourcesToCreate sources in one fell swoop
|
||||||
sources.position(0).limit(sourcesToCreate);
|
sources.position(0).limit(sourcesToCreate);
|
||||||
|
@ -122,7 +123,7 @@ public class SourceLimitTest extends BasicTest {
|
||||||
|
|
||||||
//create the sources
|
//create the sources
|
||||||
for (int i = 0; i <= sourcesToCreate; i++) {
|
for (int i = 0; i <= sourcesToCreate; i++) {
|
||||||
sources[i] = createIntBuffer(1);
|
sources[i] = BufferUtils.createIntBuffer(1);
|
||||||
sources[i].position(0).limit(1);
|
sources[i].position(0).limit(1);
|
||||||
AL10.alGenSources(sources[i]);
|
AL10.alGenSources(sources[i]);
|
||||||
if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
|
||||||
|
|
|
@ -33,6 +33,7 @@ package org.lwjgl.test.openal;
|
||||||
|
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
|
|
||||||
|
import org.lwjgl.BufferUtils;
|
||||||
import org.lwjgl.openal.AL10;
|
import org.lwjgl.openal.AL10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,7 +80,7 @@ public class StressTest extends BasicTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createSources() {
|
private void createSources() {
|
||||||
sources = createIntBuffer(4);
|
sources = BufferUtils.createIntBuffer(4);
|
||||||
sources.position(0).limit(4);
|
sources.position(0).limit(4);
|
||||||
AL10.alGenSources(sources);
|
AL10.alGenSources(sources);
|
||||||
if (AL10.alGetError() != AL10.AL_NO_ERROR) {
|
if (AL10.alGetError() != AL10.AL_NO_ERROR) {
|
||||||
|
@ -89,7 +90,7 @@ public class StressTest extends BasicTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createBuffers() {
|
private void createBuffers() {
|
||||||
buffers = createIntBuffer(10);
|
buffers = BufferUtils.createIntBuffer(10);
|
||||||
buffers.position(0).limit(10);
|
buffers.position(0).limit(10);
|
||||||
AL10.alGenBuffers(buffers);
|
AL10.alGenBuffers(buffers);
|
||||||
if (AL10.alGetError() != AL10.AL_NO_ERROR) {
|
if (AL10.alGetError() != AL10.AL_NO_ERROR) {
|
||||||
|
|
Loading…
Reference in New Issue