nicbarker / clay

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

[Improvement] Raylib renderer segfaults if fonts fail to load #32

Open LucasMW opened 1 month ago

LucasMW commented 1 month ago

Can't run on Mac OS Sonoma

image

INFO: FONT: Default font loaded successfully (224 glyphs) INFO: SYSTEM: Working Directory: /Users/lucassousa WARNING: FILEIO: [resources/profile-picture.png] Failed to open file WARNING: IMAGE: Data is not valid to load texture WARNING: FILEIO: [resources/Roboto-Regular.ttf] Failed to open file WARNING: FILEIO: [resources/Roboto-Regular.ttf] Failed to open file zsh: segmentation fault

nicbarker commented 1 month ago

Hello, sorry to hear that you're having issues. It appears from the log the example isn't able to load the font files from the disk, so the renderer is segfaulting when trying to measure text. Would you be able to tell me about your toolchain? Are you running the examples with CMake?

LucasMW commented 1 month ago

Hello. Thanks for the swift reply I tried some things and was actually able to run one of the examples, namely raylib-sidebar-scrolling-container:

image

Yes, I am using cmake, mkdir build; cd build; cmake ..; make;typical workflow. clay_examples_cpp_project_example builds, but running does nothing. (I don't know if it is intended) The official website I seem to have a problem with generating code for the target wasm32 Generating with cmake builds, but the binary does nothing: ./clay_official_website (does nothing) Using sh build.sh leads to

error: unable to create target: 'No available targets are compatible with triple "wasm32"'

I tried changing the target options and changing the compiler but got nowhere.

clang --version

Apple clang version 15.0.0 (clang-1500.3.9.4) Target: x86_64-apple-darwin23.0.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

cmake --version

cmake version 3.30.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).

Tried using zig cc as well:

zig version

0.12.0

nicbarker commented 1 month ago

@LucasMW Thanks for the info, I will get the documentation cleaned up a bit. Just for posterity:

I suspect that you may have to install llvm via brew to get the wasm example to compile, as clang goes out to llvm for it's wasm compile target. Let me know if you have issues and I can try to dig up the process I used. (Note to self: document this properly)

LucasMW commented 1 month ago

Hello! I managed to make the website work using zig cc 0.14.0+ (master branch by now)
--- a/examples/clay-official-website/build.sh +++ b/examples/clay-official-website/build.sh

-&& clang \ +&& zig-macos-x86_64-0.14.0-dev.1694+3b465ebec/zig cc \

---target=wasm32 \ +--target=wasm32-freestanding \

image
nicbarker commented 1 month ago

@LucasMW Apologies for the delayed response, I forgot to reply. That's awesome, well done! 😁