mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-03-31 02:24:47 +02:00
adding support for zeroing buffers - patch'ish by MatthiasM
This commit is contained in:
parent
63e79ab5b3
commit
ebb196936e
|
|
@ -266,6 +266,7 @@
|
|||
<class name="org.lwjgl.opengl.CallbackUtil" />
|
||||
<class name="org.lwjgl.opencl.CL" />
|
||||
<class name="org.lwjgl.opencl.CallbackUtil" />
|
||||
<class name="org.lwjgl.BufferUtils" />
|
||||
</javah>
|
||||
</target>
|
||||
|
||||
|
|
|
|||
|
|
@ -155,4 +155,41 @@ public final class BufferUtils {
|
|||
return buffer.position() << getElementSizeExponent(buffer);
|
||||
}
|
||||
|
||||
/** Fill buffer with zeros from position to remaining */
|
||||
public static void zeroBuffer(ByteBuffer b) {
|
||||
zeroBuffer0(b, b.position(), b.remaining());
|
||||
}
|
||||
|
||||
/** Fill buffer with zeros from position to remaining */
|
||||
public static void zeroBuffer(ShortBuffer b) {
|
||||
zeroBuffer0(b, b.position()*2L, b.remaining()*2L);
|
||||
}
|
||||
|
||||
/** Fill buffer with zeros from position to remaining */
|
||||
public static void zeroBuffer(CharBuffer b) {
|
||||
zeroBuffer0(b, b.position()*2L, b.remaining()*2L);
|
||||
}
|
||||
|
||||
/** Fill buffer with zeros from position to remaining */
|
||||
public static void zeroBuffer(IntBuffer b) {
|
||||
zeroBuffer0(b, b.position()*4L, b.remaining()*4L);
|
||||
}
|
||||
|
||||
/** Fill buffer with zeros from position to remaining */
|
||||
public static void zeroBuffer(FloatBuffer b) {
|
||||
zeroBuffer0(b, b.position()*4L, b.remaining()*4L);
|
||||
}
|
||||
|
||||
/** Fill buffer with zeros from position to remaining */
|
||||
public static void zeroBuffer(LongBuffer b) {
|
||||
zeroBuffer0(b, b.position()*8L, b.remaining()*8L);
|
||||
}
|
||||
|
||||
/** Fill buffer with zeros from position to remaining */
|
||||
public static void zeroBuffer(DoubleBuffer b) {
|
||||
zeroBuffer0(b, b.position()*8L, b.remaining()*8L);
|
||||
}
|
||||
|
||||
/** Fill buffer with zeros from position to remaining */
|
||||
private static native void zeroBuffer0(Buffer b, long off, long size);
|
||||
}
|
||||
|
|
|
|||
5
src/native/common/org_lwjgl_BufferUtils.c
Normal file
5
src/native/common/org_lwjgl_BufferUtils.c
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#include "org_lwjgl_BufferUtils.h"
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_BufferUtils_zeroBuffer0(JNIEnv *env, jclass clazz, jobject buffer, jlong offset, jlong size) {
|
||||
memset((char*)(*env)->GetDirectBufferAddress(env, buffer) + (size_t)offset, 0, (size_t)size);
|
||||
}
|
||||
Loading…
Reference in a new issue