Compare commits

...

3 Commits

Author SHA1 Message Date
FintasticMan
67e5fac1ac
Merge 40e2d0decc into c24a41b9e4 2024-12-29 17:04:31 -07:00
Junior Rantila
c24a41b9e4
Add Clay_IsDebugModeEnabled() (#130) 2024-12-30 12:04:48 +13:00
FintasticMan
5831a8ac7c
[Examples/Intro] Fix NULL pointer deref due to huuge malloc (#120)
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Has been cancelled
2024-12-29 06:39:38 +13:00
2 changed files with 8 additions and 5 deletions

6
clay.h
View File

@ -466,6 +466,7 @@ void Clay_SetMeasureTextFunction(Clay_Dimensions (*measureTextFunction)(Clay_Str
void Clay_SetQueryScrollOffsetFunction(Clay_Vector2 (*queryScrollOffsetFunction)(uint32_t elementId)); void Clay_SetQueryScrollOffsetFunction(Clay_Vector2 (*queryScrollOffsetFunction)(uint32_t elementId));
Clay_RenderCommand * Clay_RenderCommandArray_Get(Clay_RenderCommandArray* array, int32_t index); Clay_RenderCommand * Clay_RenderCommandArray_Get(Clay_RenderCommandArray* array, int32_t index);
void Clay_SetDebugModeEnabled(bool enabled); void Clay_SetDebugModeEnabled(bool enabled);
bool Clay_IsDebugModeEnabled(void);
void Clay_SetCullingEnabled(bool enabled); void Clay_SetCullingEnabled(bool enabled);
void Clay_SetMaxElementCount(uint32_t maxElementCount); void Clay_SetMaxElementCount(uint32_t maxElementCount);
void Clay_SetMaxMeasureTextCacheWordCount(uint32_t maxMeasureTextCacheWordCount); void Clay_SetMaxMeasureTextCacheWordCount(uint32_t maxMeasureTextCacheWordCount);
@ -3838,6 +3839,11 @@ void Clay_SetDebugModeEnabled(bool enabled) {
Clay__debugModeEnabled = enabled; Clay__debugModeEnabled = enabled;
} }
CLAY_WASM_EXPORT("Clay_IsDebugModeEnabled")
bool Clay_IsDebugModeEnabled(void) {
return Clay__debugModeEnabled;
}
CLAY_WASM_EXPORT("Clay_SetCullingEnabled") CLAY_WASM_EXPORT("Clay_SetCullingEnabled")
void Clay_SetCullingEnabled(bool enabled) { void Clay_SetCullingEnabled(bool enabled) {
Clay__disableCulling = !enabled; Clay__disableCulling = !enabled;

View File

@ -79,10 +79,7 @@ int main(void) {
Clay_Raylib_Initialize(1024, 768, "Introducing Clay Demo", FLAG_WINDOW_RESIZABLE | FLAG_WINDOW_HIGHDPI | FLAG_MSAA_4X_HINT | FLAG_VSYNC_HINT); // Extra parameters to this function are new since the video was published Clay_Raylib_Initialize(1024, 768, "Introducing Clay Demo", FLAG_WINDOW_RESIZABLE | FLAG_WINDOW_HIGHDPI | FLAG_MSAA_4X_HINT | FLAG_VSYNC_HINT); // Extra parameters to this function are new since the video was published
uint64_t clayRequiredMemory = Clay_MinMemorySize(); uint64_t clayRequiredMemory = Clay_MinMemorySize();
Clay_Arena clayMemory = (Clay_Arena) { Clay_Arena clayMemory = Clay_CreateArenaWithCapacityAndMemory(clayRequiredMemory, malloc(clayRequiredMemory));
.memory = malloc((size_t)1024 * 1024 * 1024 * 1024),
.capacity = clayRequiredMemory
};
Clay_Initialize(clayMemory, (Clay_Dimensions) { Clay_Initialize(clayMemory, (Clay_Dimensions) {
.width = GetScreenWidth(), .width = GetScreenWidth(),
.height = GetScreenHeight() .height = GetScreenHeight()