Skip to content

Instantly share code, notes, and snippets.

Avatar

Brendan Zabarauskas brendanzab

View GitHub Profile
View basicwindow.c
#include <stdlib.h>
#include <stdio.h>
#include <GL/glfw3.h>
int main()
{
GLFWwindow window;
if( !glfwInit() )
{
View app.rs
import glfw3::*;
fn run(init_fn: &fn(), update_fn: &fn(tpf: f64), render_fn: &fn(), cleanup_fn: &fn()) {
init(init_fn, cleanup_fn);
mainloop(update_fn, render_fn, cleanup_fn);
cleanup(cleanup_fn);
}
fn init(init_fn: &fn(), cleanup_fn: &fn()) {
init_fn();
View glcorearb.rs
// #ifndef __glcorearb_h_
// #define __glcorearb_h_
// #ifdef __cplusplus
// extern "C" {
// #endif
/*
** Copyright (c) 2007-2012 The Khronos Group Inc.
**
View example of a glew registry file
GL_VERSION_2_0
http://www.opengl.org/documentation/specs/version2.0/glspec20.pdf
GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION
GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
GL_CURRENT_VERTEX_ATTRIB 0x8626
GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
View generate.rs
use io::*;
fn main() {
let (meta, consts, functions) = parse_ext("../core/GL_VERSION_1_1");
io::println(fmt!("%?", meta));
}
struct ExtMeta {
name: ~str,
url: ~str,
@brendanzab
brendanzab / macros.md
Created Oct 12, 2012
cond! and switch! macros for Rust
View macros.md

Scheme-style cond

macro_rules! cond(
    ($($pred:expr => $body:block),+ _ => $default:block) => (
        $(if $pred $body else)+
        
        $default
    )
)
@brendanzab
brendanzab / baby3.rs
Created Oct 15, 2012
Baby's First Parser Combinators
View baby3.rs
enum ParseNode {
NonTerminal(~[ParseNode]),
Terminal(~str),
}
enum ParseResult {
ParseOk(ParseNode, ~str),
ParseEnd(ParseNode),
NoParse,
}
@brendanzab
brendanzab / baby1.rs
Created Oct 15, 2012
Baby's First Parser Combinators
View baby1.rs
fn match_a(s: &str) -> bool { s == "a" }
fn main() {
io::println(fmt!("match_a(\"a\") -> %?", match_a("a")));
io::println(fmt!("match_a(\"b\") -> %?", match_a("b")));
}
View gist:3897455
// based off the examples shown in this blog post:
// http://blog.rfw.name/2012/10/12/parser_combinators.html
enum ParseNode {
NonTerminal(&self/[ParseNode]),
Terminal(&self/str),
Empty,
}
enum ParseResult {