This file contains hidden or 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
when isMainModule: | |
import strutils | |
import common | |
import vector2 | |
import vector3 | |
import euler | |
import quaternion | |
import math3 | |
import math |
This file contains hidden or 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
type | |
Array32Part{.unchecked.} = array[0..0, float32] | |
Buffer32 = ref object | |
samples: int | |
bytes: int | |
data: ptr Array32Part | |
proc AllocBuffer32(samples : int): Buffer32 = | |
let bytes = samples * (sizeof(float32)) | |
Buffer32(samples: samples, bytes : bytes, data: cast[ptr Array32Part](alloc0(bytes))) |
This file contains hidden or 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
import endians | |
import sdl2 | |
import sdl2.image | |
discard IMG_Init | |
proc loadImage*(filename:string):PSurface= | |
var suce = IMG_Load(cstring(filename)) |
This file contains hidden or 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
class Node | |
{ | |
public var ci : Array<Int>; /* channel in */ | |
public var co : Array<Int>; /* channel out */ | |
public var i : Int; /* id */ | |
public var b : Int; /* behavior */ | |
public var a : Bool; /* alive */ | |
public function new(i,a) { ci = []; co = []; this.i = i; this.b = -1; this.a = a; } | |
} |
This file contains hidden or 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
type | |
GLFloatBufferPart{.unchecked.} = array[0..0, GLfloat] | |
GLFloatBuffer* = ref tuple | |
data : ptr GLFloatBufferPart | |
samples : int | |
bytes : int | |
# i want to expand this to all the GL numeric types through a generic: |
This file contains hidden or 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
type | |
DataEntry* = object | |
k:string # key | |
v:int # value | |
Rect* = object | |
x:int | |
y:int | |
w:int # width | |
h:int # height | |
d:seq[DataEntry] # metadata |
This file contains hidden or 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
# Generate and playback a sine tone | |
import sdl2 | |
import sdl2/audio | |
import math | |
# Audio settings requested: | |
const RQBufferSizeInSamples = 4096 | |
const RQBytesPerSample = 2 # 16 bit PCM | |
const RQBufferSizeInBytes = RQBufferSizeInSamples * RQBytesPerSample |
This file contains hidden or 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
type Uniforms = object | |
faefar:GLint # fade factor | |
tee:array[0..1,GLint] # textures | |
type Attributes = object | |
pon:GLint # position | |
type Resources = object | |
vexbur, eltbur:GLuint # vertex, element buffers | |
tee:array[0..1,GLuint] # textures | |
vexshr, frtshr:GLuint # vertex, element shaders | |
prm:GLuint # program |
This file contains hidden or 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
# Generate and playback a sine tone | |
import sdl2 | |
import sdl2/audio | |
import math | |
# Audio settings: | |
const Channels = 1 | |
const RQSizeInSamples = 4096 * Channels |
This file contains hidden or 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
class Eventsys | |
{ | |
public var entities = new Map<Int, IEntity>(); | |
public function new(){} | |
/* raw spawning tools. instantiate and assign parameters to entities with your own configuration mechanism. */ | |
public function spawn(e : IEntity, id : Int) { if (entities.exists(id)) { throw "overlapping entity id"; } e.id = id; entities.set(id, e); } | |
public function despawn(e : IEntity) { entities.remove(e.id); } |