mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-04-06 06:53:59 +00:00
static implementation - work in progress
This commit is contained in:
parent
315375dee5
commit
4c4d56e583
34 changed files with 2001 additions and 2008 deletions
|
|
@ -31,10 +31,7 @@
|
|||
*/
|
||||
package org.lwjgl.test.openal;
|
||||
|
||||
import org.lwjgl.Sys;
|
||||
|
||||
import org.lwjgl.openal.AL;
|
||||
import org.lwjgl.openal.ALC;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
|
@ -51,22 +48,15 @@ import java.nio.IntBuffer;
|
|||
*/
|
||||
public class OpenALCreationTest {
|
||||
|
||||
/** OpenAL instance */
|
||||
protected AL al;
|
||||
|
||||
/** OpenAL Context instance */
|
||||
protected ALC alc;
|
||||
|
||||
/**
|
||||
* Creates an instance of OpenALCreationTest
|
||||
*/
|
||||
public OpenALCreationTest() {
|
||||
al = new AL();
|
||||
}
|
||||
|
||||
public void alInitialize() {
|
||||
try {
|
||||
al.create();
|
||||
AL.create();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
|
|
@ -74,7 +64,7 @@ public class OpenALCreationTest {
|
|||
}
|
||||
|
||||
public void alExit() {
|
||||
al.destroy();
|
||||
AL.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -97,7 +87,7 @@ public class OpenALCreationTest {
|
|||
* @param error Error code causing exit
|
||||
*/
|
||||
protected void exit(int error) {
|
||||
System.out.println("OpenAL Error: " + al.getString(error));
|
||||
System.out.println("OpenAL Error: " + AL.alGetString(error));
|
||||
alExit();
|
||||
System.exit(-1);
|
||||
}
|
||||
|
|
@ -133,7 +123,6 @@ public class OpenALCreationTest {
|
|||
System.out.print("shutdown...");
|
||||
alExit();
|
||||
System.out.println("success");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -147,13 +136,13 @@ public class OpenALCreationTest {
|
|||
IntBuffer sources = createIntBuffer(1);
|
||||
|
||||
// al generate buffers and sources
|
||||
al.genBuffers(1, Sys.getDirectBufferAddress(buffers));
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alGenBuffers(1, buffers);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
al.genSources(1, Sys.getDirectBufferAddress(sources));
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alGenSources(1, sources);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
@ -161,13 +150,13 @@ public class OpenALCreationTest {
|
|||
WaveData wavefile = WaveData.create("Footsteps.wav");
|
||||
|
||||
//copy to buffers
|
||||
al.bufferData(
|
||||
AL.alBufferData(
|
||||
buffers.get(0),
|
||||
wavefile.format,
|
||||
Sys.getDirectBufferAddress(wavefile.data),
|
||||
wavefile.data,
|
||||
wavefile.data.capacity(),
|
||||
wavefile.samplerate);
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
@ -175,20 +164,20 @@ public class OpenALCreationTest {
|
|||
wavefile.dispose();
|
||||
|
||||
//set up source input
|
||||
al.sourcei(sources.get(0), AL.BUFFER, buffers.get(0));
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alSourcei(sources.get(0), AL.AL_BUFFER, buffers.get(0));
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//lets loop the sound
|
||||
al.sourcei(sources.get(0), AL.LOOPING, AL.TRUE);
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alSourcei(sources.get(0), AL.AL_LOOPING, AL.AL_TRUE);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//play source 0
|
||||
al.sourcePlay(sources.get(0));
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alSourcePlay(sources.get(0));
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
|
|
@ -201,19 +190,19 @@ public class OpenALCreationTest {
|
|||
System.out.println("done");
|
||||
|
||||
//stop source 0
|
||||
al.sourceStop(sources.get(0));
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alSourceStop(sources.get(0));
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
//delete buffers and sources
|
||||
al.deleteSources(1, Sys.getDirectBufferAddress(sources));
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alDeleteSources(1, sources);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
|
||||
al.deleteBuffers(1, Sys.getDirectBufferAddress(buffers));
|
||||
if ((lastError = al.getError()) != AL.NO_ERROR) {
|
||||
AL.alDeleteBuffers(1, buffers);
|
||||
if ((lastError = AL.alGetError()) != AL.AL_NO_ERROR) {
|
||||
exit(lastError);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue