Minimum working example of Clay with the raylib renderer.
Signed-off-by: jmug <u.g.a.mariano@gmail.com>
This commit is contained in:
parent
86a9d305a6
commit
9c40af02c0
4 changed files with 60 additions and 0 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -116,3 +116,5 @@ tags
|
||||||
# Persistent undo
|
# Persistent undo
|
||||||
[._]*.un~
|
[._]*.un~
|
||||||
|
|
||||||
|
# Executable name
|
||||||
|
pialarm
|
||||||
|
|
|
||||||
14
build-and-run.sh
Executable file
14
build-and-run.sh
Executable file
|
|
@ -0,0 +1,14 @@
|
||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
gcc -o pialarm src/main.c -Wall -Wno-missing-braces -Wunused-result -O2 \
|
||||||
|
-I. -I/usr/local/include \
|
||||||
|
-Iraylib-5.5/src -Iraylib-5.5/src/external \
|
||||||
|
-Iclay \
|
||||||
|
-lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -latomic \
|
||||||
|
-L. -Lraylib-5.5/src -L/usr/local/lib \
|
||||||
|
-D_DEFAULT_SOURCE \
|
||||||
|
-DPLATFORM_DESKTOP -DPLATFORM_DESKTOP_GLFW
|
||||||
|
|
||||||
|
./pialarm
|
||||||
9
build-raylib.sh
Executable file
9
build-raylib.sh
Executable file
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
pushd "raylib-5.5/src"
|
||||||
|
make clean
|
||||||
|
make
|
||||||
|
popd
|
||||||
|
|
||||||
35
src/main.c
Normal file
35
src/main.c
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
#define CLAY_IMPLEMENTATION
|
||||||
|
#include "clay.h"
|
||||||
|
#include "renderers/raylib/clay_renderer_raylib.c"
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
uint64_t clayRequiredMemory = Clay_MinMemorySize();
|
||||||
|
Clay_Arena clayMemory = (Clay_Arena) {
|
||||||
|
.label = CLAY_STRING("Clay Memory Arena"),
|
||||||
|
.memory = malloc(clayRequiredMemory),
|
||||||
|
.capacity = clayRequiredMemory
|
||||||
|
};
|
||||||
|
Clay_Initialize(clayMemory, (Clay_Dimensions) { (float)GetScreenWidth(), (float)GetScreenHeight() });
|
||||||
|
Clay_Raylib_Initialize(GetScreenWidth(), GetScreenHeight(), "PiAlarm", FLAG_FULLSCREEN_MODE);
|
||||||
|
while (!WindowShouldClose()) {
|
||||||
|
Clay_BeginLayout();
|
||||||
|
CLAY(
|
||||||
|
CLAY_RECTANGLE({ .color = {255, 0, 0, 255} }),
|
||||||
|
CLAY_LAYOUT({
|
||||||
|
.sizing = {
|
||||||
|
.width = 720,
|
||||||
|
.height = 720
|
||||||
|
}
|
||||||
|
})
|
||||||
|
) {}
|
||||||
|
Clay_RenderCommandArray renderCommands = Clay_EndLayout();
|
||||||
|
|
||||||
|
BeginDrawing();
|
||||||
|
ClearBackground(BLACK);
|
||||||
|
Clay_Raylib_Render(renderCommands);
|
||||||
|
EndDrawing();
|
||||||
|
}
|
||||||
|
CloseWindow();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue