Skip to content

Commit

Permalink
Fixed changing alt syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
mmeyerho committed Aug 6, 2012
1 parent a3ddb0b commit f071d5e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
4 changes: 2 additions & 2 deletions layers.rs
Expand Up @@ -67,10 +67,10 @@ class Image {

drop {
alt copy self.texture {
none {
none => {
// Nothing to do.
}
some(texture) {
some(texture) => {
delete_textures(&[texture]);
}
}
Expand Down
32 changes: 13 additions & 19 deletions rendergl.rs
Expand Up @@ -152,8 +152,8 @@ fn init_buffers() -> (GLuint, GLuint) {

fn create_texture_for_image_if_necessary(image: @Image) {
alt image.texture {
none {}
some(_) { return; /* Nothing to do. */ }
none => {}
some(_) => { return; /* Nothing to do. */ }
}

#debug("making texture");
Expand All @@ -169,14 +169,14 @@ fn create_texture_for_image_if_necessary(image: @Image) {
pixel_store_i(UNPACK_ALIGNMENT, 1);

alt image.format {
RGB24Format {
tex_image_2d(TEXTURE_2D, 0 as GLint, RGB as GLint, image.width as GLsizei,
image.height as GLsizei, 0 as GLint, RGB, UNSIGNED_BYTE, image.data);
}
ARGB32Format {
tex_image_2d(TEXTURE_2D, 0 as GLint, RGBA as GLint, image.width as GLsizei,
image.height as GLsizei, 0 as GLint, BGRA, UNSIGNED_BYTE, image.data);
}
RGB24Format => {
tex_image_2d(TEXTURE_2D, 0 as GLint, RGB as GLint, image.width as GLsizei,
image.height as GLsizei, 0 as GLint, RGB, UNSIGNED_BYTE, image.data);
}
ARGB32Format => {
tex_image_2d(TEXTURE_2D, 0 as GLint, RGBA as GLint, image.width as GLsizei,
image.height as GLsizei, 0 as GLint, BGRA, UNSIGNED_BYTE, image.data);
}
}

image.texture = some(texture);
Expand Down Expand Up @@ -248,15 +248,9 @@ fn render_scene(render_context: RenderContext, &scene: Scene) {
uniform_matrix_4fv(render_context.projection_uniform, false, projection_matrix.to_array());

alt copy scene.root {
ContainerLayerKind(*) {
fail ~"container layers unsupported";
}
ImageLayerKind(image_layer) {
image_layer.render(render_context);
}
TiledImageLayerKind(tiled_image_layer) {
tiled_image_layer.render(render_context);
}
ContainerLayerKind(*) => fail ~"container layers unsupported",
ImageLayerKind(image_layer) => image_layer.render(render_context),
TiledImageLayerKind(tiled_image_layer) => tiled_image_layer.render(render_context)
}
}

8 changes: 4 additions & 4 deletions test.rs
Expand Up @@ -85,16 +85,16 @@ struct Renderer {

fn display_callback() {
alt self.render_context {
none {
none => {
self.render_context = some(init_render_context());
}
some(_) {
some(_) => {
// Nothing to do.
}
}
let context = alt self.render_context {
none { fail }
some(ctx) { ctx }
none => fail,
some(ctx) => ctx
};

let t = self.t;
Expand Down

0 comments on commit f071d5e

Please sign in to comment.