View main.cpp
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); | |
}; |
View buffer.cpp
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); | |
} | |
} |
View main.lua
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; |
View line.lua
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) |
View generateSphereVertices.lua
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) |
View genMesh.lua
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}) |
View map.lua
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 |
View stateful_with_proxy.js
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) { |
View test1.lua
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, |
View class_test.lua
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 Class = setmetatable({ | |
new = function(arg1, arg2, arg3) | |
local obj = {} | |
obj.var1 = arg1 | |
obj.var2 = arg2 | |
obj.var3 = arg3 | |
obj.out = function (self, arg) | |
print(self[arg]) | |
end |
NewerOlder