mirror of
https://github.com/nicbarker/clay.git
synced 2025-04-19 04:38:01 +00:00
Fixed init ordering
This commit is contained in:
parent
bfed9520fc
commit
49b46a007b
@ -116,8 +116,8 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
|
|||||||
|
|
||||||
int width, height;
|
int width, height;
|
||||||
SDL_GetWindowSize(state->window, &width, &height);
|
SDL_GetWindowSize(state->window, &width, &height);
|
||||||
Clay_SetMeasureTextFunction(SDL_MeasureText, 0);
|
|
||||||
Clay_Initialize(clayMemory, (Clay_Dimensions) { (float) width, (float) height }, (Clay_ErrorHandler) { HandleClayErrors });
|
Clay_Initialize(clayMemory, (Clay_Dimensions) { (float) width, (float) height }, (Clay_ErrorHandler) { HandleClayErrors });
|
||||||
|
Clay_SetMeasureTextFunction(SDL_MeasureText, 0);
|
||||||
|
|
||||||
*appstate = state;
|
*appstate = state;
|
||||||
return SDL_APP_CONTINUE;
|
return SDL_APP_CONTINUE;
|
||||||
|
@ -218,8 +218,8 @@ void HandleClayErrors(Clay_ErrorData errorData) {
|
|||||||
int main(void) {
|
int main(void) {
|
||||||
uint64_t totalMemorySize = Clay_MinMemorySize();
|
uint64_t totalMemorySize = Clay_MinMemorySize();
|
||||||
Clay_Arena clayMemory = Clay_CreateArenaWithCapacityAndMemory(totalMemorySize, malloc(totalMemorySize));
|
Clay_Arena clayMemory = Clay_CreateArenaWithCapacityAndMemory(totalMemorySize, malloc(totalMemorySize));
|
||||||
Clay_SetMeasureTextFunction(Raylib_MeasureText, 0);
|
|
||||||
Clay_Initialize(clayMemory, (Clay_Dimensions) { (float)GetScreenWidth(), (float)GetScreenHeight() }, (Clay_ErrorHandler) { HandleClayErrors });
|
Clay_Initialize(clayMemory, (Clay_Dimensions) { (float)GetScreenWidth(), (float)GetScreenHeight() }, (Clay_ErrorHandler) { HandleClayErrors });
|
||||||
|
Clay_SetMeasureTextFunction(Raylib_MeasureText, 0);
|
||||||
Clay_Raylib_Initialize(1024, 768, "Clay - Raylib Renderer Example", FLAG_VSYNC_HINT | FLAG_WINDOW_RESIZABLE | FLAG_WINDOW_HIGHDPI | FLAG_MSAA_4X_HINT);
|
Clay_Raylib_Initialize(1024, 768, "Clay - Raylib Renderer Example", FLAG_VSYNC_HINT | FLAG_WINDOW_RESIZABLE | FLAG_WINDOW_HIGHDPI | FLAG_MSAA_4X_HINT);
|
||||||
profilePicture = LoadTextureFromImage(LoadImage("resources/profile-picture.png"));
|
profilePicture = LoadTextureFromImage(LoadImage("resources/profile-picture.png"));
|
||||||
Raylib_fonts[FONT_ID_BODY_24] = (Raylib_Font) {
|
Raylib_fonts[FONT_ID_BODY_24] = (Raylib_Font) {
|
||||||
|
@ -83,7 +83,7 @@ static inline char *Clay_Cairo__NullTerminate(Clay_String *str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Measure text using cairo's *toy* text API.
|
// Measure text using cairo's *toy* text API.
|
||||||
static inline Clay_Dimensions Clay_Cairo_MeasureText(Clay_String *str, Clay_TextElementConfig *config) {
|
static inline Clay_Dimensions Clay_Cairo_MeasureText(Clay_String *str, Clay_TextElementConfig *config, uintptr_t userData) {
|
||||||
// Edge case: Clay computes the width of a whitespace character
|
// Edge case: Clay computes the width of a whitespace character
|
||||||
// once. Cairo does not factor in whitespaces when computing text
|
// once. Cairo does not factor in whitespaces when computing text
|
||||||
// extents, this edge-case serves as a short-circuit to introduce
|
// extents, this edge-case serves as a short-circuit to introduce
|
||||||
|
Loading…
Reference in New Issue
Block a user