This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _CRT_SECURE_NO_WARNINGS | |
#define _CRT_NONSTDC_NO_DEPRECATE | |
#include <ctype.h> | |
#include <stdbool.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <direct.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stdint.h> | |
char *read_entire_file_to_memory_and_nul_terminate(const char *filename, size_t *file_size) | |
{ | |
FILE* file = fopen(filename, "rb"); | |
if (file == NULL) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local ffi = require 'ffi' | |
ffi.cdef [[ | |
typedef void* b2AllocFcn( unsigned int size, int alignment ); | |
typedef void b2FreeFcn( void* mem ); | |
typedef int b2AssertFcn( const char* condition, const char* fileName, int lineNumber ); | |
void b2SetAllocator( b2AllocFcn* allocFcn, b2FreeFcn* freeFcn ); | |
int b2GetByteCount( void ); | |
void b2SetAssertFcn( b2AssertFcn* assertFcn ); | |
typedef struct b2Version { int major; int minor; int revision; } b2Version; | |
b2Version b2GetVersion( void ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint64_t b2_colorBox2DYellow = 16772748; | |
uint64_t b2_colorBox2DGreen = 9226532; | |
uint64_t b2_colorBox2DBlue = 3190463; | |
uint64_t b2_colorBox2DRed = 14430514; | |
uint64_t b2_colorYellowGreen = 10145074; | |
uint64_t b2_colorYellow = 16776960; | |
uint64_t b2_colorWhiteSmoke = 16119285; | |
uint64_t b2_colorWhite = 16777215; | |
uint64_t b2_colorWheat = 16113331; | |
uint64_t b2_colorVioletRed = 13639824; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include(FetchContent) | |
FetchContent_Declare( | |
luajit | |
GIT_REPOSITORY https://github.com/LuaJIT/LuaJIT | |
GIT_TAG v2.1 | |
) | |
FetchContent_MakeAvailable(luajit) | |
if (luajit_ADDED) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---@class Profiler | |
local profiler = { | |
internal_fns = {}, | |
call_stack = {}, | |
call_tree = {}, | |
clock = function() | |
return get_ticks() / get_tick_frequency() | |
end | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---@meta | |
---@class CF_Touch | |
---@field id number | |
---@field x number | |
---@field y number | |
---@field pressure number | |
---@class CF_ImeComposition | |
---@field composition string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Shallow copy a table | |
local function shallow_copy(t) | |
local copy = {} | |
for k, v in pairs(t) do | |
copy[k] = v | |
end | |
return copy | |
end | |
-- Escape reserved characters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define SPRITEBATCH_CHECK_BUFFER_GROW(ctx, count, capacity, data, type) \ | |
do { \ | |
if ((ctx->count) >= ctx->capacity) \ | |
{ \ | |
int new_capacity = (ctx->count) * 2; \ | |
void* new_data = SPRITEBATCH_MALLOC(sizeof(type) * new_capacity, ctx->mem_ctx); \ | |
if (!new_data) return 0; \ | |
SPRITEBATCH_MEMCPY(new_data, ctx->data, sizeof(type) * (ctx->count)); \ | |
SPRITEBATCH_FREE(ctx->data, ctx->mem_ctx); \ | |
ctx->data = (type*)new_data; \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <pico_ecs.h> | |
// -- System API -- | |
template<ecs_system_fn F> | |
inline ecs_id_t ecs_system; | |
template<ecs_system_fn F, typename... Cs> | |
ecs_id_t ecs_register_system(ecs_t *ecs, void *udata) |
NewerOlder