Skip to content

Commit 25f66b0

Browse files
committed
Merge pull request #31 from crumblingstatue/master
Update to sdl2 0.15
2 parents 0d771d1 + a945e51 commit 25f66b0

File tree

4 files changed

+64
-67
lines changed

4 files changed

+64
-67
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ path = "src/sdl2_ttf/lib.rs"
1414

1515
[dependencies]
1616
bitflags = "0.4"
17-
sdl2 = "0.14.0"
17+
sdl2 = "0.15.0"
1818
sdl2-sys = "0.8.0"
1919

2020
# [dependencies.sdl2]

examples/demo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ static SCREEN_HEIGHT : u32 = 600;
1616
// handle the annoying Rect i32
1717
macro_rules! rect(
1818
($x:expr, $y:expr, $w:expr, $h:expr) => (
19-
Rect::new_unwrap($x as i32, $y as i32, $w as u32, $h as u32)
19+
Rect::new($x as i32, $y as i32, $w as u32, $h as u32)
2020
)
2121
);
2222

src/sdl2_ttf/context.rs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ use std::path::Path;
77
use sdl2::get_error;
88
use sdl2::rwops::RWops;
99
use sdl2::version::Version;
10-
use sdl2::SdlResult;
1110

1211
use font::{
13-
internal_load_font,
14-
internal_load_font_at_index,
12+
internal_load_font,
13+
internal_load_font_at_index,
1514
internal_load_font_from_ll,
1615
Font,
1716
};
@@ -31,21 +30,21 @@ impl Drop for Sdl2TtfContext {
3130

3231
impl Sdl2TtfContext {
3332
/// Loads a font from the given file with the given size in points.
34-
pub fn load_font(&self, path: &Path, point_size: u16) -> SdlResult<Font> {
33+
pub fn load_font(&self, path: &Path, point_size: u16) -> Result<Font, String> {
3534
internal_load_font(path, point_size)
3635
}
37-
38-
/// Loads the font at the given index of the file, with the given
39-
/// size in points.
36+
37+
/// Loads the font at the given index of the file, with the given
38+
/// size in points.
4039
pub fn load_font_at_index(&self, path: &Path, index: u32, point_size: u16)
41-
-> SdlResult<Font> {
40+
-> Result<Font, String> {
4241
internal_load_font_at_index(path, index, point_size)
4342
}
44-
43+
4544
/// Loads a font from the given SDL2 rwops object with the given size in
4645
/// points.
47-
pub fn load_font_from_rwops(&self, rwops: RWops, point_size: u16)
48-
-> SdlResult<Font> {
46+
pub fn load_font_from_rwops(&self, rwops: RWops, point_size: u16)
47+
-> Result<Font, String> {
4948
let raw = unsafe {
5049
ffi::TTF_OpenFontRW(rwops.raw(), 0, point_size as c_int)
5150
};
@@ -55,13 +54,13 @@ impl Sdl2TtfContext {
5554
Ok(internal_load_font_from_ll(raw, true))
5655
}
5756
}
58-
57+
5958
/// Loads the font at the given index of the SDL2 rwops object with
6059
/// the given size in points.
61-
pub fn load_font_at_index_from_rwops(&self, rwops: RWops, index: u32,
62-
point_size: u16) -> SdlResult<Font> {
60+
pub fn load_font_at_index_from_rwops(&self, rwops: RWops, index: u32,
61+
point_size: u16) -> Result<Font, String> {
6362
let raw = unsafe {
64-
ffi::TTF_OpenFontIndexRW(rwops.raw(), 0, point_size as c_int,
63+
ffi::TTF_OpenFontIndexRW(rwops.raw(), 0, point_size as c_int,
6564
index as c_long)
6665
};
6766
if (raw as *mut ()).is_null() {
@@ -117,8 +116,8 @@ impl fmt::Display for InitError {
117116
}
118117
}
119118

120-
/// Initializes the truetype font API and returns a context manager which will
121-
/// clean up the library once it goes out of scope.
119+
/// Initializes the truetype font API and returns a context manager which will
120+
/// clean up the library once it goes out of scope.
122121
pub fn init() -> Result<Sdl2TtfContext, InitError> {
123122
unsafe {
124123
if ffi::TTF_WasInit() == 1 {
@@ -140,4 +139,4 @@ pub fn has_been_initialized() -> bool {
140139
unsafe {
141140
ffi::TTF_WasInit() == 1
142141
}
143-
}
142+
}

0 commit comments

Comments
 (0)