Skip to content

Instantly share code, notes, and snippets.

View mrtrizer's full-sized avatar
💾

Denis Zdorovtsov mrtrizer

💾
View GitHub Profile
@mrtrizer
mrtrizer / c_ecs.c
Last active October 19, 2020 07:27
C language cache-friendly ECS
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <limits.h>
#include <assert.h>
#include <stdbool.h>
typedef uint32_t EId;
typedef struct
@mrtrizer
mrtrizer / typesafe_c_container.c
Last active March 14, 2021 00:55
C language type save containers. Requires GNU C11 (--std=gnu11) because of using typeof(). The benefit of this solution is compilation error if container type is wrong, or container item is of wrong type. The main idea is using function pointer to contain both type of container and type of container items.
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
unsigned int size;
void (*destructor)();
int length;
int reserved;
char* bytes;
Shader "Custom/Fog"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Texture", 2D) = "white" {}
_NoiseTex ("NoiseTexture", 2D) = "white" {}
}
SubShader
{
using UnityEngine;
using UnityEngine.Networking;
using System.Collections;
using System.Collections.Generic;
[CreateAssetMenu]
public class GoogleTranslateService : ScriptableObject
{
public static GoogleTranslateService instance;
@mrtrizer
mrtrizer / main.c
Last active October 18, 2020 11:16
C language macro-intense reflection for functions
#include <stdio.h>
// Make a FOREACH macro
#define FE_0()
#define FE_1(X) *((X*)(args[0]))
#define FE_2(X, ...) FE_1(__VA_ARGS__), *((X*)(args[1]))
#define FE_3(X, ...) FE_2(__VA_ARGS__), *((X*)(args[2]))
#define FE_4(X, ...) FE_3(__VA_ARGS__), *((X*)(args[3]))
#define FE_5(X, ...) FE_4(__VA_ARGS__), *((X*)(args[4]))
#define FE_6(X, ...) FE_5(__VA_ARGS__), *((X*)(args[5]))