LWJGL / lwjgl3

LWJGL is a Java library that enables cross-platform access to popular native APIs useful in the development of graphics (OpenGL, Vulkan, bgfx), audio (OpenAL, Opus), parallel computing (OpenCL, CUDA) and XR (OpenVR, LibOVR, OpenXR) applications.
https://www.lwjgl.org
BSD 3-Clause "New" or "Revised" License
4.67k stars 629 forks source link

Nuklear nk_font_atlas_bake not returning correct byte buffer size #903

Closed rongcuid closed 11 months ago

rongcuid commented 11 months ago

Version

3.3.2

Platform

Linux x64, Linux arm64, Linux arm32, macOS x64, macOS arm64, Windows x64, Windows x86, Windows arm64

JDK

OpenJDK 17

Module

Nuklear

Bug description

The nk_font_atlas_bake doesn't handle format NK_FONT_ATLAS_RGBA32 properly. On a NK_FONT_ATLAS_ALPHA8 output, the byte buffer is exactly width * height, but on NK_FONT_ATLAS_RGBA32 output it should be width * height * 4. The current implementation works only for the ALPHA8 format:

    @Nullable
    @NativeType("void const *")
    public static ByteBuffer nk_font_atlas_bake(@NativeType("struct nk_font_atlas *") NkFontAtlas atlas, @NativeType("int *") IntBuffer width, @NativeType("int *") IntBuffer height, @NativeType("enum nk_font_atlas_format") int fmt) {
        if (CHECKS) {
            check(width, 1);
            check(height, 1);
        }
        long __result = nnk_font_atlas_bake(atlas.address(), memAddress(width), memAddress(height), fmt);
        return memByteBufferSafe(__result, width.get(width.position()) * height.get(height.position())); // <- This can be *4
    }

Stacktrace or crash log output

No response

Spasi commented 11 months ago

@rongcuid Thanks!