Skip to content

Instantly share code, notes, and snippets.

View rubber-duck's full-sized avatar

Rafael Munitić rubber-duck

  • atena.tech
  • Zagreb, Croatia
  • 16:15 (UTC +02:00)
View GitHub Profile
#[deriving(ToStr)]
struct Vec3f {
x: f32,
y: f32,
z: f32
}
macro_rules! impl_vec_op(
($tr: ident, $op: ident, $vt: ident, $($members: ident)+) => (
impl $tr<$vt, $vt> for $vt {
src/functions.rs:1557:109: 1557:113 error: unresolved import. maybe a missing `extern mod libc`?
src/functions.rs:1557 fn glDrawElementsInstancedBaseInstance(mode: ::GLenum, count: ::GLsizei, gltype: ::GLenum, indices: *::libc::c_void, instancecount: ::GLsizei, baseinstance: ::GLuint);
^~~~
src/functions.rs:1557:109: 1557:123 error: use of undeclared module `::libc`
src/functions.rs:1557 fn glDrawElementsInstancedBaseInstance(mode: ::GLenum, count: ::GLsizei, gltype: ::GLenum, indices: *::libc::c_void, instancecount: ::GLsizei, baseinstance: ::GLuint);
^~~~~~~~~~~~~~
src/functions.rs:1557:109: 1557:123 error: use of undeclared type name `libc::c_void`
src/functions.rs:1557 fn glDrawElementsInstancedBaseInstance(mode: ::GLenum, c
use std::uint; use std::vec;
static node_size : uint = 32;
struct HashArrayMappedTrie<T> {
root : Node<T>,
length : uint
}
#[deriving(Clone)]
static node_size : uint = 32;
struct HashArrayMappedTrie<T> {
root : ~Node<T>,
length : uint
}
enum Node<T> {
Values([T]),
Children([@Node<T>, ..node_size]),
module toybox.math.vector;
private
{
import std.stdio, std.string, std.metastrings, std.typecons, std.traits;
static import std.math, std.algorithm;
import toybox.math.matrix;
}
template IsComponentType(T) { static if(is(T == float) || is(T == double) || is(T == int) || is(T == uint) || is(T == bool)) { enum IsComponentType = true; } else { enum IsComponentType = false; } }
template IsFloat(T) { static if(is(T == float) || is(T == double)) { enum IsFloat = true; } else { enum IsFloat = false; } }
static int coordIndex(char c)() pure nothrow
{
switch(c)
{
case 'x': return 0;
case 'y': return 1;
case 'z': return N > 2 ? 2 : -1;
case 'w': return N > 3 ? 3 : -1;
default:
return -1;
module test;
import std.stdio;
void foo(T)(T param) { static assert(false, "Not implemented"); }
void foo(T:float)(T param) { writeln(param); }
int main()
{
foo!double(1);
return 0;
ReturnType!fn checkedgl(alias fn) (ParameterTypeTuple!fn params, string file = __FILE__, size_t line = __LINE__)
{
scope(success)
{
auto errorCode = gl.getError();
if(errorCode != 0)
throw new GlException(errorCode, file, line);
}
return fn(params);
}
class Foo
{
int foo;
}
int main()
{
const Foo[] foo = [new Foo(), new Foo(), new Foo()];
foo[0].foo= 1;
import xml.etree.ElementTree as ET
import string
core_3_0 = [
"VERSION_1_0",
"VERSION_1_1",
"VERSION_1_2",
"VERSION_1_3",
"VERSION_1_4",