Skip to content

Instantly share code, notes, and snippets.

View CobaltXII's full-sized avatar

CobaltXII CobaltXII

View GitHub Profile
@CobaltXII
CobaltXII / cross_compiling_sdl2.md
Last active May 30, 2024 03:24
Cross-Compiling SDL2 Programs for Windows from Linux

Cross-Compiling SDL2 Programs for Windows from Linux using MinGW-w64

I'll explain how to create programs that run on Windows (.exe files) from a Linux machine. I'll explain how to compile C and C++, and how to make 32- and 64-bit programs. I'll also explain how to use third-party libraries (we'll use SDL2 here), and how to distribute the programs. We'll use the MinGW-w64 toolchain to accomplish this.

Note: MinGW-w64 is a fork of its predecessor, MinGW. They are different. If you install MinGW-w64 in a different way than shown in this document, make sure you have MinGW-w64, not just MinGW!

Installing and Using a Cross-Compiler

// 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'];
#pragma once
#include <array>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <map>
#include <string>
#include <tuple>
#include <type_traits>
@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>
{"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]}

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.

// Cellular automata? Awesome.
#include "../boiler/boiler.h"
#include <vector>
#include <utility>
#include <iostream>
typedef unsigned char cell;
@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
// Emptyness? Awesome.
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"
#include <vector>
#include <utility>
#include <sstream>
#include <iostream>