From: <ma...@us...> - 2010-11-24 21:48:29
|
Revision: 3456 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3456&view=rev Author: matzon Date: 2010-11-24 21:48:23 +0000 (Wed, 24 Nov 2010) Log Message: ----------- adding support for zeroing buffers - patch'ish by MatthiasM Modified Paths: -------------- trunk/LWJGL/build.xml trunk/LWJGL/src/java/org/lwjgl/BufferUtils.java Added Paths: ----------- trunk/LWJGL/src/native/common/org_lwjgl_BufferUtils.c Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2010-11-11 21:25:20 UTC (rev 3455) +++ trunk/LWJGL/build.xml 2010-11-24 21:48:23 UTC (rev 3456) @@ -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> Modified: trunk/LWJGL/src/java/org/lwjgl/BufferUtils.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/BufferUtils.java 2010-11-11 21:25:20 UTC (rev 3455) +++ trunk/LWJGL/src/java/org/lwjgl/BufferUtils.java 2010-11-24 21:48:23 UTC (rev 3456) @@ -155,4 +155,41 @@ 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); } Added: trunk/LWJGL/src/native/common/org_lwjgl_BufferUtils.c =================================================================== --- trunk/LWJGL/src/native/common/org_lwjgl_BufferUtils.c (rev 0) +++ trunk/LWJGL/src/native/common/org_lwjgl_BufferUtils.c 2010-11-24 21:48:23 UTC (rev 3456) @@ -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); +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |