Skip to content

Instantly share code, notes, and snippets.

View bvssvni's full-sized avatar

Sven Nilsen bvssvni

View GitHub Profile
@bvssvni
bvssvni / Cargo.lock
Created August 6, 2015 18:08
Cargo.lock for piston-examples
[root]
name = "piston-examples"
version = "0.0.0"
dependencies = [
"camera_controllers 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"find_folder 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx_device_gl 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"image 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
"piston-ai_behavior 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
[(Range { offset: 20, length: 0, phantom: PhantomData }, StartNode("materials")), (Range { offset: 45, length: 0, phantom: PhantomData }, StartNode("material")), (Range { offset: 45, length: 7, phantom: PhantomData }, String("name", "metal")), (Range { offset: 86, length: 3, phantom: PhantomData }, F64("reflectivity", 1)), (Range { offset: 45, length: 59, phantom: PhantomData }, EndNode("material")), (Range { offset: 118, length: 0, phantom: PhantomData }, StartNode("material")), (Range { offset: 118, length: 9, phantom: PhantomData }, String("name", "plastic")), (Range { offset: 161, length: 3, phantom: PhantomData }, F64("reflectivity", 0.5)), (Range { offset: 118, length: 61, phantom: PhantomData }, EndNode("material")), (Range { offset: 20, length: 170, phantom: PhantomData }, EndNode("materials")), (Range { offset: 200, length: 0, phantom: PhantomData }, StartNode("entities")), (Range { offset: 224, length: 0, phantom: PhantomData }, StartNode("entity")), (Range { offset: 248, length: 6, phantom: Phantom
@bvssvni
bvssvni / progress.md
Last active August 29, 2015 14:22
Bump "0.0.x" to "0.1.0"
  • graphics (@bvssvni)
  • interpolation (@bvssvni)
  • texture (@bvssvni)
  • viewport (@bvssvni)
  • float (@bvssvni)
  • read_color (@bvssvni)
  • vecmath (@bvssvni)
  • piston_window (@bvssvni)
  • glutin_window (@bvssvni)
  • input (@bvssvni)
@bvssvni
bvssvni / gist:18aa2ebac87081cafdd0
Last active August 29, 2015 14:20
Notation for reasoning about parsing - described in its own notation
whitespace { optional }:
whitespace?
token("whitespace")
select(
token("?") as optional
token("!") as !optional
)
whitespace?
parameter { name, args, value }:
0 CGLSetOption(pname = kCGLGOUseErrorHandler, param = 0) = kCGLNoError
1 CGLChoosePixelFormat(attribs = {kCGLPFAOpenGLProfile, kCGLOGLPVersion_3_2_Core, kCGLPFAColorSize, 32, kCGLPFADepthSize, 16, kCGLPFADoubleBuffer, kCGLPFADisplayMask, 4, 0}, pix = &0x7ff0c9d00f10, npix = &2) = kCGLNoError
2 CGLSetOption(pname = kCGLGOUseErrorHandler, param = 0) = kCGLNoError
3 CGLCreateContext(pix = 0x7ff0c9d00f10, share = NULL, ctx = &0x7ff0ca803600) = kCGLNoError
4 CGLSetParameter(ctx = 0x7ff0ca803600, pname = 1236, params = &-909113104) = kCGLNoError
5 CGLReleasePixelFormat(pix = 0x7ff0c9d00f10)
6 CGLSetSurface(ctx = 0x7ff0ca803600, cid = 0xd97b, wid = 68112, sid = 1642141264) = kCGLNoError
8 CGLUpdateContext(ctx = 0x7ff0ca803600) = kCGLNoError
9 CGLSetCurrentContext(ctx = 0x7ff0ca803600) = kCGLNoError
10 glViewport(x = 0, y = 0, width = 600, height = 600)
@bvssvni
bvssvni / gist:9a84fac5c95a40fbf18d
Created March 31, 2015 09:27
Slow build time on example
rustc examples/draw_state_test.rs
--crate-name draw_state_test
--crate-type bin
-g
--out-dir /Users/sven/rust/gfx_graphics/target/debug/examples
--emit=dep-info,link
-L dependency=/Users/sven/rust/gfx_graphics/target/debug
-L dependency=/Users/sven/rust/gfx_graphics/target/debug/deps
--extern graphics=/Users/sven/rust/gfx_graphics/target/debug/deps/libgraphics-3ec65f4f2805722e.rlib
--extern image=/Users/sven/rust/gfx_graphics/target/debug/deps/libimage-85c07ef1cf5314da.rlib
impl<'a> ToIndex<usize, &'a [usize]> for Permutation<Data> {
fn to_index(&self, dim: usize, pos: &'a [usize]) -> usize {
let mut index = 0;
let mut count = self.count(dim);
for (i, &x) in pos.iter().enumerate() {
count /= dim - i;
let lower = pos[..i].iter().fold(0, |a, &y|
if y < x { a + 1 } else { a });
index += count * (x - lower);
}
current! {
FOO: bar
=> {
print_text();
print_text();
}
}
/// Calls closure with a texture constructor enabled.
/// This is required to render characters.
pub fn with_texture_constructor<'a>(&mut self, texture_constructor: TextureConstructor<'a, T>, f: |&mut UiContext<T>|) {
use std::mem::transmute;
self.glyph_cache.texture_constructor =
Some(unsafe { transmute(texture_constructor) });
f(self);
self.glyph_cache.texture_constructor = None;
}
Failed to run custom build command for `cocoa v0.1.0 (https://github.com/DavidPartouche/rust-cocoa#b9cbbd50)`
Process didn't exit successfully: `make -f makefile.msgsend` (status=2)
--- stdout
cc -Wall src/msgsend.m -o /Users/sven/rust/glutin/target/native/cocoa-ebcc268ffcd672e2/msgsend.o -c
--- stderr
src/msgsend.m:82:9: warning: incompatible pointer to integer conversion returning 'id' from a function with result type 'char' [-Wint-conversion]
return objc_msgSend(theReceiver, theSelector, a);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/msgsend.m:86:15: warning: incompatible pointer types initializing 'NSPoint (*)(id, SEL, NSPoint)' with an expression of type 'NSPoint *' (aka 'struct CGPoint *') [-Wincompatible-pointer-types]