Adapt LWJGL 3.4 changes (hopefully fixes 22w42a)

This commit is contained in:
Nguyen Phi Hung
2022-10-19 22:05:31 +07:00
parent 64410a65e5
commit 2e43367af0

View File

@@ -199,8 +199,45 @@ public class GLFWImage extends Struct implements NativeResource {
public static GLFWImage.Buffer createSafe(long address, int capacity) {
return address == NULL ? null : wrap(Buffer.class, address, capacity);
}
/**
* Returns a new {@code GLFWImage} instance allocated on the specified {@link MemoryStack}.
*
* @param stack the stack from which to allocate
*/
public static GLFWImage malloc(MemoryStack stack) {
return wrap(GLFWImage.class, stack.nmalloc(ALIGNOF, SIZEOF));
}
// -----------------------------------
/**
* Returns a new {@code GLFWImage} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero.
*
* @param stack the stack from which to allocate
*/
public static GLFWImage calloc(MemoryStack stack) {
return wrap(GLFWImage.class, stack.ncalloc(ALIGNOF, 1, SIZEOF));
}
/**
* Returns a new {@link GLFWImage.Buffer} instance allocated on the specified {@link MemoryStack}.
*
* @param stack the stack from which to allocate
* @param capacity the buffer capacity
*/
public static GLFWImage.Buffer malloc(int capacity, MemoryStack stack) {
return wrap(Buffer.class, stack.nmalloc(ALIGNOF, capacity * SIZEOF), capacity);
}
/**
* Returns a new {@link GLFWImage.Buffer} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero.
*
* @param stack the stack from which to allocate
* @param capacity the buffer capacity
*/
public static GLFWImage.Buffer calloc(int capacity, MemoryStack stack) {
return wrap(Buffer.class, stack.ncalloc(ALIGNOF, capacity, SIZEOF), capacity);
}
// mallocStack() and callocStack() will be removed in 3.4.0. Keeping them here for compatibility.
/** Returns a new {@code GLFWImage} instance allocated on the thread-local {@link MemoryStack}. */
public static GLFWImage mallocStack() {