diff --git a/src/native/common/common_tools.h b/src/native/common/common_tools.h index c236b093..5b80495a 100644 --- a/src/native/common/common_tools.h +++ b/src/native/common/common_tools.h @@ -89,7 +89,8 @@ static inline jobject safeNewBuffer(JNIEnv *env, void *p, int size) { static inline jobject safeNewBufferCached(JNIEnv *env, void *p, int size, jobject old_buffer) { if (old_buffer != NULL) { void *old_buffer_address = (*env)->GetDirectBufferAddress(env, old_buffer); - if (old_buffer_address == p) + jlong capacity = (*env)->GetDirectBufferCapacity(env, old_buffer); + if (old_buffer_address == p && capacity == size) return old_buffer; } return safeNewBuffer(env, p, size); diff --git a/src/templates/org/lwjgl/opengl/ARB_buffer_object.java b/src/templates/org/lwjgl/opengl/ARB_buffer_object.java index 76447ae1..5a6c782a 100644 --- a/src/templates/org/lwjgl/opengl/ARB_buffer_object.java +++ b/src/templates/org/lwjgl/opengl/ARB_buffer_object.java @@ -110,7 +110,7 @@ public interface ARB_buffer_object { * ByteBuffer mapped_buffer; mapped_buffer = glMapBufferARB(..., ..., ..., null); ... // Another map on the same buffer mapped_buffer = glMapBufferARB(..., ..., ..., mapped_buffer); * * @param result_size The size of the buffer area. - * @param old_buffer A ByteBuffer. If this argument points to the same address as the new mapping, it will be returned and no new buffer will be created. In that case, size is ignored. + * @param old_buffer A ByteBuffer. If this argument points to the same address and has the same capacity as the new mapping, it will be returned and no new buffer will be created. * * @return A ByteBuffer representing the mapped buffer memory. */ diff --git a/src/templates/org/lwjgl/opengl/ATI_map_object_buffer.java b/src/templates/org/lwjgl/opengl/ATI_map_object_buffer.java index d6bfda78..092e91d4 100644 --- a/src/templates/org/lwjgl/opengl/ATI_map_object_buffer.java +++ b/src/templates/org/lwjgl/opengl/ATI_map_object_buffer.java @@ -44,9 +44,8 @@ public interface ATI_map_object_buffer { * new ByteBuffer is created. * * @param result_size The size of the buffer area. - * @param old_buffer A ByteBuffer. If this argument points to the same address as the new mapping, - * it will be returned and no new buffer will be created. In that case, size is - * ignored. + * @param old_buffer A ByteBuffer. If this argument points to the same address and has the same capacity as the new mapping, + * it will be returned and no new buffer will be created. * * @return A ByteBuffer representing the mapped object buffer memory. */ diff --git a/src/templates/org/lwjgl/opengl/GL15.java b/src/templates/org/lwjgl/opengl/GL15.java index 9a61061b..7acdfb8c 100644 --- a/src/templates/org/lwjgl/opengl/GL15.java +++ b/src/templates/org/lwjgl/opengl/GL15.java @@ -116,8 +116,8 @@ public interface GL15 { * mapped_buffer = glMapBuffer(..., ..., ..., mapped_buffer); * * @param result_size The size of the buffer area. - * @param old_buffer A ByteBuffer. If this argument points to the same address as the new mapping, it will be returned and no - * new buffer will be created. In that case, size is ignored. + * @param old_buffer A ByteBuffer. If this argument points to the same address and has the same capacity as the new mapping, it will be returned and no + * new buffer will be created. * * @return A ByteBuffer representing the mapped buffer memory. */