removed size argument from alBufferData and added additional buffer types

This commit is contained in:
Elias Naur 2004-04-09 15:22:20 +00:00
parent 4974a66398
commit 942dfb758d
4 changed files with 26 additions and 12 deletions

View File

@ -31,9 +31,11 @@
*/
package org.lwjgl.openal;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.ShortBuffer;
import java.nio.IntBuffer;
import java.nio.FloatBuffer;
/**
* $Id$
* <br>
@ -972,15 +974,27 @@ public final class AL10 {
int buffer,
int format,
ByteBuffer data,
int size,
int freq) {
// TODO: add an assertion here?
nalBufferData(buffer, format, data, data.position(), data.remaining(), freq);
}
public static void alBufferData(
int buffer,
int format,
ShortBuffer data,
int freq) {
nalBufferData(buffer, format, data, data.position() << 1, data.remaining() << 1, freq);
}
public static void alBufferData(
int buffer,
int format,
IntBuffer data,
int freq) {
nalBufferData(buffer, format, data, data.position() << 2, data.remaining() << 2, freq);
}
private static native void nalBufferData(
int buffer,
int format,
ByteBuffer data,
Buffer data,
int offset,
int size,
int freq);

View File

@ -133,4 +133,4 @@ public abstract class BasicTest {
alExit();
System.exit(-1);
}
}
}

View File

@ -103,14 +103,14 @@ public class PlayTest extends BasicTest {
ByteBuffer filebuffer = getData(args[0]);
// pass directly to buffer data
AL10.alBufferData(buffers.get(0), AL10.AL_FORMAT_VORBIS_EXT, filebuffer, -1, -1);
AL10.alBufferData(buffers.get(0), AL10.AL_FORMAT_VORBIS_EXT, filebuffer, -1);
filebuffer.clear();
} else {
// load wave data from buffer
WaveData wavefile = WaveData.create(args[0]);
//copy to buffers
AL10.alBufferData(buffers.get(0), wavefile.format, wavefile.data, wavefile.data.capacity(), wavefile.samplerate);
AL10.alBufferData(buffers.get(0), wavefile.format, wavefile.data, wavefile.samplerate);
//unload file again
wavefile.dispose();
@ -215,4 +215,4 @@ public class PlayTest extends BasicTest {
PlayTest playTest = new PlayTest();
playTest.execute(args);
}
}
}

View File

@ -164,7 +164,7 @@ public class PositionTest extends BasicTest {
Sys.log("Loading left.wav");
WaveData left = WaveData.create("left.wav");
AL10.alBufferData(soundBuffers.get(LEFT), left.format, left.data, left.data.capacity(), left.samplerate);
AL10.alBufferData(soundBuffers.get(LEFT), left.format, left.data, left.samplerate);
AL10.alSourcef(soundSources.get(LEFT), AL10.AL_PITCH, 1.0f);
AL10.alSourcef(soundSources.get(LEFT), AL10.AL_GAIN, 1.0f);
AL10.alSource(soundSources.get(LEFT), AL10.AL_POSITION, leftPosition);
@ -174,7 +174,7 @@ public class PositionTest extends BasicTest {
Sys.log("Loading center.wav");
WaveData center = WaveData.create("center.wav");
AL10.alBufferData(soundBuffers.get(CENTER), center.format, center.data, center.data.capacity(), center.samplerate);
AL10.alBufferData(soundBuffers.get(CENTER), center.format, center.data, center.samplerate);
AL10.alSourcef(soundSources.get(CENTER), AL10.AL_PITCH, 1.0f);
AL10.alSourcef(soundSources.get(CENTER), AL10.AL_GAIN, 1.0f);
AL10.alSource(soundSources.get(CENTER), AL10.AL_POSITION, centerPosition);
@ -184,7 +184,7 @@ public class PositionTest extends BasicTest {
Sys.log("Loading right.wav");
WaveData right = WaveData.create("right.wav");
AL10.alBufferData(soundBuffers.get(RIGHT), right.format, right.data, right.data.capacity(), right.samplerate);
AL10.alBufferData(soundBuffers.get(RIGHT), right.format, right.data, right.samplerate);
AL10.alSourcef(soundSources.get(RIGHT), AL10.AL_PITCH, 1.0f);
AL10.alSourcef(soundSources.get(RIGHT), AL10.AL_GAIN, 1.0f);
AL10.alSource(soundSources.get(RIGHT), AL10.AL_POSITION, rightPosition);
@ -513,4 +513,4 @@ public class PositionTest extends BasicTest {
}
}
}
}