This file contains hidden or 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
#ifndef soluna_render_h | |
#define soluna_render_h | |
#include <stdint.h> | |
#include "sokol/sokol_gfx.h" | |
#define SOKOL_COMMAND_INVALID 0 | |
#define SOKOL_COMMAND_MAKE 1 | |
#define SOKOL_COMMAND_PASS 2 | |
#define SOKOL_COMMAND_UPDATE 3 |
This file contains hidden or 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
-- https://x.com/Ziyao233/status/1872575782360649792 | |
local inf <const> = 1/0 | |
local bool2Tri = { | |
[true] = "true", | |
[false] = "false", | |
} | |
local lut = { | |
equal = { [inf] = false, [true] = true, [-inf] = false }, |
This file contains hidden or 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
-- An inefficient but minimalist pure lua json parser | |
local escape_table = { | |
['"'] = '"', | |
['/'] = '/', | |
['\\'] = '\\', | |
['b'] = '\b', | |
['f'] = '\f', | |
['n'] = '\n', | |
['r'] = '\r', |
This file contains hidden or 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 "handle.h" | |
#include <stdlib.h> | |
#include <assert.h> | |
#include <string.h> | |
#define HANDLE_USED 0x80000000 | |
size_t | |
handle_size(int bits) { | |
int n = 1 << bits; |
This file contains hidden or 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
-- https://weibo.com/2050899237/OpPODpfBK | |
local function cache_func(func, cap) | |
cap = cap or 128 | |
local current_cache = {} | |
local cache_meta = { __index = current_cache } | |
local func_meta = { __index = nil } | |
local prev_meta = { __index = nil } | |
local n = 0 | |
This file contains hidden or 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 "scene.h" | |
#include <assert.h> | |
struct build_context { | |
int shift; | |
int x; | |
int y; | |
int id; | |
slot_t *grid; | |
}; |
This file contains hidden or 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 function keys(o) | |
local len = #o | |
local skeys = {} | |
local ukeys = {} | |
local n = 1 | |
for k,v in pairs(o) do | |
local nk = math.tointeger(k) | |
if nk == nil or nk <= 0 or nk > len then | |
local sk = tostring(k) | |
if type(k) == "string" then |
This file contains hidden or 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 <stdio.h> | |
static void | |
minmax(int height[], int n, int *min, int *max) { | |
int i; | |
*min = *max = height[0]; | |
for (i=1;i<n;i++) { | |
if (height[i] < *min) | |
*min = height[i]; | |
else if (height[i] > *max) |
This file contains hidden or 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 "clog.h" | |
#include <stdatomic.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#define LOGMETA_BUFFER 4096 | |
#define LOGDATA_BUFFER (64 * 1024) | |
// [..........................] | |
// ^ |
This file contains hidden or 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
// interface | |
struct object { | |
object * create(); | |
void release(); | |
int getState(); | |
}; | |
// implementation |
NewerOlder