Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuklear nk_font_atlas_bake not returning correct byte buffer size #903

Closed
rongcuid opened this issue Jul 16, 2023 · 1 comment
Closed

Nuklear nk_font_atlas_bake not returning correct byte buffer size #903

rongcuid opened this issue Jul 16, 2023 · 1 comment

Comments

@rongcuid
Copy link

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
Copy link
Member

Spasi commented Jul 16, 2023

@rongcuid Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants