Skip to content

Instantly share code, notes, and snippets.

View CobaltXII's full-sized avatar

CobaltXII CobaltXII

View GitHub Profile
#include <SDL2/SDL.h>
#include <cmath>
// An audio driver. This audio driver will define a callback that will
// generate a waveform which is passed to SDL. SDL passes this waveform to
// the OS, where it is output to a physical device.
struct audio_driver
{
// Emptyness? Awesome.
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"
#include <vector>
#include <utility>
#include <sstream>
#include <iostream>
@CobaltXII
CobaltXII / todo.txt
Last active November 27, 2019 21:11
To do
- [x] Quad tree compression
- [ ] GLSL smallpt
- [ ] CPU smallpt
- [ ] Dithering library
- [ ] All RGB
- [ ] Chip-8 emulator
- [ ] Chip-8 assembler
- [ ] Chip-8 disassembler
// Cellular automata? Awesome.
#include "../boiler/boiler.h"
#include <vector>
#include <utility>
#include <iostream>
typedef unsigned char cell;

Cosmos

Cosmos is an OpenCL accelerated n-body simulator. It can be used to render n-body simulations at a high speed.

Usage

Using Cosmos is a two step process. First, you must output binary data of the results of a n-body simulation. Second, you render this to a high-resolution image sequence. Cosmos provides two tools for these purposes, cosmos_simulate and cosmos_render.

Unfortunately, the Cosmos toolchain does not provide an easy way to tweak initial conditions or parameters. However, it does come with a great set of pre-defined conditions and parameters. If you want to modify these, you will have to edit the source code before compiling. If you want to find places where you can edit parameters, search for the text PARAM in all source files.

{"barrelBoltVertices":0,"barrelColor":[0.0,0.24705882370471954,0.0,1.0],"levelFloorColor1":[0.49803921580314636,0.49803921580314636,0.24705882370471954,1.0],"levelFloorColor2":[0.3079601228237152,0.30980393290519714,0.1530795842409134,1.0],"levelGridMajorColor":[0.0,0.0,0.0,0.0],"levelGridMajorThickness":0.0,"levelNoiseFrequency":0.4000000059604645,"lightBrilliance":5.0,"lightColor":[1.0,1.0,0.0,0.24705882370471954],"lightLuminosity":0.10000000149011612,"orbBackgroundColor":[0.7490196228027344,0.7490196228027344,0.125490203499794,1.0],"playerAdminTextColor":[1.0,1.0,0.0,1.0],"playerModeratorTextColor":[1.0,0.49803921580314636,0.0,1.0],"playerRespectedTextColor":[1.0,0.0,0.0,1.0]}
@CobaltXII
CobaltXII / protocol.md
Last active June 11, 2021 20:45
C4RN4G3 protocol

C4RN4G3 protocol

Data Types

Signed integers use 2's complement for negative values. Floating-point numbers must fulfill the requirements of IEEE 754. All data types are little-endian.

#include <cstdint>
#include <limits>
#pragma once
#include <array>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <map>
#include <string>
#include <tuple>
#include <type_traits>
// this function returns the frequency in Hz of a given note in a given octave
// i used this page to get the formula:
// https://pages.mtu.edu/~suits/NoteFreqCalcs.html
// and i used this page to get the reference frequency:
// https://pages.mtu.edu/~suits/notefreqs.html
function getNoteFrequency(note, octave)
{
// capital letter means it's a sharp
// this notation is what piano letter notes uses
var notes = ['c', 'C', 'd', 'D', 'e', 'f', 'F', 'g', 'G', 'a', 'A', 'b'];