nicbarker / clay

High performance UI layout library in C.
https://nicbarker.com/clay
zlib License
1.29k stars 31 forks source link

The Odin example doesn't seem to work on Windows #9

Closed Dudejoe870 closed 2 months ago

Dudejoe870 commented 2 months ago

I was taking a look at a memory leak in the Odin bindings, you can find my changes here.

However, when trying to test my changes, it appears as if the example doesn't work at all on Windows? I tried the main branch of course as well; without my changes, and all I get is a white Window that stops responding, and just crashes. I haven't made a PR yet for the memory leak fix since I can't test it (though it's a very simple fix, you just forgot to free_all(context.temp_allocator), also I cleaned up part of the code using strings.clone_to_cstring instead of doing it manually). As I said, this behavior is the same on my branch as it is the main branch, so it isn't the fault of my changes of course.

All I did to run it is use odin run . in the examples/clay-official-website directory.

Doesn't look like it'd be a ton of help, but here's the log:

INFO: Initializing raylib 5.0
INFO: Platform backend: DESKTOP (GLFW)
INFO: Supported raylib modules:
INFO:     > rcore:..... loaded (mandatory)
INFO:     > rlgl:...... loaded (mandatory)
INFO:     > rshapes:... loaded (optional)
INFO:     > rtextures:. loaded (optional)
INFO:     > rtext:..... loaded (optional)
INFO:     > rmodels:... loaded (optional)
INFO:     > raudio:.... loaded (optional)
INFO: DISPLAY: Trying to enable MSAA x4
INFO: DISPLAY: Trying to enable VSYNC
INFO: DISPLAY: Device initialized successfully
INFO:     > Display size: 2560 x 1440
INFO:     > Screen size:  1024 x 768
INFO:     > Render size:  1024 x 768
INFO:     > Viewport offsets: 0, 0
INFO: GLAD: OpenGL extensions loaded successfully
INFO: GL: Supported extensions count: 401
INFO: GL: OpenGL device information:
INFO:     > Vendor:   NVIDIA Corporation
INFO:     > Renderer: NVIDIA GeForce RTX 2070 SUPER/PCIe/SSE2
INFO:     > Version:  3.3.0 NVIDIA 560.70
INFO:     > GLSL:     3.30 NVIDIA via Cg compiler
INFO: GL: VAO extension detected, VAO functions loaded successfully
INFO: GL: NPOT textures extension detected, full NPOT textures supported
INFO: GL: DXT compressed textures supported
INFO: GL: ETC2/EAC compressed textures supported
INFO: PLATFORM: DESKTOP (GLFW): Initialized successfully
INFO: TEXTURE: [ID 1] Texture loaded successfully (1x1 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 1] Default texture loaded successfully
INFO: SHADER: [ID 1] Vertex shader compiled successfully
INFO: SHADER: [ID 2] Fragment shader compiled successfully
INFO: SHADER: [ID 3] Program shader loaded successfully
INFO: SHADER: [ID 3] Default shader loaded successfully
INFO: RLGL: Render batch vertex buffers loaded successfully in RAM (CPU)
INFO: RLGL: Render batch vertex buffers loaded successfully in VRAM (GPU)
INFO: RLGL: Default OpenGL state initialized successfully
INFO: TEXTURE: [ID 2] Texture loaded successfully (128x128 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Default font loaded successfully (224 glyphs)
INFO: TIMER: Target time per frame: 6.944 milliseconds
INFO: FILEIO: [resources/Calistoga-Regular.ttf] File loaded successfully
INFO: TEXTURE: [ID 3] Texture loaded successfully (1024x1024 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Data loaded successfully (112 pixel size | 95 glyphs)
WARNING: TEXTURE: [ID 3] No mipmaps available for TRILINEAR texture filtering
INFO: FILEIO: [resources/Calistoga-Regular.ttf] File loaded successfully
INFO: TEXTURE: [ID 4] Texture loaded successfully (1024x1024 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Data loaded successfully (104 pixel size | 95 glyphs)
WARNING: TEXTURE: [ID 4] No mipmaps available for TRILINEAR texture filtering
INFO: FILEIO: [resources/Calistoga-Regular.ttf] File loaded successfully
INFO: TEXTURE: [ID 5] Texture loaded successfully (1024x1024 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Data loaded successfully (96 pixel size | 95 glyphs)
WARNING: TEXTURE: [ID 5] No mipmaps available for TRILINEAR texture filtering
INFO: FILEIO: [resources/Calistoga-Regular.ttf] File loaded successfully
INFO: TEXTURE: [ID 6] Texture loaded successfully (1024x512 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Data loaded successfully (72 pixel size | 95 glyphs)
WARNING: TEXTURE: [ID 6] No mipmaps available for TRILINEAR texture filtering
INFO: FILEIO: [resources/Calistoga-Regular.ttf] File loaded successfully
INFO: TEXTURE: [ID 7] Texture loaded successfully (1024x512 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Data loaded successfully (64 pixel size | 95 glyphs)
WARNING: TEXTURE: [ID 7] No mipmaps available for TRILINEAR texture filtering
INFO: FILEIO: [resources/Quicksand-Semibold.ttf] File loaded successfully
INFO: TEXTURE: [ID 8] Texture loaded successfully (1024x512 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Data loaded successfully (72 pixel size | 95 glyphs)
WARNING: TEXTURE: [ID 8] No mipmaps available for TRILINEAR texture filtering
INFO: FILEIO: [resources/Quicksand-Semibold.ttf] File loaded successfully
INFO: TEXTURE: [ID 9] Texture loaded successfully (1024x512 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Data loaded successfully (60 pixel size | 95 glyphs)
WARNING: TEXTURE: [ID 9] No mipmaps available for TRILINEAR texture filtering
INFO: FILEIO: [resources/Quicksand-Semibold.ttf] File loaded successfully
INFO: TEXTURE: [ID 10] Texture loaded successfully (512x512 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Data loaded successfully (56 pixel size | 95 glyphs)
WARNING: TEXTURE: [ID 10] No mipmaps available for TRILINEAR texture filtering
INFO: FILEIO: [resources/Quicksand-Semibold.ttf] File loaded successfully
INFO: TEXTURE: [ID 11] Texture loaded successfully (512x512 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Data loaded successfully (48 pixel size | 95 glyphs)
WARNING: TEXTURE: [ID 11] No mipmaps available for TRILINEAR texture filtering
INFO: FILEIO: [resources/Quicksand-Semibold.ttf] File loaded successfully
INFO: TEXTURE: [ID 12] Texture loaded successfully (512x256 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Data loaded successfully (32 pixel size | 95 glyphs)
WARNING: TEXTURE: [ID 12] No mipmaps available for TRILINEAR texture filtering
INFO: FILEIO: [resources/declarative.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (1136x1194 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 13] Texture loaded successfully (1136x1194 | R8G8B8A8 | 1 mipmaps)
INFO: FILEIO: [resources/check_1.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (64x64 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 14] Texture loaded successfully (64x64 | R8G8B8A8 | 1 mipmaps)
INFO: FILEIO: [resources/check_2.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (64x64 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 15] Texture loaded successfully (64x64 | R8G8B8A8 | 1 mipmaps)
INFO: FILEIO: [resources/check_3.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (64x64 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 16] Texture loaded successfully (64x64 | R8G8B8A8 | 1 mipmaps)
INFO: FILEIO: [resources/check_4.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (64x64 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 17] Texture loaded successfully (64x64 | R8G8B8A8 | 1 mipmaps)
INFO: FILEIO: [resources/check_5.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (64x64 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 18] Texture loaded successfully (64x64 | R8G8B8A8 | 1 mipmaps)
nicbarker commented 2 months ago

Thanks for the info and sorry it didn't work, I'll take a look on my windows machine now!

OttoHatt commented 2 months ago

Seems __attribute__((__packed__)) is not producing 1-byte enums on Windows? You can test this by replacing all instances of enum u8 with enum u32 in the bindings.

Dudejoe870 commented 2 months ago

Oh...? Does that fix it? Perhaps on Windows you could do a when ODIN_OS == .Windows to change the backing type

Dudejoe870 commented 2 months ago

That fixed it! I'll make a PR now

nicbarker commented 2 months ago

Thanks for the great work here!