init
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.vscode
|
||||
.build
|
||||
47
build.sh
Executable file
47
build.sh
Executable file
@@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
RELEASE=false
|
||||
RUN_AFTER=false
|
||||
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--release)
|
||||
RELEASE=true
|
||||
;;
|
||||
--run)
|
||||
RUN_AFTER=true
|
||||
;;
|
||||
*)
|
||||
echo "Error: Unknown argument '$arg'"
|
||||
echo "Usage: $0 [--release] [--run]"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
mkdir -p .build
|
||||
|
||||
if $RELEASE; then
|
||||
echo "Building in RELEASE mode..."
|
||||
gcc src/main.c -O3 -std=c23 \
|
||||
-Ivendor/raylib-5.5_linux_amd64/include \
|
||||
-Ivendor/clay-0.14 \
|
||||
vendor/raylib-5.5_linux_amd64/lib/libraylib.a \
|
||||
-lm -o .build/out
|
||||
else
|
||||
echo "Building in DEBUG mode..."
|
||||
gcc src/main.c -ggdb -DDEBUG -std=c23 \
|
||||
-Ivendor/raylib-5.5_linux_amd64/include \
|
||||
-Ivendor/clay-0.14 \
|
||||
vendor/raylib-5.5_linux_amd64/lib/libraylib.a \
|
||||
-lm -o .build/out
|
||||
fi
|
||||
|
||||
if $RUN_AFTER; then
|
||||
echo "Running program..."
|
||||
.build/out
|
||||
else
|
||||
echo "Build complete: .build/out"
|
||||
fi
|
||||
BIN
resources/JetBrainsMono-Medium.ttf
Normal file
BIN
resources/JetBrainsMono-Medium.ttf
Normal file
Binary file not shown.
82
src/da.h
Normal file
82
src/da.h
Normal file
@@ -0,0 +1,82 @@
|
||||
// Yoinked from https://raw.githubusercontent.com/tsoding/nob.h/refs/heads/main/nob.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define DA_INIT_CAP 256
|
||||
|
||||
#define da_reserve(da, expected_capacity) \
|
||||
do \
|
||||
{ \
|
||||
if ((expected_capacity) > (da)->capacity) \
|
||||
{ \
|
||||
if ((da)->capacity == 0) \
|
||||
{ \
|
||||
(da)->capacity = DA_INIT_CAP; \
|
||||
} \
|
||||
while ((expected_capacity) > (da)->capacity) \
|
||||
{ \
|
||||
(da)->capacity *= 2; \
|
||||
} \
|
||||
(da)->items = realloc((da)->items, (da)->capacity * sizeof(*(da)->items)); \
|
||||
assert((da)->items != NULL && "Buy more RAM lol"); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define da_append(da, item) \
|
||||
do \
|
||||
{ \
|
||||
da_reserve((da), (da)->count + 1); \
|
||||
(da)->items[(da)->count++] = (item); \
|
||||
} while (0)
|
||||
|
||||
#define da_free(da) free((da).items)
|
||||
|
||||
#define da_append_many(da, new_items, new_items_count) \
|
||||
do \
|
||||
{ \
|
||||
da_reserve((da), (da)->count + (new_items_count)); \
|
||||
memcpy((da)->items + (da)->count, (new_items), (new_items_count) * sizeof(*(da)->items)); \
|
||||
(da)->count += (new_items_count); \
|
||||
} while (0)
|
||||
|
||||
#define da_resize(da, new_size) \
|
||||
do \
|
||||
{ \
|
||||
da_reserve((da), new_size); \
|
||||
(da)->count = (new_size); \
|
||||
} while (0)
|
||||
|
||||
#define da_last(da) (da)->items[(assert((da)->count > 0), (da)->count - 1)]
|
||||
|
||||
#define da_remove_unordered(da, i) \
|
||||
do \
|
||||
{ \
|
||||
size_t j = (i); \
|
||||
assert(j < (da)->count); \
|
||||
(da)->items[j] = (da)->items[--(da)->count]; \
|
||||
} while (0)
|
||||
|
||||
// Foreach over Dynamic Arrays. Example:
|
||||
// ```c
|
||||
// typedef struct {
|
||||
// int *items;
|
||||
// size_t count;
|
||||
// size_t capacity;
|
||||
// } Numbers;
|
||||
//
|
||||
// Numbers xs = {0};
|
||||
//
|
||||
// da_append(&xs, 69);
|
||||
// da_append(&xs, 420);
|
||||
// da_append(&xs, 1337);
|
||||
//
|
||||
// da_foreach(int, x, &xs) {
|
||||
// // `x` here is a pointer to the current element. You can get its index by taking a difference
|
||||
// // between `x` and the start of the array which is `x.items`.
|
||||
// size_t index = x - xs.items;
|
||||
// }
|
||||
// ```
|
||||
#define da_foreach(Type, it, da) for (Type *it = (da)->items; it < (da)->items + (da)->count; ++it)
|
||||
242
src/main.c
Normal file
242
src/main.c
Normal file
@@ -0,0 +1,242 @@
|
||||
#include <stdio.h>
|
||||
#include <raylib.h>
|
||||
#include <stdint.h>
|
||||
#define CLAY_IMPLEMENTATION
|
||||
#include <clay.h>
|
||||
#include <clay_renderer_raylib.c>
|
||||
#include "da.h"
|
||||
|
||||
#define COLOR_BLACK (Clay_Color){ 0, 0, 0, 255 }
|
||||
#define COLOR_WHITE (Clay_Color){ 255, 255, 255, 255 }
|
||||
|
||||
#define COLOR_BACKGROUND (Clay_Color){ 240, 240, 240, 255 }
|
||||
|
||||
#define SURFACE_BG_COLOR (Clay_Color){ 255, 255, 255, 255 }
|
||||
#define SURFACE_PADDING (Clay_Padding){ 8, 8, 8, 8 }
|
||||
#define SURFACE_CORNER_RADIUS (Clay_CornerRadius){ 4, 4, 4, 4 }
|
||||
#define SURFACE_BORDER (Clay_BorderElementConfig){ { 230, 230, 230, 255 }, { 2, 2, 2, 2 } }
|
||||
|
||||
#define FONT_SIZE 16
|
||||
|
||||
const unsigned char JETBRAINS_MONO_FONT_DATA[] = {
|
||||
#embed "../resources/JetBrainsMono-Medium.ttf"
|
||||
};
|
||||
|
||||
bool hoveringClickable = false;
|
||||
|
||||
typedef struct {
|
||||
size_t count;
|
||||
size_t capacity;
|
||||
Clay_String* items;
|
||||
} TabArray;
|
||||
|
||||
void HandleClayErrors(Clay_ErrorData errorData)
|
||||
{
|
||||
fprintf(stderr, "ERROR: %s\n", errorData.errorText.chars);
|
||||
}
|
||||
|
||||
Clay_Color shadeDown(Clay_Color color, int step)
|
||||
{
|
||||
return (Clay_Color){ color.r - step, color.g - step, color.b - step, color.a };
|
||||
}
|
||||
|
||||
bool Button(Clay_ElementId id, Clay_String text, Clay_Color backgroundColor, Clay_Color borderColor, bool disabled)
|
||||
{
|
||||
Clay_Context *context = Clay_GetCurrentContext();
|
||||
bool pressed = context->pointerInfo.state == CLAY_POINTER_DATA_PRESSED;
|
||||
|
||||
CLAY({
|
||||
.id = id,
|
||||
.layout = {
|
||||
.childGap = 4,
|
||||
.sizing = {
|
||||
.width = CLAY_SIZING_FIT(),
|
||||
.height = 16,
|
||||
},
|
||||
.padding = { 8, 8, 4, 4 },
|
||||
},
|
||||
.backgroundColor = disabled
|
||||
? shadeDown(backgroundColor, 15)
|
||||
: Clay_Hovered()
|
||||
? pressed
|
||||
? shadeDown(backgroundColor, 30)
|
||||
: shadeDown(backgroundColor, 15)
|
||||
: backgroundColor,
|
||||
.cornerRadius = { 4, 4, 4, 4 },
|
||||
.border = {
|
||||
.color = disabled
|
||||
? shadeDown(borderColor, 15)
|
||||
: Clay_Hovered()
|
||||
? pressed
|
||||
? shadeDown(borderColor, 30)
|
||||
: shadeDown(borderColor, 15)
|
||||
: borderColor,
|
||||
.width = { 2, 2, 2, 2 },
|
||||
},
|
||||
}) {
|
||||
CLAY_TEXT(text, CLAY_TEXT_CONFIG({
|
||||
.textColor = { 0, 0, 0, 255 },
|
||||
.fontSize = 16,
|
||||
}));
|
||||
}
|
||||
|
||||
bool hovered = Clay_PointerOver(id);
|
||||
|
||||
if (hovered && !disabled) {
|
||||
hoveringClickable = true;
|
||||
}
|
||||
|
||||
return !disabled && hovered && context->pointerInfo.state == CLAY_POINTER_DATA_RELEASED_THIS_FRAME;
|
||||
}
|
||||
|
||||
void Tabs(Clay_String tabs[], size_t tabCount, int *outTab)
|
||||
{
|
||||
CLAY({
|
||||
.id = CLAY_ID("TopBar"),
|
||||
.layout = {
|
||||
.layoutDirection = CLAY_LEFT_TO_RIGHT,
|
||||
.childGap = 4,
|
||||
.sizing = {
|
||||
.width = CLAY_SIZING_GROW(),
|
||||
},
|
||||
.padding = SURFACE_PADDING,
|
||||
},
|
||||
.backgroundColor = SURFACE_BG_COLOR,
|
||||
.cornerRadius = SURFACE_CORNER_RADIUS,
|
||||
.border = SURFACE_BORDER,
|
||||
}) {
|
||||
for (size_t i = 0; i < tabCount; i++)
|
||||
{
|
||||
bool isActiveTab = *outTab == i;
|
||||
|
||||
if (Button(CLAY_IDI_LOCAL("tab", i), tabs[i], COLOR_WHITE, shadeDown(COLOR_WHITE, 15), isActiveTab)) {
|
||||
*outTab = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Clay_RenderCommandArray CreateLayout(void)
|
||||
{
|
||||
Clay_SetLayoutDimensions((Clay_Dimensions){.width = GetScreenWidth(), .height = GetScreenHeight()});
|
||||
Clay_SetPointerState((Clay_Vector2){GetMouseX(), GetMouseY()}, IsMouseButtonDown(MOUSE_BUTTON_LEFT));
|
||||
Clay_UpdateScrollContainers(true, (Clay_Vector2){GetMouseWheelMoveV().x, GetMouseWheelMoveV().y}, GetFrameTime());
|
||||
|
||||
Clay_BeginLayout();
|
||||
|
||||
CLAY({
|
||||
.id = CLAY_ID("Container"),
|
||||
.layout = {
|
||||
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
||||
.childGap = 4,
|
||||
.sizing = {
|
||||
.width = CLAY_SIZING_GROW(),
|
||||
.height = CLAY_SIZING_GROW(),
|
||||
},
|
||||
.padding = { 8, 8, 8, 8 },
|
||||
},
|
||||
.backgroundColor = COLOR_BACKGROUND,
|
||||
}) {
|
||||
static TabArray tabs = {0};
|
||||
static int currentTab = 0;
|
||||
|
||||
if (tabs.count == 0) {
|
||||
da_append(&tabs, CLAY_STRING("default"));
|
||||
}
|
||||
|
||||
if (Button(CLAY_ID("AddTabButton"), CLAY_STRING("Add tab"), COLOR_WHITE, shadeDown(COLOR_WHITE, 15), false)) {
|
||||
da_append(&tabs, CLAY_STRING("tab"));
|
||||
}
|
||||
|
||||
Tabs(tabs.items, tabs.count, ¤tTab);
|
||||
|
||||
CLAY({
|
||||
.layout = {
|
||||
.padding = SURFACE_PADDING,
|
||||
.sizing = {
|
||||
.width = CLAY_SIZING_GROW(),
|
||||
.height = CLAY_SIZING_GROW(),
|
||||
},
|
||||
},
|
||||
.backgroundColor = SURFACE_BG_COLOR,
|
||||
.cornerRadius = SURFACE_CORNER_RADIUS,
|
||||
.border = SURFACE_BORDER
|
||||
}) {
|
||||
switch (currentTab)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
CLAY_TEXT(CLAY_STRING("Tab 1"), CLAY_TEXT_CONFIG({
|
||||
.textColor = COLOR_BLACK,
|
||||
.fontSize = FONT_SIZE,
|
||||
}));
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
CLAY_TEXT(CLAY_STRING("Tab 2"), CLAY_TEXT_CONFIG({
|
||||
.textColor = COLOR_BLACK,
|
||||
.fontSize = FONT_SIZE,
|
||||
}));
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
CLAY_TEXT(CLAY_STRING("Tab 3"), CLAY_TEXT_CONFIG({
|
||||
.textColor = COLOR_BLACK,
|
||||
.fontSize = FONT_SIZE,
|
||||
}));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Clay_EndLayout();
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
Clay_Raylib_Initialize(1920, 1080, "Introducing Clay Demo", FLAG_WINDOW_RESIZABLE | FLAG_WINDOW_HIGHDPI | FLAG_MSAA_4X_HINT | FLAG_VSYNC_HINT);
|
||||
|
||||
Font fonts[] = {
|
||||
LoadFontFromMemory(".ttf", JETBRAINS_MONO_FONT_DATA, sizeof(JETBRAINS_MONO_FONT_DATA), FONT_SIZE, NULL, 0),
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < sizeof(fonts) / sizeof(Font); i++)
|
||||
{
|
||||
SetTextureFilter(fonts[i].texture, TEXTURE_FILTER_BILINEAR);
|
||||
}
|
||||
|
||||
uint64_t requiredMemory = Clay_MinMemorySize();
|
||||
Clay_Arena arena = Clay_CreateArenaWithCapacityAndMemory(requiredMemory, malloc(requiredMemory));
|
||||
|
||||
Clay_Initialize(arena, (Clay_Dimensions){.width = GetScreenWidth(), .height = GetScreenHeight()}, (Clay_ErrorHandler){HandleClayErrors});
|
||||
Clay_SetMeasureTextFunction(Raylib_MeasureText, fonts);
|
||||
|
||||
#ifdef DEBUG
|
||||
Clay_SetDebugModeEnabled(true);
|
||||
#endif
|
||||
|
||||
while (!WindowShouldClose())
|
||||
{
|
||||
Clay_RenderCommandArray renderCommands = CreateLayout();
|
||||
BeginDrawing();
|
||||
ClearBackground(BLACK);
|
||||
Clay_Raylib_Render(renderCommands, fonts);
|
||||
|
||||
if (hoveringClickable) {
|
||||
SetMouseCursor(MOUSE_CURSOR_POINTING_HAND);
|
||||
} else {
|
||||
SetMouseCursor(MOUSE_CURSOR_DEFAULT);
|
||||
}
|
||||
|
||||
hoveringClickable = false;
|
||||
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
Clay_Raylib_Close();
|
||||
}
|
||||
4393
vendor/clay-0.14/clay.h
vendored
Normal file
4393
vendor/clay-0.14/clay.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
265
vendor/clay-0.14/clay_renderer_raylib.c
vendored
Normal file
265
vendor/clay-0.14/clay_renderer_raylib.c
vendored
Normal file
@@ -0,0 +1,265 @@
|
||||
#include "raylib.h"
|
||||
#include "raymath.h"
|
||||
#include "stdint.h"
|
||||
#include "string.h"
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
#define CLAY_RECTANGLE_TO_RAYLIB_RECTANGLE(rectangle) (Rectangle) { .x = rectangle.x, .y = rectangle.y, .width = rectangle.width, .height = rectangle.height }
|
||||
#define CLAY_COLOR_TO_RAYLIB_COLOR(color) (Color) { .r = (unsigned char)roundf(color.r), .g = (unsigned char)roundf(color.g), .b = (unsigned char)roundf(color.b), .a = (unsigned char)roundf(color.a) }
|
||||
|
||||
Camera Raylib_camera;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CUSTOM_LAYOUT_ELEMENT_TYPE_3D_MODEL
|
||||
} CustomLayoutElementType;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Model model;
|
||||
float scale;
|
||||
Vector3 position;
|
||||
Matrix rotation;
|
||||
} CustomLayoutElement_3DModel;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CustomLayoutElementType type;
|
||||
union {
|
||||
CustomLayoutElement_3DModel model;
|
||||
} customData;
|
||||
} CustomLayoutElement;
|
||||
|
||||
// Get a ray trace from the screen position (i.e mouse) within a specific section of the screen
|
||||
Ray GetScreenToWorldPointWithZDistance(Vector2 position, Camera camera, int screenWidth, int screenHeight, float zDistance)
|
||||
{
|
||||
Ray ray = { 0 };
|
||||
|
||||
// Calculate normalized device coordinates
|
||||
// NOTE: y value is negative
|
||||
float x = (2.0f*position.x)/(float)screenWidth - 1.0f;
|
||||
float y = 1.0f - (2.0f*position.y)/(float)screenHeight;
|
||||
float z = 1.0f;
|
||||
|
||||
// Store values in a vector
|
||||
Vector3 deviceCoords = { x, y, z };
|
||||
|
||||
// Calculate view matrix from camera look at
|
||||
Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up);
|
||||
|
||||
Matrix matProj = MatrixIdentity();
|
||||
|
||||
if (camera.projection == CAMERA_PERSPECTIVE)
|
||||
{
|
||||
// Calculate projection matrix from perspective
|
||||
matProj = MatrixPerspective(camera.fovy*DEG2RAD, ((double)screenWidth/(double)screenHeight), 0.01f, zDistance);
|
||||
}
|
||||
else if (camera.projection == CAMERA_ORTHOGRAPHIC)
|
||||
{
|
||||
double aspect = (double)screenWidth/(double)screenHeight;
|
||||
double top = camera.fovy/2.0;
|
||||
double right = top*aspect;
|
||||
|
||||
// Calculate projection matrix from orthographic
|
||||
matProj = MatrixOrtho(-right, right, -top, top, 0.01, 1000.0);
|
||||
}
|
||||
|
||||
// Unproject far/near points
|
||||
Vector3 nearPoint = Vector3Unproject((Vector3){ deviceCoords.x, deviceCoords.y, 0.0f }, matProj, matView);
|
||||
Vector3 farPoint = Vector3Unproject((Vector3){ deviceCoords.x, deviceCoords.y, 1.0f }, matProj, matView);
|
||||
|
||||
// Calculate normalized direction vector
|
||||
Vector3 direction = Vector3Normalize(Vector3Subtract(farPoint, nearPoint));
|
||||
|
||||
ray.position = farPoint;
|
||||
|
||||
// Apply calculated vectors to ray
|
||||
ray.direction = direction;
|
||||
|
||||
return ray;
|
||||
}
|
||||
|
||||
|
||||
static inline Clay_Dimensions Raylib_MeasureText(Clay_StringSlice text, Clay_TextElementConfig *config, void *userData) {
|
||||
// Measure string size for Font
|
||||
Clay_Dimensions textSize = { 0 };
|
||||
|
||||
float maxTextWidth = 0.0f;
|
||||
float lineTextWidth = 0;
|
||||
int maxLineCharCount = 0;
|
||||
int lineCharCount = 0;
|
||||
|
||||
float textHeight = config->fontSize;
|
||||
Font* fonts = (Font*)userData;
|
||||
Font fontToUse = fonts[config->fontId];
|
||||
// Font failed to load, likely the fonts are in the wrong place relative to the execution dir.
|
||||
// RayLib ships with a default font, so we can continue with that built in one.
|
||||
if (!fontToUse.glyphs) {
|
||||
fontToUse = GetFontDefault();
|
||||
}
|
||||
|
||||
float scaleFactor = config->fontSize/(float)fontToUse.baseSize;
|
||||
|
||||
for (int i = 0; i < text.length; ++i, lineCharCount++)
|
||||
{
|
||||
if (text.chars[i] == '\n') {
|
||||
maxTextWidth = fmax(maxTextWidth, lineTextWidth);
|
||||
maxLineCharCount = CLAY__MAX(maxLineCharCount, lineCharCount);
|
||||
lineTextWidth = 0;
|
||||
lineCharCount = 0;
|
||||
continue;
|
||||
}
|
||||
int index = text.chars[i] - 32;
|
||||
if (fontToUse.glyphs[index].advanceX != 0) lineTextWidth += fontToUse.glyphs[index].advanceX;
|
||||
else lineTextWidth += (fontToUse.recs[index].width + fontToUse.glyphs[index].offsetX);
|
||||
}
|
||||
|
||||
maxTextWidth = fmax(maxTextWidth, lineTextWidth);
|
||||
maxLineCharCount = CLAY__MAX(maxLineCharCount, lineCharCount);
|
||||
|
||||
textSize.width = maxTextWidth * scaleFactor + (lineCharCount * config->letterSpacing);
|
||||
textSize.height = textHeight;
|
||||
|
||||
return textSize;
|
||||
}
|
||||
|
||||
void Clay_Raylib_Initialize(int width, int height, const char *title, unsigned int flags) {
|
||||
SetConfigFlags(flags);
|
||||
InitWindow(width, height, title);
|
||||
// EnableEventWaiting();
|
||||
}
|
||||
|
||||
// A MALLOC'd buffer, that we keep modifying inorder to save from so many Malloc and Free Calls.
|
||||
// Call Clay_Raylib_Close() to free
|
||||
static char *temp_render_buffer = NULL;
|
||||
static int temp_render_buffer_len = 0;
|
||||
|
||||
// Call after closing the window to clean up the render buffer
|
||||
void Clay_Raylib_Close()
|
||||
{
|
||||
if(temp_render_buffer) free(temp_render_buffer);
|
||||
temp_render_buffer_len = 0;
|
||||
|
||||
CloseWindow();
|
||||
}
|
||||
|
||||
|
||||
void Clay_Raylib_Render(Clay_RenderCommandArray renderCommands, Font* fonts)
|
||||
{
|
||||
for (int j = 0; j < renderCommands.length; j++)
|
||||
{
|
||||
Clay_RenderCommand *renderCommand = Clay_RenderCommandArray_Get(&renderCommands, j);
|
||||
Clay_BoundingBox boundingBox = {roundf(renderCommand->boundingBox.x), roundf(renderCommand->boundingBox.y), roundf(renderCommand->boundingBox.width), roundf(renderCommand->boundingBox.height)};
|
||||
switch (renderCommand->commandType)
|
||||
{
|
||||
case CLAY_RENDER_COMMAND_TYPE_TEXT: {
|
||||
Clay_TextRenderData *textData = &renderCommand->renderData.text;
|
||||
Font fontToUse = fonts[textData->fontId];
|
||||
|
||||
int strlen = textData->stringContents.length + 1;
|
||||
|
||||
if(strlen > temp_render_buffer_len) {
|
||||
// Grow the temp buffer if we need a larger string
|
||||
if(temp_render_buffer) free(temp_render_buffer);
|
||||
temp_render_buffer = (char *) malloc(strlen);
|
||||
temp_render_buffer_len = strlen;
|
||||
}
|
||||
|
||||
// Raylib uses standard C strings so isn't compatible with cheap slices, we need to clone the string to append null terminator
|
||||
memcpy(temp_render_buffer, textData->stringContents.chars, textData->stringContents.length);
|
||||
temp_render_buffer[textData->stringContents.length] = '\0';
|
||||
DrawTextEx(fontToUse, temp_render_buffer, (Vector2){boundingBox.x, boundingBox.y}, (float)textData->fontSize, (float)textData->letterSpacing, CLAY_COLOR_TO_RAYLIB_COLOR(textData->textColor));
|
||||
|
||||
break;
|
||||
}
|
||||
case CLAY_RENDER_COMMAND_TYPE_IMAGE: {
|
||||
Texture2D imageTexture = *(Texture2D *)renderCommand->renderData.image.imageData;
|
||||
Clay_Color tintColor = renderCommand->renderData.image.backgroundColor;
|
||||
if (tintColor.r == 0 && tintColor.g == 0 && tintColor.b == 0 && tintColor.a == 0) {
|
||||
tintColor = (Clay_Color) { 255, 255, 255, 255 };
|
||||
}
|
||||
DrawTexturePro(
|
||||
imageTexture,
|
||||
(Rectangle) { 0, 0, imageTexture.width, imageTexture.height },
|
||||
(Rectangle){boundingBox.x, boundingBox.y, boundingBox.width, boundingBox.height},
|
||||
(Vector2) {},
|
||||
0,
|
||||
CLAY_COLOR_TO_RAYLIB_COLOR(tintColor));
|
||||
break;
|
||||
}
|
||||
case CLAY_RENDER_COMMAND_TYPE_SCISSOR_START: {
|
||||
BeginScissorMode((int)roundf(boundingBox.x), (int)roundf(boundingBox.y), (int)roundf(boundingBox.width), (int)roundf(boundingBox.height));
|
||||
break;
|
||||
}
|
||||
case CLAY_RENDER_COMMAND_TYPE_SCISSOR_END: {
|
||||
EndScissorMode();
|
||||
break;
|
||||
}
|
||||
case CLAY_RENDER_COMMAND_TYPE_RECTANGLE: {
|
||||
Clay_RectangleRenderData *config = &renderCommand->renderData.rectangle;
|
||||
if (config->cornerRadius.topLeft > 0) {
|
||||
float radius = (config->cornerRadius.topLeft * 2) / (float)((boundingBox.width > boundingBox.height) ? boundingBox.height : boundingBox.width);
|
||||
DrawRectangleRounded((Rectangle) { boundingBox.x, boundingBox.y, boundingBox.width, boundingBox.height }, radius, 8, CLAY_COLOR_TO_RAYLIB_COLOR(config->backgroundColor));
|
||||
} else {
|
||||
DrawRectangle(boundingBox.x, boundingBox.y, boundingBox.width, boundingBox.height, CLAY_COLOR_TO_RAYLIB_COLOR(config->backgroundColor));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CLAY_RENDER_COMMAND_TYPE_BORDER: {
|
||||
Clay_BorderRenderData *config = &renderCommand->renderData.border;
|
||||
// Left border
|
||||
if (config->width.left > 0) {
|
||||
DrawRectangle((int)roundf(boundingBox.x), (int)roundf(boundingBox.y + config->cornerRadius.topLeft), (int)config->width.left, (int)roundf(boundingBox.height - config->cornerRadius.topLeft - config->cornerRadius.bottomLeft), CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
||||
}
|
||||
// Right border
|
||||
if (config->width.right > 0) {
|
||||
DrawRectangle((int)roundf(boundingBox.x + boundingBox.width - config->width.right), (int)roundf(boundingBox.y + config->cornerRadius.topRight), (int)config->width.right, (int)roundf(boundingBox.height - config->cornerRadius.topRight - config->cornerRadius.bottomRight), CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
||||
}
|
||||
// Top border
|
||||
if (config->width.top > 0) {
|
||||
DrawRectangle((int)roundf(boundingBox.x + config->cornerRadius.topLeft), (int)roundf(boundingBox.y), (int)roundf(boundingBox.width - config->cornerRadius.topLeft - config->cornerRadius.topRight), (int)config->width.top, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
||||
}
|
||||
// Bottom border
|
||||
if (config->width.bottom > 0) {
|
||||
DrawRectangle((int)roundf(boundingBox.x + config->cornerRadius.bottomLeft), (int)roundf(boundingBox.y + boundingBox.height - config->width.bottom), (int)roundf(boundingBox.width - config->cornerRadius.bottomLeft - config->cornerRadius.bottomRight), (int)config->width.bottom, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
||||
}
|
||||
if (config->cornerRadius.topLeft > 0) {
|
||||
DrawRing((Vector2) { roundf(boundingBox.x + config->cornerRadius.topLeft), roundf(boundingBox.y + config->cornerRadius.topLeft) }, roundf(config->cornerRadius.topLeft - config->width.top), config->cornerRadius.topLeft, 180, 270, 10, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
||||
}
|
||||
if (config->cornerRadius.topRight > 0) {
|
||||
DrawRing((Vector2) { roundf(boundingBox.x + boundingBox.width - config->cornerRadius.topRight), roundf(boundingBox.y + config->cornerRadius.topRight) }, roundf(config->cornerRadius.topRight - config->width.top), config->cornerRadius.topRight, 270, 360, 10, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
||||
}
|
||||
if (config->cornerRadius.bottomLeft > 0) {
|
||||
DrawRing((Vector2) { roundf(boundingBox.x + config->cornerRadius.bottomLeft), roundf(boundingBox.y + boundingBox.height - config->cornerRadius.bottomLeft) }, roundf(config->cornerRadius.bottomLeft - config->width.bottom), config->cornerRadius.bottomLeft, 90, 180, 10, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
||||
}
|
||||
if (config->cornerRadius.bottomRight > 0) {
|
||||
DrawRing((Vector2) { roundf(boundingBox.x + boundingBox.width - config->cornerRadius.bottomRight), roundf(boundingBox.y + boundingBox.height - config->cornerRadius.bottomRight) }, roundf(config->cornerRadius.bottomRight - config->width.bottom), config->cornerRadius.bottomRight, 0.1, 90, 10, CLAY_COLOR_TO_RAYLIB_COLOR(config->color));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CLAY_RENDER_COMMAND_TYPE_CUSTOM: {
|
||||
Clay_CustomRenderData *config = &renderCommand->renderData.custom;
|
||||
CustomLayoutElement *customElement = (CustomLayoutElement *)config->customData;
|
||||
if (!customElement) continue;
|
||||
switch (customElement->type) {
|
||||
case CUSTOM_LAYOUT_ELEMENT_TYPE_3D_MODEL: {
|
||||
Clay_BoundingBox rootBox = renderCommands.internalArray[0].boundingBox;
|
||||
float scaleValue = CLAY__MIN(CLAY__MIN(1, 768 / rootBox.height) * CLAY__MAX(1, rootBox.width / 1024), 1.5f);
|
||||
Ray positionRay = GetScreenToWorldPointWithZDistance((Vector2) { renderCommand->boundingBox.x + renderCommand->boundingBox.width / 2, renderCommand->boundingBox.y + (renderCommand->boundingBox.height / 2) + 20 }, Raylib_camera, (int)roundf(rootBox.width), (int)roundf(rootBox.height), 140);
|
||||
BeginMode3D(Raylib_camera);
|
||||
DrawModel(customElement->customData.model.model, positionRay.position, customElement->customData.model.scale * scaleValue, WHITE); // Draw 3d model with texture
|
||||
EndMode3D();
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
printf("Error: unhandled render command.");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2599
vendor/raylib-5.5_linux_amd64/CHANGELOG
vendored
Normal file
2599
vendor/raylib-5.5_linux_amd64/CHANGELOG
vendored
Normal file
File diff suppressed because it is too large
Load Diff
16
vendor/raylib-5.5_linux_amd64/LICENSE
vendored
Normal file
16
vendor/raylib-5.5_linux_amd64/LICENSE
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
Copyright (c) 2013-2024 Ramon Santamaria (@raysan5)
|
||||
|
||||
This software is provided "as-is", without any express or implied warranty. In no event
|
||||
will the authors be held liable for any damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
wrote the original software. If you use this software in a product, an acknowledgment
|
||||
in the product documentation would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
150
vendor/raylib-5.5_linux_amd64/README.md
vendored
Normal file
150
vendor/raylib-5.5_linux_amd64/README.md
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
<img align="left" style="width:260px" src="https://github.com/raysan5/raylib/blob/master/logo/raylib_logo_animation.gif" width="288px">
|
||||
|
||||
**raylib is a simple and easy-to-use library to enjoy videogames programming.**
|
||||
|
||||
raylib is highly inspired by Borland BGI graphics lib and by XNA framework and it's especially well suited for prototyping, tooling, graphical applications, embedded systems and education.
|
||||
|
||||
*NOTE for ADVENTURERS: raylib is a programming library to enjoy videogames programming; no fancy interface, no visual helpers, no debug button... just coding in the most pure spartan-programmers way.*
|
||||
|
||||
Ready to learn? Jump to [code examples!](https://www.raylib.com/examples.html)
|
||||
|
||||
---
|
||||
|
||||
<br>
|
||||
|
||||
[](https://github.com/raysan5/raylib/releases)
|
||||
[](https://github.com/raysan5/raylib/stargazers)
|
||||
[](https://github.com/raysan5/raylib/commits/master)
|
||||
[](https://github.com/sponsors/raysan5)
|
||||
[](https://repology.org/project/raylib/versions)
|
||||
[](LICENSE)
|
||||
|
||||
[](https://discord.gg/raylib)
|
||||
[](https://www.reddit.com/r/raylib/)
|
||||
[](https://www.youtube.com/c/raylib)
|
||||
[](https://www.twitch.tv/raysan5)
|
||||
|
||||
[](https://github.com/raysan5/raylib/actions?query=workflow%3AWindows)
|
||||
[](https://github.com/raysan5/raylib/actions?query=workflow%3ALinux)
|
||||
[](https://github.com/raysan5/raylib/actions?query=workflow%3AmacOS)
|
||||
[](https://github.com/raysan5/raylib/actions?query=workflow%3AWebAssembly)
|
||||
|
||||
[](https://github.com/raysan5/raylib/actions?query=workflow%3ACMakeBuilds)
|
||||
[](https://github.com/raysan5/raylib/actions/workflows/windows_examples.yml)
|
||||
[](https://github.com/raysan5/raylib/actions/workflows/linux_examples.yml)
|
||||
|
||||
features
|
||||
--------
|
||||
- **NO external dependencies**, all required libraries are [bundled into raylib](https://github.com/raysan5/raylib/tree/master/src/external)
|
||||
- Multiple platforms supported: **Windows, Linux, MacOS, RPI, Android, HTML5... and more!**
|
||||
- Written in plain C code (C99) using PascalCase/camelCase notation
|
||||
- Hardware accelerated with OpenGL (**1.1, 2.1, 3.3, 4.3, ES 2.0, ES 3.0**)
|
||||
- **Unique OpenGL abstraction layer** (usable as standalone module): [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h)
|
||||
- Multiple **Fonts** formats supported (TTF, OTF, FNT, BDF, sprite fonts)
|
||||
- Multiple texture formats supported, including **compressed formats** (DXT, ETC, ASTC)
|
||||
- **Full 3D support**, including 3D Shapes, Models, Billboards, Heightmaps and more!
|
||||
- Flexible Materials system, supporting classic maps and **PBR maps**
|
||||
- **Animated 3D models** supported (skeletal bones animation) (IQM, M3D, glTF)
|
||||
- Shaders support, including model shaders and **postprocessing** shaders
|
||||
- **Powerful math module** for Vector, Matrix and Quaternion operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h)
|
||||
- Audio loading and playing with streaming support (WAV, QOA, OGG, MP3, FLAC, XM, MOD)
|
||||
- **VR stereo rendering** support with configurable HMD device parameters
|
||||
- Huge examples collection with [+140 code examples](https://github.com/raysan5/raylib/tree/master/examples)!
|
||||
- Bindings to [+70 programming languages](https://github.com/raysan5/raylib/blob/master/BINDINGS.md)!
|
||||
- **Free and open source**
|
||||
|
||||
basic example
|
||||
--------------
|
||||
This is a basic raylib example, it creates a window and draws the text `"Congrats! You created your first window!"` in the middle of the screen. Check this example [running live on web here](https://www.raylib.com/examples/core/loader.html?name=core_basic_window).
|
||||
```c
|
||||
#include "raylib.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
InitWindow(800, 450, "raylib [core] example - basic window");
|
||||
|
||||
while (!WindowShouldClose())
|
||||
{
|
||||
BeginDrawing();
|
||||
ClearBackground(RAYWHITE);
|
||||
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
CloseWindow();
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
build and installation
|
||||
----------------------
|
||||
|
||||
raylib binary releases for Windows, Linux, macOS, Android and HTML5 are available at the [Github Releases page](https://github.com/raysan5/raylib/releases).
|
||||
|
||||
raylib is also available via multiple package managers on multiple OS distributions.
|
||||
|
||||
#### Installing and building raylib on multiple platforms
|
||||
|
||||
[raylib Wiki](https://github.com/raysan5/raylib/wiki#development-platforms) contains detailed instructions on building and usage on multiple platforms.
|
||||
|
||||
- [Working on Windows](https://github.com/raysan5/raylib/wiki/Working-on-Windows)
|
||||
- [Working on macOS](https://github.com/raysan5/raylib/wiki/Working-on-macOS)
|
||||
- [Working on GNU Linux](https://github.com/raysan5/raylib/wiki/Working-on-GNU-Linux)
|
||||
- [Working on Chrome OS](https://github.com/raysan5/raylib/wiki/Working-on-Chrome-OS)
|
||||
- [Working on FreeBSD](https://github.com/raysan5/raylib/wiki/Working-on-FreeBSD)
|
||||
- [Working on Raspberry Pi](https://github.com/raysan5/raylib/wiki/Working-on-Raspberry-Pi)
|
||||
- [Working for Android](https://github.com/raysan5/raylib/wiki/Working-for-Android)
|
||||
- [Working for Web (HTML5)](https://github.com/raysan5/raylib/wiki/Working-for-Web-(HTML5))
|
||||
- [Working anywhere with CMake](https://github.com/raysan5/raylib/wiki/Working-with-CMake)
|
||||
|
||||
*Note that the Wiki is open for edit, if you find some issues while building raylib for your target platform, feel free to edit the Wiki or open an issue related to it.*
|
||||
|
||||
#### Setup raylib with multiple IDEs
|
||||
|
||||
raylib has been developed on Windows platform using [Notepad++](https://notepad-plus-plus.org/) and [MinGW GCC](https://www.mingw-w64.org/) compiler but it can be used with other IDEs on multiple platforms.
|
||||
|
||||
[Projects directory](https://github.com/raysan5/raylib/tree/master/projects) contains several ready-to-use **project templates** to build raylib and code examples with multiple IDEs.
|
||||
|
||||
*Note that there are lots of IDEs supported, some of the provided templates could require some review, so please, if you find some issue with a template or you think they could be improved, feel free to send a PR or open a related issue.*
|
||||
|
||||
learning and docs
|
||||
------------------
|
||||
|
||||
raylib is designed to be learned using [the examples](https://github.com/raysan5/raylib/tree/master/examples) as the main reference. There is no standard API documentation but there is a [**cheatsheet**](https://www.raylib.com/cheatsheet/cheatsheet.html) containing all the functions available on the library a short description of each one of them, input parameters and result value names should be intuitive enough to understand how each function works.
|
||||
|
||||
Some additional documentation about raylib design can be found in [raylib GitHub Wiki](https://github.com/raysan5/raylib/wiki). Here are the relevant links:
|
||||
|
||||
- [raylib cheatsheet](https://www.raylib.com/cheatsheet/cheatsheet.html)
|
||||
- [raylib architecture](https://github.com/raysan5/raylib/wiki/raylib-architecture)
|
||||
- [raylib library design](https://github.com/raysan5/raylib/wiki)
|
||||
- [raylib examples collection](https://github.com/raysan5/raylib/tree/master/examples)
|
||||
- [raylib games collection](https://github.com/raysan5/raylib-games)
|
||||
|
||||
|
||||
contact and networks
|
||||
---------------------
|
||||
|
||||
raylib is present in several networks and raylib community is growing everyday. If you are using raylib and enjoying it, feel free to join us in any of these networks. The most active network is our [Discord server](https://discord.gg/raylib)! :)
|
||||
|
||||
- Webpage: [https://www.raylib.com](https://www.raylib.com)
|
||||
- Discord: [https://discord.gg/raylib](https://discord.gg/raylib)
|
||||
- Twitter: [https://www.twitter.com/raysan5](https://www.twitter.com/raysan5)
|
||||
- Twitch: [https://www.twitch.tv/raysan5](https://www.twitch.tv/raysan5)
|
||||
- Reddit: [https://www.reddit.com/r/raylib](https://www.reddit.com/r/raylib)
|
||||
- Patreon: [https://www.patreon.com/raylib](https://www.patreon.com/raylib)
|
||||
- YouTube: [https://www.youtube.com/channel/raylib](https://www.youtube.com/c/raylib)
|
||||
|
||||
contributors
|
||||
------------
|
||||
|
||||
<a href="https://github.com/raysan5/raylib/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=raysan5/raylib&max=500&columns=20&anon=1" />
|
||||
</a>
|
||||
|
||||
license
|
||||
-------
|
||||
|
||||
raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software. Check [LICENSE](LICENSE) for further details.
|
||||
|
||||
raylib uses internally some libraries for window/graphics/inputs management and also to support different file formats loading, all those libraries are embedded with and are available in [src/external](https://github.com/raysan5/raylib/tree/master/src/external) directory. Check [raylib dependencies LICENSES](https://github.com/raysan5/raylib/wiki/raylib-dependencies) on [raylib Wiki](https://github.com/raysan5/raylib/wiki) for details.
|
||||
1708
vendor/raylib-5.5_linux_amd64/include/raylib.h
vendored
Normal file
1708
vendor/raylib-5.5_linux_amd64/include/raylib.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2941
vendor/raylib-5.5_linux_amd64/include/raymath.h
vendored
Normal file
2941
vendor/raylib-5.5_linux_amd64/include/raymath.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
5262
vendor/raylib-5.5_linux_amd64/include/rlgl.h
vendored
Normal file
5262
vendor/raylib-5.5_linux_amd64/include/rlgl.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
vendor/raylib-5.5_linux_amd64/lib/libraylib.a
vendored
Normal file
BIN
vendor/raylib-5.5_linux_amd64/lib/libraylib.a
vendored
Normal file
Binary file not shown.
1
vendor/raylib-5.5_linux_amd64/lib/libraylib.so
vendored
Symbolic link
1
vendor/raylib-5.5_linux_amd64/lib/libraylib.so
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
libraylib.so.550
|
||||
BIN
vendor/raylib-5.5_linux_amd64/lib/libraylib.so.5.5.0
vendored
Executable file
BIN
vendor/raylib-5.5_linux_amd64/lib/libraylib.so.5.5.0
vendored
Executable file
Binary file not shown.
1
vendor/raylib-5.5_linux_amd64/lib/libraylib.so.550
vendored
Symbolic link
1
vendor/raylib-5.5_linux_amd64/lib/libraylib.so.550
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
libraylib.so.5.5.0
|
||||
Reference in New Issue
Block a user