33 lines
972 B
C
33 lines
972 B
C
#ifndef _clay_renderer_SDL3_h
|
|
#define _clay_renderer_SDL3_h
|
|
|
|
#include <SDL3/SDL.h>
|
|
#include <SDL3_ttf/SDL_ttf.h>
|
|
#include <SDL3_image/SDL_image.h>
|
|
#include <SDL3_gfx/SDL3_gfxPrimitives.h>
|
|
|
|
#include "clay.h"
|
|
|
|
typedef struct {
|
|
SDL_Renderer *renderer;
|
|
TTF_TextEngine *textEngine;
|
|
TTF_Font **fonts;
|
|
} Clay_SDL3RendererData;
|
|
|
|
static inline Clay_Dimensions SDL_Clay_MeasureText(Clay_StringSlice text, Clay_TextElementConfig *config, void *userData) {
|
|
TTF_Font **fonts = userData;
|
|
TTF_Font *font = fonts[config->fontId];
|
|
int width, height;
|
|
|
|
if (!TTF_GetStringSize(font, text.chars, text.length, &width, &height)) {
|
|
SDL_LogError(SDL_LOG_CATEGORY_ERROR, "Failed to measure text: %s", SDL_GetError());
|
|
}
|
|
|
|
return (Clay_Dimensions) { (float) width, (float) height };
|
|
}
|
|
|
|
void SDL_Clay_HandleErrors(Clay_ErrorData errorData);
|
|
|
|
void SDL_Clay_RenderClayCommands(Clay_SDL3RendererData *rendererData, Clay_RenderCommandArray *rcommands);
|
|
|
|
#endif
|