Skip to content

Fix some things for new rust version #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 8, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/demo/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
extern mod sdl2;
extern mod native;

mod video;

#[start]
fn start(argc: int, argv: **u8) -> int {
std::rt::start_on_main_thread(argc, argv, main)
native::start(argc, argv, main)
}

#[main]
Expand Down
38 changes: 22 additions & 16 deletions src/sdl2/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ pub enum RenderDriverIndex {

#[deriving(Eq, FromPrimitive)]
pub enum TextureAccess {
AccessStatic = ll::SDL_TEXTUREACCESS_STATIC as int,
AccessStatic = ll::SDL_TEXTUREACCESS_STATIC as int,
AccessStreaming = ll::SDL_TEXTUREACCESS_STREAMING as int,
AccessTarget = ll::SDL_TEXTUREACCESS_TARGET as int
}
Expand Down Expand Up @@ -206,10 +206,16 @@ impl RendererInfo {
}
}

#[deriving(Eq)]
enum RendererParent {
Window(~video::Window),
Surface(~surface::Surface),
}

#[deriving(Eq)]
pub struct Renderer {
raw: *ll::SDL_Renderer,
parent: Either<~video::Window, ~surface::Surface>,
parent: RendererParent,
owned: bool
}

Expand Down Expand Up @@ -238,7 +244,7 @@ impl Renderer {
if raw == ptr::null() {
Err(get_error())
} else {
Ok(~Renderer{ raw: raw, parent: Left(window), owned: true,})
Ok(~Renderer{ raw: raw, parent: Window(window), owned: true,})
}
}

Expand All @@ -254,8 +260,8 @@ impl Renderer {
};
Ok(~Renderer {
raw: raw_renderer,
parent: Left(window),
owned: true
parent: Window(window),
owned: true
})
} else {
Err(get_error())
Expand All @@ -267,8 +273,8 @@ impl Renderer {
if result == ptr::null() {
Ok(~Renderer {
raw: result,
parent: Right(surface),
owned: true
parent: Surface(surface),
owned: true
})
} else {
Err(get_error())
Expand Down Expand Up @@ -343,7 +349,7 @@ impl Renderer {
}

pub fn set_render_target(&self, texture: Option<&Texture>) -> bool {
unsafe {
unsafe {
let actual_texture = match texture {
Some(texture) => cast::transmute(texture.raw),
None => ptr::null()
Expand Down Expand Up @@ -467,11 +473,11 @@ impl Renderer {
texture.raw,
match src {
Some(rect) => cast::transmute(&rect),
None => ptr::null()
None => ptr::null()
},
match dst {
Some(rect) => cast::transmute(&rect),
None => ptr::null()
None => ptr::null()
}
) == 0
}
Expand All @@ -485,16 +491,16 @@ impl Renderer {
texture.raw,
match src {
Some(rect) => cast::transmute(&rect),
None => ptr::null()
None => ptr::null()
},
match dst {
Some(rect) => cast::transmute(&rect),
None => ptr::null()
None => ptr::null()
},
angle as c_double,
match center {
Some(point) => cast::transmute(&point),
None => ptr::null()
None => ptr::null()
},
FromPrimitive::from_i64(flip as i64).unwrap()
) == 0
Expand Down Expand Up @@ -542,7 +548,7 @@ impl Texture {
if result {
Ok(~TextureQuery {
format: FromPrimitive::from_i64(format as i64).unwrap(),
access: FromPrimitive::from_i64(access as i64).unwrap(),
access: FromPrimitive::from_i64(access as i64).unwrap(),
width: width as int,
height: height as int
})
Expand Down Expand Up @@ -598,7 +604,7 @@ impl Texture {
}

pub fn update(&self, rect: Option<Rect>, pixel_data: &[u8], pitch: int) -> bool {
unsafe {
unsafe {
let actual_rect = match rect {
Some(rect) => cast::transmute(&rect),
None => ptr::null()
Expand Down Expand Up @@ -650,7 +656,7 @@ pub fn get_num_render_drivers() -> Result<int, ~str> {
if result > 0 {
Ok(result as int)
} else {
Err(get_error())
Err(get_error())
}
}

Expand Down