Skip to content

Instantly share code, notes, and snippets.

View bvssvni's full-sized avatar

Sven Nilsen bvssvni

View GitHub Profile
impl<'a, W: Window>
Iterator<Event>
for EventIterator<'a, W> {
/// Returns the next game event.
fn next(&mut self) -> Option<Event> {
loop {
self.state = match self.state {
RenderState => {
if self.window.should_close() { return None; }
@bvssvni
bvssvni / new.rs
Last active August 29, 2015 14:06
fn main() {
let opengl = piston::shader_version::opengl::OpenGL_3_2;
let mut window = WindowSDL2::new(
opengl,
{ title: "Image".to_string(), size: [300, 300], .. }
);
let asset_store = AssetStore::from_folder("../bin/assets");
let image = asset_store.path("rust-logo.png").unwrap();
0 CGLSetOption(pname = kCGLGOUseErrorHandler, param = 0) = kCGLNoError
1 CGLChoosePixelFormat(attribs = {kCGLPFAOpenGLProfile, kCGLOGLPVersion_3_2_Core, kCGLPFAColorSize, 32, kCGLPFADepthSize, 16, kCGLPFADoubleBuffer, kCGLPFADisplayMask, 4, 0}, pix = &0x7f86ead063c0, npix = &2) = kCGLNoError
2 CGLSetOption(pname = kCGLGOUseErrorHandler, param = 0) = kCGLNoError
3 CGLCreateContext(pix = 0x7f86ead063c0, share = NULL, ctx = &0x7f86eb811400) = kCGLNoError
4 CGLSetParameter(ctx = 0x7f86eb811400, pname = 1236, params = &-355444128) = kCGLNoError
5 CGLReleasePixelFormat(pix = 0x7f86ead063c0)
6 CGLSetSurface(ctx = 0x7f86eb811400, cid = 0x125cf, wid = 39922, sid = 744855519) = kCGLNoError
8 CGLUpdateContext(ctx = 0x7f86eb811400) = kCGLNoError
9 CGLSetCurrentContext(ctx = 0x7f86eb811400) = kCGLNoError
10 glViewport(x = 0, y = 0, width = 300, height = 300)
src/main.rs:103:29: 103:68 error: unable to infer enough type information to locate the impl of the trait `graphics::image_size::ImageSize` for the type `<generic #737>`; type annotations required
src/main.rs:103 c.color(settings::WATER_COLOR).draw(gl);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Moving average:
avg * n / (n + 1) + x / (n + 1)
= (avg * n + x) / (n + 1)
substitue 1 with k:
(avg * n + x) / (n + k)
src/gfx2d.rs:112:5: 112:20 error: mismatched types: expected `[f32, .. 2]` but found `&[f32]` (expected vector but found &-ptr)
src/gfx2d.rs:112 pos: [f32, ..2],
^~~~~~~~~~~~~~~
note: in expansion of #[deriving]
src/gfx2d.rs:110:1: 110:19 note: expansion site
src/gfx2d.rs:113:5: 113:22 error: mismatched types: expected `[f32, .. 4]` but found `&[f32]` (expected vector but found &-ptr)
src/gfx2d.rs:113 color: [f32, ..4],
^~~~~~~~~~~~~~~~~
note: in expansion of #[deriving]
src/gfx2d.rs:110:1: 110:19 note: expansion site
pub struct Gfx2d {
state: gfx::DrawState,
program: gfx::shade::EmptyProgram,
program_uv: gfx::Program,
vertex_data: Vec<Vertex>,
vertex_data_uv: Vec<VertexUV>,
}
#![crate_name = "triangle"]
#![feature(phase)]
extern crate piston;
extern crate gfx;
#[phase(plugin)]
extern crate gfx_macros;
extern crate device;
extern crate sdl2;
extern crate sdl2_game_window;
error: error while parsing the registry
src/gl/lib.rs:88 generate_gl_bindings!("gl", "core", "4.5", "static", [ "GL_EXT_texture_filter_anisotropic" ])
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/gl/lib.rs:88:1: 88:94 error: Did not find version 4.5 in the registry
src/gl/lib.rs:88 generate_gl_bindings!("gl", "core", "4.5", "static", [ "GL_EXT_texture_filter_anisotropic" ])
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pub enum UserInput {
Press(&'static str),
Release(&'static str),
Repeat(&'static str),
Position(&'static str, f64, f64),
Scroll(&'static str, f64, f64),
Character(&'static str, char),
}