Skip to content

Instantly share code, notes, and snippets.

@acidleaf
acidleaf / Tilecode LUT
Created December 25, 2018 08:41
Lookup table for tilemap tile connectivity
// This LUT follows the following tile code:
// 1 2 4
// 8 X 16
// 32 64 128
static const int NUM_DIR = 8;
static const glm::ivec2 dir[NUM_DIR] = {
{ -1, -1 },
{ 0, -1 },
{ 1, -1 },
{ -1, 0 },
@acidleaf
acidleaf / clean-up-boot-partition-ubuntu.md
Created May 18, 2018 07:44 — forked from ipbastola/clean-up-boot-partition-ubuntu.md
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r 
@acidleaf
acidleaf / FPS.h
Created July 19, 2016 11:54
Simple FPS Counter
#ifndef __FPS_H__
#define __FPS_H__
// FPS Counter class
// Keep an instance in the main app context, and call update every frame
// Use the () operator to get the current FPS
class FPSCounter {
private:
unsigned long _frames = 0;
@acidleaf
acidleaf / checker.h
Created March 13, 2015 02:48
Generates a checker texture
uint8_t* checkerTexture(int w, int h, int num) {
const int dataSize = w * h * 3;
uint8_t* texData = new uint8_t[dataSize];
uint8_t c1r = 0x25, c1g = 0x25, c1b = 0x25;
uint8_t c2r = 0x30, c2g = 0x30, c2b = 0x30;
for (int i = 0; i < h; ++i) {
bool odd = true;
if ((i / num) % 2) odd = false;
@acidleaf
acidleaf / Elapsed.h
Last active August 29, 2015 14:16
C++11 std::chrono Timer
#ifndef __ELAPSED_H__
#define __ELAPSED_H__
/*
Simple C++11 timer class to profile your function calls, etc.
Usage:
Elapsed e;
e.begin();
myFunctionToBeProfiled();
@acidleaf
acidleaf / random.h
Last active August 29, 2015 14:13
C++11 RNG Wrapper
#ifndef __RANDOM_H__
#define __RANDOM_H__
// Wrapper for the C++11 random generators
#include <chrono>
#include <random>
class Random {
@acidleaf
acidleaf / pbo.cc
Last active August 29, 2015 14:07
OpenGL 3.3 PBO Code
void init() {
// Generate PBO
glGenBuffers(1, &_pbo);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, _pbo);
glBufferData(GL_PIXEL_UNPACK_BUFFER, TEX_SIZE * TEX_SIZE * 3, nullptr, GL_STREAM_DRAW);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
// Generate a texture
glGenTextures(1, &_texID);
@acidleaf
acidleaf / ZSH Prompt
Last active August 29, 2015 13:56
ZSH Prompt
PROMPT="
%{$FG[159]%}:: %{$FG[154]%}%n%{$FG[255]%} @ %{$FG[166]%}%m %{$FG[159][%}%{$FG[045]%}%*%{$FG[159]%}]
%{$FG[159]:: %}%{$FG[105]%~%}
%{$FG[045]%} ~> %{%f%}"
@acidleaf
acidleaf / vec2.h
Last active December 18, 2023 19:45
C++ 2D Vector
/*
Copyright (c) 2020 Chan Jer Shyan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: