From 2e43367af048deb20475ca0b5063dc3e27c8504c Mon Sep 17 00:00:00 2001 From: Nguyen Phi Hung Date: Wed, 19 Oct 2022 22:05:31 +0700 Subject: [PATCH] Adapt LWJGL 3.4 changes (hopefully fixes 22w42a) --- .../main/java/org/lwjgl/glfw/GLFWImage.java | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWImage.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWImage.java index c6feeb53a..43014d92e 100644 --- a/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWImage.java +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/glfw/GLFWImage.java @@ -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() {