Skip to content

Instantly share code, notes, and snippets.

View gszauer's full-sized avatar
💻
Living life 16.6 ms at a time

Gabor Szauer gszauer

💻
Living life 16.6 ms at a time
View GitHub Profile
@gszauer
gszauer / Tokenizer.cs
Created April 1, 2024 23:20
Tokenizer.cs
namespace Compiler {
public delegate void PrintErrorFunction(string message);
public class Location {
public string File { get; protected set; }
public int Line { get; protected set; }
public int Column { get; protected set; }
public Location(string file, int line, int column) {
File = file;
Line = line;
using UnityEngine;
using UnityEditor;
using System.Collections;
// an Editor method to create a cone primitive (so far no end caps)
// the top center is placed at (0/0/0)
// the bottom center is placed at (0/0/length)
// if either one of the radii is 0, the result will be a cone, otherwise a truncated cone
// note you will get inevitable breaks in the smooth shading at cone tips
// note the resulting mesh will be created as an asset in Assets/Editor
@gszauer
gszauer / trigapproximations.cpp
Created September 3, 2023 20:39
trigapproximations.cpp
// Trig approximations from: http://www.ganssle.com/approx.htm
#include <windows.h>
#include <cmath>
#include <iostream>
#include <iomanip>
#define WINDOW_WIDTH 800
#define WINDOW_HEIGHT 600
@gszauer
gszauer / math.glsl
Created November 4, 2018 20:19
Just Quaternions
// From: https://code.google.com/archive/p/kri/wikis/Quaternions.wiki
struct Spatial {
vec4 pos,rot;
};
//rotate vector
vec3 qrot(vec4 q, vec3 v) {
return v + 2.0*cross(q.xyz, cross(q.xyz,v) + q.w*v);
}
@gszauer
gszauer / Font.cpp
Last active July 26, 2023 06:21
Minimal ttf parser and rasterizer
#define _CRT_SECURE_NO_WARNINGS
#include "Font.h"
#include <tuple>
using std::vector;
using std::tuple;
using std::get;
void DrawPixel(i32 x, i32 y, u8 r, u8 g, u8 b);
@gszauer
gszauer / SkeletonVisualizer.cpp
Last active March 28, 2023 08:17
Skeleton Visualizer
#include "SkeletonVisualizer.h"
#if __linux
#include <GL/glew.h>
#include <GL/gl.h>
#elif WIN32
#include <GL/glew.h>
#include <Windows.h>
#include <tchar.h>
#include <gl/gl.h>
#else
@gszauer
gszauer / Brainfuck.cs
Created October 11, 2014 02:43
Simple 100 line C# brainfuck interpreter
using System;
namespace Brainfuck {
class MainClass {
public static void Main (string[] args) {
Console.WriteLine ("Enter Command Buffer: ");
string commandBuffer = Console.ReadLine ();
int[] memory = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int memoryPointer = 0;
@gszauer
gszauer / mousehandler.cpp
Created March 8, 2023 19:47
mousehandler.cpp
///////////////////////////////////////////////////////////////////////////
//
// MODULE: MOUSINFO.C
//
// DESCRIPTION: SDK sample for handling the WM_MOUSEWHEEL message and
// the TrackMouseEvent() API.
//
// Applet displays MouseButton, MouseWheel, MouseMovement, and
// any mouse messages in the title bar.
//
@gszauer
gszauer / memory.cpp
Created January 20, 2023 22:49
memory.cpp
#include "memory.h"
#if defined(MEM_PLATFORM_WINDOWS)
#include <windows.h>
mem_cfunc void PrintDebugString(const char* str) {
OutputDebugStringA(str);
}
#ifdef _DEBUG
#define MemInternal_Assert(cond) if (!(cond)) {*(u8*)0 = 0;}