|
From: Brian M. <ma...@us...> - 2005-05-12 15:44:32
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/openal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29994/src/java/org/lwjgl/test/openal Modified Files: SourceLimitTest.java Log Message: updated test to expect exceptions Index: SourceLimitTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/openal/SourceLimitTest.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- SourceLimitTest.java 8 Dec 2004 21:02:50 -0000 1.14 +++ SourceLimitTest.java 12 May 2005 15:44:22 -0000 1.15 @@ -99,18 +99,18 @@ IntBuffer sources = BufferUtils.createIntBuffer(sourcesToCreate); //Create sourcesToCreate sources in one fell swoop - sources.position(0).limit(sourcesToCreate); - AL10.alGenSources(sources); - if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { - System.out.println("failed to create " + sourcesToCreate + " sources (" + AL10.alGetString(lastError) + ")"); - return; - } - - //delete sources - sources.position(0).limit(sourcesToCreate); - AL10.alDeleteSources(sources); + try { + sources.position(0).limit(sourcesToCreate); + AL10.alGenSources(sources); + + //delete sources + sources.position(0).limit(sourcesToCreate); + AL10.alDeleteSources(sources); - System.out.println("created " + sourcesToCreate + " sources successfully!"); + System.out.println("created " + sourcesToCreate + " sources successfully!"); + } catch (OpenALException oale) { + System.out.println("Unable to create " + sourcesToCreate + " sources"); + } } /** @@ -123,34 +123,33 @@ //make bytbuffer that can hold sourcesToCreate sources IntBuffer[] sources = new IntBuffer[sourcesToCreate]; - //create the sources - for (int i = 0; i < sourcesToCreate; i++) { - sources[i] = BufferUtils.createIntBuffer(1); - sources[i].position(0).limit(1); - AL10.alGenSources(sources[i]); - if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { - System.out.println("failed to create source: " + (i + 1)); - break; + //create the sources + try { + for (int i = 0; i < sourcesToCreate; i++) { + sources[i] = BufferUtils.createIntBuffer(1); + sources[i].position(0).limit(1); + AL10.alGenSources(sources[i]); + if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { + break; + } + sourcesCreated++; } - sourcesCreated++; + } catch (OpenALException oale) { + System.out.println("failed to create source: " + (sourcesCreated + 1)); } - //delete allocated sources + //delete allocated sources for (int i = 0; i < sourcesCreated; i++) { //delete buffers and sources - sources[i].position(0).limit(1); + sources[i].position(0).limit(1); AL10.alDeleteSources(sources[i]); - if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { - System.out.println("failed to delete source: " + i + "(" + AL10.alGetString(lastError) + ")"); - break; - } } - if(sourcesCreated != sourcesToCreate) { - System.out.println("created " + sourcesCreated + " sources before failing"); - } else { - System.out.println("created " + sourcesCreated + " sources successfully!"); - } + if(sourcesCreated != sourcesToCreate) { + System.out.println("created " + sourcesCreated + " sources before failing"); + } else { + System.out.println("created " + sourcesCreated + " sources successfully!"); + } } /** |