Skip to content

Commit

Permalink
Update to new API
Browse files Browse the repository at this point in the history
  • Loading branch information
nicbarker committed Jan 19, 2025
1 parent e516739 commit 713fd67
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions examples/sdl3_renderer/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ static void SDL_RenderClayCommands(SDL_Renderer *renderer, Clay_RenderCommandArr
}
}

void HandleClayErrors(Clay_ErrorData errorData) {
printf("%s", errorData.errorText.chars);
}

SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
{
(void) argc;
Expand Down Expand Up @@ -137,15 +141,14 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
/* Initialize Clay */
uint64_t totalMemorySize = Clay_MinMemorySize();
Clay_Arena clayMemory = (Clay_Arena) {
.label = CLAY_STRING("Clay Memory Arena"),
.memory = SDL_malloc(totalMemorySize),
.capacity = totalMemorySize
};

int width, height;
SDL_GetWindowSize(state->window, &width, &height);
Clay_SetMeasureTextFunction(SDL_MeasureText);
Clay_Initialize(clayMemory, (Clay_Dimensions) { (float) width, (float) height });
Clay_Initialize(clayMemory, (Clay_Dimensions) { (float) width, (float) height }, (Clay_ErrorHandler) { HandleClayErrors });

*appstate = state;
return SDL_APP_CONTINUE;
Expand Down

0 comments on commit 713fd67

Please sign in to comment.