mirror of
https://github.com/nicbarker/clay.git
synced 2026-02-06 12:48:49 +00:00
[Renderers/SDL3] Add image rendering and scissor support to SDL3 renderer (#246)
This commit is contained in:
parent
eeb4520f48
commit
bc2548e3ec
5 changed files with 46 additions and 6 deletions
|
|
@ -14,7 +14,7 @@ set(FETCHCONTENT_QUIET FALSE)
|
|||
FetchContent_Declare(
|
||||
SDL
|
||||
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
|
||||
GIT_TAG preview-3.1.6
|
||||
GIT_TAG release-3.2.4
|
||||
GIT_SHALLOW TRUE
|
||||
GIT_PROGRESS TRUE
|
||||
)
|
||||
|
|
@ -34,11 +34,24 @@ message(STATUS "Using SDL_ttf via FetchContent")
|
|||
FetchContent_MakeAvailable(SDL_ttf)
|
||||
set_property(DIRECTORY "${sdl_ttf_SOURCE_DIR}" PROPERTY EXCLUDE_FROM_ALL TRUE)
|
||||
|
||||
# Download SDL_image
|
||||
FetchContent_Declare(
|
||||
SDL_image
|
||||
GIT_REPOSITORY "https://github.com/libsdl-org/SDL_image.git"
|
||||
GIT_TAG release-3.2.0 # Slightly risky to use main branch, but it's the only one available
|
||||
GIT_SHALLOW TRUE
|
||||
GIT_PROGRESS TRUE
|
||||
)
|
||||
message(STATUS "Using SDL_image via FetchContent")
|
||||
FetchContent_MakeAvailable(SDL_image)
|
||||
set_property(DIRECTORY "${SDL_image_SOURCE_DIR}" PROPERTY EXCLUDE_FROM_ALL TRUE)
|
||||
|
||||
# Example executable
|
||||
add_executable(${PROJECT_NAME} main.c)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
SDL3::SDL3
|
||||
SDL3_ttf::SDL3_ttf
|
||||
SDL3_image::SDL3_image
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ typedef struct app_state {
|
|||
ClayVideoDemo_Data demoData;
|
||||
} AppState;
|
||||
|
||||
SDL_Surface *sample_image;
|
||||
|
||||
static inline Clay_Dimensions SDL_MeasureText(Clay_StringSlice text, Clay_TextElementConfig *config, void *userData)
|
||||
{
|
||||
TTF_Font **fonts = userData;
|
||||
|
|
@ -81,6 +83,8 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
|
|||
|
||||
state->rendererData.fonts[FONT_ID] = font;
|
||||
|
||||
sample_image = IMG_Load("resources/sample.png");
|
||||
|
||||
/* Initialize Clay */
|
||||
uint64_t totalMemorySize = Clay_MinMemorySize();
|
||||
Clay_Arena clayMemory = (Clay_Arena) {
|
||||
|
|
|
|||
BIN
examples/SDL3-simple-demo/resources/sample.png
Normal file
BIN
examples/SDL3-simple-demo/resources/sample.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 850 B |
Loading…
Add table
Add a link
Reference in a new issue