add: last test added. ALCTest complete sans some stuff that doesn't work on win32 - awaiting fix from OpenAL people

This commit is contained in:
Brian Matzon 2002-08-27 23:21:03 +00:00
parent 32eccb5e58
commit 2d43fd17aa
1 changed files with 21 additions and 19 deletions

View File

@ -35,8 +35,10 @@ import org.lwjgl.openal.AL;
import org.lwjgl.openal.ALC; import org.lwjgl.openal.ALC;
import org.lwjgl.openal.ALCcontext; import org.lwjgl.openal.ALCcontext;
import org.lwjgl.openal.ALCdevice; import org.lwjgl.openal.ALCdevice;
import org.lwjgl.Sys;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder;
/** /**
* $Id$ * $Id$
* *
@ -69,17 +71,18 @@ public class ALCTest extends BasicTest {
} }
//create attribute list for context creation //create attribute list for context creation
ByteBuffer buffer = ByteBuffer.allocate(28); ByteBuffer buffer = ByteBuffer.allocateDirect(28);
buffer.order(ByteOrder.nativeOrder());
buffer.putInt(ALC.FREQUENCY); buffer.putInt(ALC.FREQUENCY);
buffer.putInt(44100); buffer.putInt(44100);
buffer.putInt(ALC.SYNC);
buffer.putInt(ALC.FALSE);
buffer.putInt(ALC.REFRESH); buffer.putInt(ALC.REFRESH);
buffer.putInt(15); buffer.putInt(15);
buffer.putInt(ALC.SYNC);
buffer.putInt(ALC.FALSE);
buffer.putInt(0); //terminating int buffer.putInt(0); //terminating int
//create a context //create a context, using above attributes
context = alc.createContext(device, org.lwjgl.Sys.getDirectBufferAddress(buffer)); context = alc.createContext(device, Sys.getDirectBufferAddress(buffer));
if(context == null) { if(context == null) {
System.out.println("Unable to create context"); System.out.println("Unable to create context");
System.exit(-1); System.exit(-1);
@ -94,31 +97,27 @@ public class ALCTest extends BasicTest {
alc.makeContextCurrent(context); alc.makeContextCurrent(context);
//process //process
//NOTE - weird bug exposed! alc.processContext(context);
//calling alcProcessContext on a non suspended context hangs
//this is a OpenAL specific bug - not our code
//alc.processContext(context);
//suspend //suspend
alc.suspendContext(context); alc.suspendContext(context);
//process again
alc.processContext(context);
//query //query
System.out.println("DEFAULT_DEVICE_SPECIFIER: " + alc.getString(device, ALC.DEFAULT_DEVICE_SPECIFIER)); System.out.println("DEFAULT_DEVICE_SPECIFIER: " + alc.getString(device, ALC.DEFAULT_DEVICE_SPECIFIER));
System.out.println("DEVICE_SPECIFIER: " + alc.getString(device, ALC.DEVICE_SPECIFIER)); System.out.println("DEVICE_SPECIFIER: " + alc.getString(device, ALC.DEVICE_SPECIFIER));
System.out.println("EXTENSIONS: " + alc.getString(device, ALC.EXTENSIONS)); System.out.println("EXTENSIONS: " + alc.getString(device, ALC.EXTENSIONS));
//mo query - hmmmmm don't get alcGetIntegerv //mo query
/*buffer.rewind(); buffer.rewind();
alc.getIntegerv(device, ALC.MAJOR_VERSION, 32, org.lwjgl.Sys.getDirectBufferAddress(buffer)); alc.getIntegerv(device, ALC.MAJOR_VERSION, 4, Sys.getDirectBufferAddress(buffer));
alc.getIntegerv(device, ALC.MINOR_VERSION, 4, Sys.getDirectBufferAddress(buffer)+4);
System.out.println("ALC_MAJOR_VERSION: " + buffer.getInt()); System.out.println("ALC_MAJOR_VERSION: " + buffer.getInt());
alc.getIntegerv(device, ALC.MINOR_VERSION, 4, org.lwjgl.Sys.getDirectBufferAddress(buffer));
System.out.println("ALC_MINOR_VERSION: " + buffer.getInt()); System.out.println("ALC_MINOR_VERSION: " + buffer.getInt());
*/
//no check for ALC_ALL_ATTRIBUTES / ALC_ATTRIBUTES_SIZE since it
//is buggy on win32 - my dev platform
//check current context //check current context
ALCcontext currentContext = alc.getCurrentContext(); ALCcontext currentContext = alc.getCurrentContext();
if(context.context != currentContext.context) { if(context.context != currentContext.context) {
@ -131,7 +130,10 @@ public class ALCTest extends BasicTest {
if(device.device != currentDevice.device) { if(device.device != currentDevice.device) {
System.out.println("Serious error! - device copy != current contexts device"); System.out.println("Serious error! - device copy != current contexts device");
System.exit(-1); System.exit(-1);
} }
//get an enumerstion value
System.out.println("Value of ALC_MAJOR_VERSION: " + alc.getEnumValue(device, "ALC_MAJOR_VERSION"));
//close context again //close context again
alc.destroyContext(context); alc.destroyContext(context);