From: Brian M. <ma...@us...> - 2002-08-29 01:11:49
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal/test In directory usw-pr-cvs1:/tmp/cvs-serv7699 Modified Files: ALTest.java ALUTTest.java PlayTest.java Log Message: fix: now using ByteBuffer all the way Index: ALTest.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/openal/test/ALTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal/test/ALTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ALTest.java 28 Aug 2002 14:17:06 -0000 1.2 +++ ALTest.java 29 Aug 2002 01:11:46 -0000 1.3 @@ -57,7 +57,7 @@ public static final int NUM_BUFFERS = 7; /** buffers used */ - protected int[] buffers = new int[NUM_BUFFERS]; + protected ByteBuffer buffers; /** enumerations string */ protected String[] enumerationString = new String[]{ @@ -216,6 +216,9 @@ */ public ALTest() { [...1438 lines suppressed...] displayALError("alSourcePlay : ", error); @@ -1917,7 +2263,7 @@ } break; case '2': - al.sourceStopv(numSources, Sources); + al.sourceStopv(numSources, Sys.getDirectBufferAddress(Sources)); if ((error = al.getError()) != AL.NO_ERROR) displayALError("alSourceStopv : ", error); break; @@ -1925,7 +2271,7 @@ } while (ch != 'Q'); // Delete the Sources - al.deleteSources(numSources, Sources); + al.deleteSources(numSources, Sys.getDirectBufferAddress(Sources)); } /** Index: ALUTTest.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/openal/test/ALUTTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal/test/ALUTTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ALUTTest.java 27 Aug 2002 23:30:21 -0000 1.1 +++ ALUTTest.java 29 Aug 2002 01:11:46 -0000 1.2 @@ -31,15 +31,13 @@ */ package org.lwjgl.openal.test; +import org.lwjgl.Sys; import org.lwjgl.openal.AL; -import org.lwjgl.openal.ALC; -import org.lwjgl.openal.ALCcontext; -import org.lwjgl.openal.ALCdevice; -import org.lwjgl.openal.ALUT; import org.lwjgl.openal.ALUTLoadWAVData; -import java.io.*; -import java.net.*; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + /** * $Id$ * @@ -73,16 +71,19 @@ alut.init(args); //create 1 buffer and 1 source - int[] buffers = new int[1]; - int[] sources = new int[1]; + ByteBuffer buffers = ByteBuffer.allocateDirect(4); + buffers.order(ByteOrder.nativeOrder()); + + ByteBuffer sources = ByteBuffer.allocateDirect(4); + sources.order(ByteOrder.nativeOrder()); // al generate buffers and sources - al.genBuffers(1, buffers); + al.genBuffers(1, Sys.getDirectBufferAddress(buffers)); if((lastError = al.getError()) != AL.NO_ERROR) { exit(lastError); } - al.genSources(1, sources); + al.genSources(1, Sys.getDirectBufferAddress(sources)); if((lastError = al.getError()) != AL.NO_ERROR) { exit(lastError); } @@ -95,7 +96,7 @@ //copy to buffers - al.bufferData(buffers[0], file.format, file.data, file.size, file.freq); + al.bufferData(buffers.getInt(0), file.format, file.data, file.size, file.freq); if((lastError = al.getError()) != AL.NO_ERROR) { exit(lastError); } @@ -107,19 +108,19 @@ } //set up source input - al.sourcei(sources[0], AL.BUFFER, buffers[0]); + al.sourcei(sources.getInt(0), AL.BUFFER, buffers.getInt(0)); if((lastError = al.getError()) != AL.NO_ERROR) { exit(lastError); } //lets loop the sound - al.sourcei(sources[0], AL.LOOPING, AL.TRUE); + al.sourcei(sources.getInt(0), AL.LOOPING, AL.TRUE); if((lastError = al.getError()) != AL.NO_ERROR) { exit(lastError); } //play source 0 - al.sourcePlay(sources[0]); + al.sourcePlay(sources.getInt(0)); if((lastError = al.getError()) != AL.NO_ERROR) { exit(lastError); } @@ -132,18 +133,18 @@ } //stop source 0 - al.sourceStop(sources[0]); + al.sourceStop(sources.getInt(0)); if((lastError = al.getError()) != AL.NO_ERROR) { exit(lastError); } //delete buffers and sources - al.deleteSources(1, sources); + al.deleteSources(1, Sys.getDirectBufferAddress(sources)); if((lastError = al.getError()) != AL.NO_ERROR) { exit(lastError); } - al.deleteBuffers(1, buffers); + al.deleteBuffers(1, Sys.getDirectBufferAddress(buffers)); if((lastError = al.getError()) != AL.NO_ERROR) { exit(lastError); } Index: PlayTest.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/openal/test/PlayTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/openal/test/PlayTest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- PlayTest.java 28 Aug 2002 22:31:15 -0000 1.6 +++ PlayTest.java 29 Aug 2002 01:11:46 -0000 1.7 @@ -31,13 +31,13 @@ */ package org.lwjgl.openal.test; +import org.lwjgl.Sys; import org.lwjgl.openal.AL; -import org.lwjgl.openal.ALC; -import org.lwjgl.openal.ALCcontext; -import org.lwjgl.openal.ALCdevice; -import org.lwjgl.openal.ALUT; import org.lwjgl.openal.ALUTLoadWAVData; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + /** * $Id$ * @@ -71,16 +71,19 @@ alInitialize(); //create 1 buffer and 1 source - int[] buffers = new int[1]; - int[] sources = new int[1]; + ByteBuffer buffers = ByteBuffer.allocateDirect(4); + buffers.order(ByteOrder.nativeOrder()); + + ByteBuffer sources = ByteBuffer.allocateDirect(4); + sources.order(ByteOrder.nativeOrder()); // al generate buffers and sources - al.genBuffers(1, buffers); + al.genBuffers(1, Sys.getDirectBufferAddress(buffers)); if((lastError = al.getError()) != AL.NO_ERROR) { exit(lastError); } - al.genSources(1, sources); + al.genSources(1, Sys.getDirectBufferAddress(sources)); if((lastError = al.getError()) != AL.NO_ERROR) { exit(lastError); } @@ -93,7 +96,7 @@ //copy to buffers - al.bufferData(buffers[0], file.format, file.data, file.size, file.freq); + al.bufferData(buffers.getInt(0), file.format, file.data, file.size, file.freq); if((lastError = al.getError()) != AL.NO_ERROR) { exit(lastError); } @@ -105,19 +108,19 @@ } //set up source input - al.sourcei(sources[0], AL.BUFFER, buffers[0]); + al.sourcei(sources.getInt(0), AL.BUFFER, buffers.getInt(0)); if((lastError = al.getError()) != AL.NO_ERROR) { exit(lastError); } //lets loop the sound - al.sourcei(sources[0], AL.LOOPING, AL.TRUE); + al.sourcei(sources.getInt(0), AL.LOOPING, AL.TRUE); if((lastError = al.getError()) != AL.NO_ERROR) { exit(lastError); } //play source 0 - al.sourcePlay(sources[0]); + al.sourcePlay(sources.getInt(0)); if((lastError = al.getError()) != AL.NO_ERROR) { exit(lastError); } @@ -130,18 +133,18 @@ } //stop source 0 - al.sourceStop(sources[0]); + al.sourceStop(sources.getInt(0)); if((lastError = al.getError()) != AL.NO_ERROR) { exit(lastError); } //delete buffers and sources - al.deleteSources(1, sources); + al.deleteSources(1, Sys.getDirectBufferAddress(sources)); if((lastError = al.getError()) != AL.NO_ERROR) { exit(lastError); } - al.deleteBuffers(1, buffers); + al.deleteBuffers(1, Sys.getDirectBufferAddress(buffers)); if((lastError = al.getError()) != AL.NO_ERROR) { exit(lastError); } @@ -155,7 +158,7 @@ /** * main entry point - * + *+ * @param args String array containing arguments */ public static void main(String[] args) { |