-
Notifications
You must be signed in to change notification settings - Fork 142
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
CLAY_STRING should only be used for constant strings #70
Comments
Ah I have seen this myself. I believe font loading in raylib is not synchronous, so there is a race condition occurring. |
It makes a lot of sense; that's why it only happens in text elements. But why would it keep happening after the font has loaded if you are recreating ui every frame like other immediate mode libraryes |
Clay internally keeps a hashmap cache of text measurements because measuring text is very expensive 🙂 Would you be able to try calling |
I added UnloadFont but it still keeps happening. I will try adding sleep for 1 second to check if raylib loads fonts asynchronously |
I copy pasted your code from above and caught the error in my debugger locally so looking at it now 👍 |
Ah, so this one is my fault. It's not well documented at all, but the I modified your code and it seems to work like this:
Rendering each as Please let me know if this works for you 🙂 |
Thank you for finding the source of this issue, in my use case I get the data from a web server so i can't use constant variables. Also can you explain why CLAY_STRING dont work well with dynamic text |
No worries, in that case you can just construct the strings dynamically using:
|
Environment:
I was writing a small demo to test if I can use Clay to create a leaderboard (source code below). However, I noticed that Clay behaves incorrectly approximately 20% of the time, while it works as expected the other 80%. Every variablein my code is constant so I thought it was an issue with clay
Expected behavior:
Same executable 20% of the time
The text was updated successfully, but these errors were encountered: