minor updates

This commit is contained in:
Brian Matzon 2004-07-22 14:27:07 +00:00
parent 30d3ea27fe
commit 760bb65d5a
9 changed files with 50 additions and 47 deletions

View File

@ -33,6 +33,7 @@ package org.lwjgl.test.openal;
import java.nio.IntBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.openal.ALC;
/**
@ -60,7 +61,7 @@ public class ALCTest extends BasicTest {
int lastError = ALC.ALC_NO_ERROR;
//create attribute list for context creation
IntBuffer buffer = createIntBuffer(7);
IntBuffer buffer = BufferUtils.createIntBuffer(7);
if ((lastError = ALC.alcGetError()) != ALC.ALC_NO_ERROR) {
System.out.println("ALC Error: " + ALC.alcGetString(lastError));

View File

@ -31,13 +31,12 @@
*/
package org.lwjgl.test.openal;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.openal.AL;
import org.lwjgl.openal.AL10;
import org.lwjgl.opengl.DisplayMode;
/**
* $Id$
@ -69,34 +68,6 @@ public abstract class BasicTest {
AL.destroy();
}
}
/**
* 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
@ -106,7 +77,7 @@ public abstract class BasicTest {
* @return created FloatBuffer
*/
protected FloatBuffer createFloatBuffer(float[] data) {
FloatBuffer temp = createFloatBuffer(data.length).put(data);
FloatBuffer temp = BufferUtils.createFloatBuffer(data.length).put(data);
temp.flip();
return temp;
}
@ -133,4 +104,26 @@ public abstract class BasicTest {
alExit();
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;
}
}

View File

@ -36,6 +36,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.IntBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.Sys;
import org.lwjgl.openal.AL;
import org.lwjgl.openal.AL10;
@ -55,10 +56,10 @@ import org.lwjgl.openal.eax.EAXListenerProperties;
public class EAXTest extends BasicTest {
/** OpenAL buffers */
private IntBuffer soundBuffers = createIntBuffer(1);
private IntBuffer soundBuffers = BufferUtils.createIntBuffer(1);
/** OpenAL sources */
private IntBuffer soundSources = createIntBuffer(1);
private IntBuffer soundSources = BufferUtils.createIntBuffer(1);
/** Listener EAX property object */
private EAXListenerProperties listenerProperties;

View File

@ -33,6 +33,7 @@ package org.lwjgl.test.openal;
import java.nio.IntBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.input.Keyboard;
import org.lwjgl.openal.AL10;
import org.lwjgl.openal.eax.EAX;
@ -71,6 +72,7 @@ public class MovingSoundTest extends BasicTest {
}
try {
setDisplayMode();
Display.create();
} catch (Exception e) {
e.printStackTrace();
@ -92,8 +94,8 @@ public class MovingSoundTest extends BasicTest {
}
//create 1 buffer and 1 source
IntBuffer buffers = createIntBuffer(1);
IntBuffer sources = createIntBuffer(1);
IntBuffer buffers = BufferUtils.createIntBuffer(1);
IntBuffer sources = BufferUtils.createIntBuffer(1);
// al generate buffers and sources
buffers.position(0).limit(1);

View File

@ -37,6 +37,7 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.IntBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.openal.AL10;
/**
@ -83,8 +84,8 @@ public class PlayTest extends BasicTest {
int lastError;
//create 1 buffer and 1 source
IntBuffer buffers = createIntBuffer(1);
IntBuffer sources = createIntBuffer(1);
IntBuffer buffers = BufferUtils.createIntBuffer(1);
IntBuffer sources = BufferUtils.createIntBuffer(1);
// al generate buffers and sources
buffers.position(0).limit(1);

View File

@ -37,6 +37,7 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.IntBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.openal.AL10;
/**
@ -83,8 +84,8 @@ public class PlayTestMemory extends BasicTest {
int lastError;
//create 1 buffer and 1 source
IntBuffer buffers = createIntBuffer(1);
IntBuffer sources = createIntBuffer(1);
IntBuffer buffers = BufferUtils.createIntBuffer(1);
IntBuffer sources = BufferUtils.createIntBuffer(1);
// al generate buffers and sources
buffers.position(0).limit(1);

View File

@ -34,6 +34,7 @@ package org.lwjgl.test.openal;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.Sys;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
@ -82,10 +83,10 @@ public class PositionTest extends BasicTest {
// ===================================================
/** OpenAL buffers */
private IntBuffer soundBuffers = createIntBuffer(3);
private IntBuffer soundBuffers = BufferUtils.createIntBuffer(3);
/** OpenAL sources */
private IntBuffer soundSources = createIntBuffer(3);
private IntBuffer soundSources = BufferUtils.createIntBuffer(3);
/** Position of listener */
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;
// setup window
setDisplayMode();
Display.create();
// -----------------------------------------------------

View File

@ -33,6 +33,7 @@ package org.lwjgl.test.openal;
import java.nio.IntBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.openal.AL10;
import org.lwjgl.openal.OpenALException;
@ -93,7 +94,7 @@ public class SourceLimitTest extends BasicTest {
int lastError;
//make bytbuffer that can hold sourcesToCreate sources
IntBuffer sources = createIntBuffer(sourcesToCreate);
IntBuffer sources = BufferUtils.createIntBuffer(sourcesToCreate);
//Create sourcesToCreate sources in one fell swoop
sources.position(0).limit(sourcesToCreate);
@ -122,7 +123,7 @@ public class SourceLimitTest extends BasicTest {
//create the sources
for (int i = 0; i <= sourcesToCreate; i++) {
sources[i] = createIntBuffer(1);
sources[i] = BufferUtils.createIntBuffer(1);
sources[i].position(0).limit(1);
AL10.alGenSources(sources[i]);
if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {

View File

@ -33,6 +33,7 @@ package org.lwjgl.test.openal;
import java.nio.IntBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.openal.AL10;
/**
@ -79,7 +80,7 @@ public class StressTest extends BasicTest {
}
private void createSources() {
sources = createIntBuffer(4);
sources = BufferUtils.createIntBuffer(4);
sources.position(0).limit(4);
AL10.alGenSources(sources);
if (AL10.alGetError() != AL10.AL_NO_ERROR) {
@ -89,7 +90,7 @@ public class StressTest extends BasicTest {
}
private void createBuffers() {
buffers = createIntBuffer(10);
buffers = BufferUtils.createIntBuffer(10);
buffers.position(0).limit(10);
AL10.alGenBuffers(buffers);
if (AL10.alGetError() != AL10.AL_NO_ERROR) {