This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![cfg_attr(not(test), no_std)] | |
#![cfg_attr(not(test), no_main)] | |
#[cfg(not(test))] | |
extern crate alloc; | |
#[cfg(not(test))] | |
type Vec<T> = alloc::vec::Vec<T>; | |
#[cfg(not(test))] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
class UnaryTest { | |
public: | |
static const UnaryTest STATIC_TEST; | |
double p; | |
UnaryTest(double p); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<int32_t N> | |
void buffer(GLuint *vbos) { | |
if constexpr(N >= 0) { | |
const auto vertices = subdivide<N>(indexedVertices, indices); | |
const auto wireframe = getWireframeGeometry(vertices); | |
glBindBuffer(GL_ARRAY_BUFFER, vbos[N]); | |
glBufferData(GL_ARRAY_BUFFER, wireframe.size() * sizeof(Vertex), wireframe.data(), GL_STATIC_DRAW); | |
buffer<N - 1>(vbos); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local num_verts = 100000 | |
local vertices = {} | |
for i=1,num_verts do | |
vertices[i] = {0, 0, 0, 0, 255, 255, 255, 255} | |
end | |
local ffi = require('ffi') | |
ffi.cdef[[ | |
typedef struct { | |
float x, y; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local _PACKAGE = (...):match("^(.+)[%./][^%.]+") | |
local Line = {} | |
Line.__index = Line | |
local Vector = require(_PACKAGE .. ".vector") | |
function Line.new(x1, y1, x2, y2) | |
local self = setmetatable({}, Line) | |
self.origin = Vector(x1, y1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function insertVertices(vertices, vert, ...) | |
if vert then | |
table.insert(vertices, vert) | |
insertVertices(vertices, ...) | |
end | |
end | |
local function createSphereVertex(radius, theta, phi, ox, oy) | |
local xb = math.cos(phi) * math.cos(theta) | |
local yb = math.sin(theta) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function genMesh(num_verts, radius) | |
local verts = {} | |
local interval = math.pi * 2 / num_verts | |
for i=1,num_verts do | |
local phi = i * interval | |
local x = radius * math.cos(phi) | |
local y = radius * math.sin(phi) | |
local u = (x + radius) / (radius * 2) | |
local v = (y + radius) / (radius * 2) | |
table.insert(verts, {x, y, u, v}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- From https://github.com/karai17/Simple-Tiled-Implementation/blob/4ac519dbd5efdc0c6a70c35b9125faebe347772f/map.lua#L217 | |
local ffi = require("ffi") | |
local function getDecompressedData(data) | |
local d = {} | |
local decoded = ffi.cast("uint32_t*", data) | |
for i=0, data:len() / ffi.sizeof("uint32_t") do | |
table.insert(d, tonumber(decoded[i])) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Stateful = { | |
extend: function(klass) { | |
var currentState = klass.prototype; | |
var states = {null: currentState}; | |
klass.prototype.gotoState = function(stateName, ...args) { | |
currentState = states[stateName]; | |
} | |
klass.addState = function(stateName, state) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- all timings in bpm | |
return { | |
file: 'sounds/music.mp3', | |
bpm: 100, | |
players: 2, | |
actions: [ | |
{ | |
player: 1, | |
start_time: 1, |
NewerOlder