Skip to content

Commit e889820

Browse files
committed
Merge pull request #15 from Ryman/rustup
Rustup
2 parents 04afa66 + 1fd0b3b commit e889820

File tree

18 files changed

+108
-80
lines changed

18 files changed

+108
-80
lines changed

src/game/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ path = "../wad"
2424

2525
[dependencies.time]
2626
git = "https://github.com/rust-lang/time"
27+
28+
[dependencies]
29+
log = "*"

src/game/level.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,10 @@ const ATLAS_UNIT: uint = 1;
101101

102102

103103
macro_rules! offset_of(
104-
($T:ty, $m:ident) =>
105-
(unsafe { (&((*(0 as *const $T)).$m)) as *const _ as *const c_void })
106-
)
104+
($T:ty, $m:ident) => (
105+
unsafe { (&((*(0 as *const $T)).$m)) as *const _ as *const c_void }
106+
)
107+
);
107108

108109

109110
pub fn build_level(shader_loader: &ShaderLoader,
@@ -370,7 +371,7 @@ impl<'a> VboBuilder<'a> {
370371
None => continue
371372
};
372373

373-
let dist = |l: &Line2f| l.signed_distance(&point);
374+
let dist = |&: l: &Line2f| l.signed_distance(&point);
374375

375376
// The intersection point must lie both within the BSP volume
376377
// and the segs volume.

src/game/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,20 +229,20 @@ pub fn run() {
229229
.map(|r| {
230230
let v = r[].splitn(1, 'x').collect::<Vec<&str>>();
231231
if v.len() != 2 { None } else { Some(v) }
232-
.and_then(|v| from_str::<uint>(v[0]).map(|v0| (v0, v[1])))
233-
.and_then(|(v0, s)| from_str::<uint>(s).map(|v1| (v0, v1)))
232+
.and_then(|v| v[0].parse().map(|v0| (v0, v[1])))
233+
.and_then(|(v0, s)| s.parse().map(|v1| (v0, v1)))
234234
.expect("Invalid format for resolution, please use WIDTHxHEIGHT.")
235235
})
236236
.unwrap_or((1280, 720));
237237
let level_index = matches
238238
.opt_str("l")
239-
.map(|l| from_str::<uint>(l[])
240-
.expect("Invalid value for --level. Expected integer."))
239+
.map(|l| l[].parse()
240+
.expect("Invalid value for --level. Expected integer."))
241241
.unwrap_or(0);
242242
let fov = matches
243243
.opt_str("f")
244-
.map(|f| from_str::<f32>(f[])
245-
.expect("Invalid value for --fov. Expected float."))
244+
.map(|f| f[].parse()
245+
.expect("Invalid value for --fov. Expected float."))
246246
.unwrap_or(65.0);
247247

248248
if matches.opt_present("h") {

src/gfx/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ path = "../math"
1515

1616
[dependencies.base]
1717
path = "../base"
18+
19+
[dependencies]
20+
log = "*"

src/gfx/shader.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ impl ShaderLoader {
2525
}
2626

2727
pub fn load(&self, name: &str) -> Result<Shader, String> {
28-
let name = name.to_string();
29-
let frag_src = self.version_directive +
30-
try!(read_utf8_file(&self.root_path.join(name + ".frag")))[];
31-
let vert_src = self.version_directive +
32-
try!(read_utf8_file(&self.root_path.join(name + ".vert")))[];
28+
debug!("Loading shader: {}", name);
29+
let frag_src = self.version_directive.clone() +
30+
try!(read_utf8_file(&self.root_path.join(name.to_string() + ".frag")))[];
31+
let vert_src = self.version_directive.clone() +
32+
try!(read_utf8_file(&self.root_path.join(name.to_string() + ".vert")))[];
33+
debug!("Shader '{}' loaded successfully", name);
3334
Shader::new_from_source(vert_src[], frag_src[])
3435
}
3536
}

src/gl/Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22
name = "gl"
33
version = "0.0.1"
44
authors = ["Cristian Cobzarenco <cristi.cobzarenco@gmail.com>"]
5+
build = "build.rs"
56

67
[lib]
78
name = "gl"
89
path = "lib.rs"
910

10-
[dependencies.gl_generator]
11+
[build-dependencies.gl_generator]
12+
git = "https://github.com/bjz/gl-rs"
13+
14+
[dependencies.gl_common]
1115
git = "https://github.com/bjz/gl-rs"
1216

src/gl/build.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
extern crate gl_generator;
2+
extern crate khronos_api;
3+
4+
use std::os;
5+
use std::io::File;
6+
7+
fn main() {
8+
let dest = Path::new(os::getenv("OUT_DIR").unwrap());
9+
let mut file = File::create(&dest.join("gl_bindings.rs")).unwrap();
10+
11+
let version = if cfg!(target_os = "linux") { "3.0" } else { "3.3" };
12+
13+
gl_generator::generate_bindings(gl_generator::GlobalGenerator,
14+
gl_generator::registry::Ns::Gl,
15+
khronos_api::GL_XML,
16+
vec![],
17+
version,
18+
"core",
19+
&mut file).unwrap();
20+
}

src/gl/lib.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,7 @@
77
#[phase(plugin)]
88
extern crate gl_generator;
99

10-
#[cfg(target_os = "linux")]
11-
generate_gl_bindings! {
12-
api: "gl",
13-
profile: "core",
14-
version: "3.0",
15-
generator: "global",
16-
}
17-
18-
#[cfg(not(target_os = "linux"))]
19-
generate_gl_bindings! {
20-
api: "gl",
21-
profile: "core",
22-
version: "3.3",
23-
generator: "global",
24-
}
10+
include!(concat!(env!("OUT_DIR"), "/gl_bindings.rs"));
2511

2612
#[cfg(target_os = "linux")]
2713
pub mod platform {
@@ -77,7 +63,7 @@ macro_rules! check_gl(
7763
::gl::check::check_gl_helper(file!(), line!(), stringify!($func));
7864
ret
7965
});
80-
)
66+
);
8167

8268
#[macro_export]
8369
macro_rules! check_gl_unsafe (
@@ -86,4 +72,4 @@ macro_rules! check_gl_unsafe (
8672
::gl::check::check_gl_helper(file!(), line!(), stringify!($func));
8773
ret
8874
}});
89-
)
75+
);

src/math/mat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ impl fmt::Show for Mat4 {
129129
}
130130

131131
impl Mul<Mat4, Mat4> for Mat4 {
132-
fn mul(&self, rhs: &Mat4) -> Mat4 {
132+
fn mul(self, rhs: Mat4) -> Mat4 {
133133
let l = &self.data;
134134
let r = &rhs.data;
135135
Mat4 { data:[

src/math/numvec.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ pub type Vec2f = Vec2<f32>;
77
pub type Vec3f = Vec3<f32>;
88
pub type Vec4f = Vec4<f32>;
99

10-
pub trait Numvec<T : Float + FloatMath>
11-
: Add<Self, Self> + Mul<T, Self> + Div<T, Self> {
10+
pub trait Numvec<T : Float + FloatMath + Copy>
11+
: Add<Self, Self> + Mul<T, Self> + Div<T, Self> + Copy {
1212
fn dot(&self, other : &Self) -> T;
1313

1414
fn squared_norm(&self) -> T { self.dot(self) }
@@ -56,27 +56,27 @@ impl<T : Float + FloatMath> Numvec<T> for Vec2<T> {
5656
}
5757
}
5858
impl<T : Float + FloatMath> Add<Vec2<T>, Vec2<T>> for Vec2<T> {
59-
fn add(&self, rhs : &Vec2<T>) -> Vec2<T> {
59+
fn add(self, rhs : Vec2<T>) -> Vec2<T> {
6060
return Vec2::new(self.x + rhs.x, self.y + rhs.y);
6161
}
6262
}
6363
impl<T : Float + FloatMath> Sub<Vec2<T>, Vec2<T>> for Vec2<T> {
64-
fn sub(&self, rhs : &Vec2<T>) -> Vec2<T> {
64+
fn sub(self, rhs : Vec2<T>) -> Vec2<T> {
6565
return Vec2::new(self.x - rhs.x, self.y - rhs.y);
6666
}
6767
}
6868
impl<T : Float + FloatMath> Mul<T, Vec2<T>> for Vec2<T> {
69-
fn mul(&self, rhs : &T) -> Vec2<T> {
70-
return Vec2::new(self.x * *rhs, self.y * *rhs);
69+
fn mul(self, rhs : T) -> Vec2<T> {
70+
return Vec2::new(self.x * rhs, self.y * rhs);
7171
}
7272
}
7373
impl<T : Float + FloatMath> Div<T, Vec2<T>> for Vec2<T> {
74-
fn div(&self, rhs : &T) -> Vec2<T> {
75-
return Vec2::new(self.x / *rhs, self.y / *rhs);
74+
fn div(self, rhs : T) -> Vec2<T> {
75+
return Vec2::new(self.x / rhs, self.y / rhs);
7676
}
7777
}
7878
impl<T : Float + FloatMath> Neg<Vec2<T>> for Vec2<T> {
79-
fn neg(&self) -> Vec2<T> {
79+
fn neg(self) -> Vec2<T> {
8080
return Vec2::new(-self.x, -self.y);
8181
}
8282
}
@@ -115,27 +115,27 @@ impl<T : Float + FloatMath> Numvec<T> for Vec3<T> {
115115
}
116116
}
117117
impl<T : Float + FloatMath> Add<Vec3<T>, Vec3<T>> for Vec3<T> {
118-
fn add(&self, rhs : &Vec3<T>) -> Vec3<T> {
118+
fn add(self, rhs : Vec3<T>) -> Vec3<T> {
119119
return Vec3::new(self.x + rhs.x, self.y + rhs.y, self.z + rhs.z);
120120
}
121121
}
122122
impl<T : Float + FloatMath> Sub<Vec3<T>, Vec3<T>> for Vec3<T> {
123-
fn sub(&self, rhs : &Vec3<T>) -> Vec3<T> {
123+
fn sub(self, rhs : Vec3<T>) -> Vec3<T> {
124124
return Vec3::new(self.x - rhs.x, self.y - rhs.y, self.z - rhs.z);
125125
}
126126
}
127127
impl<T : Float + FloatMath> Mul<T, Vec3<T>> for Vec3<T> {
128-
fn mul(&self, rhs : &T) -> Vec3<T> {
129-
return Vec3::new(self.x * *rhs, self.y * *rhs, self.z * *rhs);
128+
fn mul(self, rhs : T) -> Vec3<T> {
129+
return Vec3::new(self.x * rhs, self.y * rhs, self.z * rhs);
130130
}
131131
}
132132
impl<T : Float + FloatMath> Div<T, Vec3<T>> for Vec3<T> {
133-
fn div(&self, rhs : &T) -> Vec3<T> {
134-
return Vec3::new(self.x / *rhs, self.y / *rhs, self.z / *rhs);
133+
fn div(self, rhs : T) -> Vec3<T> {
134+
return Vec3::new(self.x / rhs, self.y / rhs, self.z / rhs);
135135
}
136136
}
137137
impl<T : Float + FloatMath> Neg<Vec3<T>> for Vec3<T> {
138-
fn neg(&self) -> Vec3<T> {
138+
fn neg(self) -> Vec3<T> {
139139
return Vec3::new(-self.x, -self.y, -self.z);
140140
}
141141
}
@@ -186,31 +186,31 @@ impl<T : Float + FloatMath> Numvec<T> for Vec4<T> {
186186
}
187187
}
188188
impl<T : Float + FloatMath> Add<Vec4<T>, Vec4<T>> for Vec4<T> {
189-
fn add(&self, rhs : &Vec4<T>) -> Vec4<T> {
189+
fn add(self, rhs : Vec4<T>) -> Vec4<T> {
190190
return Vec4::new(self.x + rhs.x, self.y + rhs.y, self.z + rhs.z,
191191
self.w + rhs.w);
192192
}
193193
}
194194
impl<T : Float + FloatMath> Sub<Vec4<T>, Vec4<T>> for Vec4<T> {
195-
fn sub(&self, rhs : &Vec4<T>) -> Vec4<T> {
195+
fn sub(self, rhs : Vec4<T>) -> Vec4<T> {
196196
return Vec4::new(self.x - rhs.x, self.y - rhs.y, self.z - rhs.z,
197197
self.w - rhs.w);
198198
}
199199
}
200200
impl<T : Float + FloatMath> Mul<T, Vec4<T>> for Vec4<T> {
201-
fn mul(&self, rhs : &T) -> Vec4<T> {
202-
return Vec4::new(self.x * *rhs, self.y * *rhs, self.z * *rhs,
203-
self.w * *rhs);
201+
fn mul(self, rhs : T) -> Vec4<T> {
202+
return Vec4::new(self.x * rhs, self.y * rhs, self.z * rhs,
203+
self.w * rhs);
204204
}
205205
}
206206
impl<T : Float + FloatMath> Div<T, Vec4<T>> for Vec4<T> {
207-
fn div(&self, rhs : &T) -> Vec4<T> {
208-
return Vec4::new(self.x / *rhs, self.y / *rhs, self.z / *rhs,
209-
self.w / *rhs);
207+
fn div(self, rhs : T) -> Vec4<T> {
208+
return Vec4::new(self.x / rhs, self.y / rhs, self.z / rhs,
209+
self.w / rhs);
210210
}
211211
}
212212
impl<T : Float + FloatMath> Neg<Vec4<T>> for Vec4<T> {
213-
fn neg(&self) -> Vec4<T> {
213+
fn neg(self) -> Vec4<T> {
214214
return Vec4::new(-self.x, -self.y, -self.z, -self.w);
215215
}
216216
}

src/wad/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ git = "https://github.com/alexcrichton/toml-rs"
2424

2525
[dependencies.time]
2626
git = "https://github.com/rust-lang/time"
27+
28+
[dependencies]
29+
rustc-serialize = "*"
30+
log = "*"
31+
regex = "*"

src/wad/image.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub struct Image {
1717

1818
macro_rules! io_try(
1919
($e:expr) => (try!($e.map_err(|e| String::from_str(e.desc))))
20-
)
20+
);
2121

2222

2323
impl Image {

src/wad/level.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ impl Level {
5757
let sectors = sectors;
5858

5959
info!("Loaded level '{}':", name);
60-
info!(" {:4} things", things.len())
61-
info!(" {:4} linedefs", linedefs.len())
62-
info!(" {:4} sidedefs", sidedefs.len())
63-
info!(" {:4} vertices", vertices.len())
64-
info!(" {:4} segs", segs.len())
65-
info!(" {:4} subsectors", subsectors.len())
66-
info!(" {:4} nodes", nodes.len())
67-
info!(" {:4} sectors", sectors.len())
60+
info!(" {:4} things", things.len());
61+
info!(" {:4} linedefs", linedefs.len());
62+
info!(" {:4} sidedefs", sidedefs.len());
63+
info!(" {:4} vertices", vertices.len());
64+
info!(" {:4} segs", segs.len());
65+
info!(" {:4} subsectors", subsectors.len());
66+
info!(" {:4} nodes", nodes.len());
67+
info!(" {:4} sectors", sectors.len());
6868

6969
Level {
7070
things: things,

src/wad/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ extern crate math;
1212
extern crate log;
1313
#[phase(plugin, link)]
1414
extern crate regex;
15-
extern crate serialize;
15+
extern crate "rustc-serialize" as rustc_serialize;
1616
extern crate time;
1717
extern crate toml;
1818

src/wad/meta.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
use base;
22
use regex::Regex;
3-
use serialize;
3+
use rustc_serialize;
44
use super::name::WadName;
55
use super::types::ThingType;
66
use toml;
77
use toml::{DecodeError, ApplicationError, ExpectedField, ExpectedType,
88
ExpectedMapElement, ExpectedMapKey, NoEnumVariants, NilTooLong};
99

1010

11-
#[deriving(Decodable, Encodable)]
11+
#[deriving(RustcDecodable, RustcEncodable)]
1212
pub struct SkyMetadata {
1313
pub texture_name: WadName,
1414
pub level_pattern: String,
1515
pub tiled_band_size: f32,
1616
}
1717

1818

19-
#[deriving(Decodable, Encodable)]
19+
#[deriving(RustcDecodable, RustcEncodable)]
2020
pub struct AnimationMetadata {
2121
pub flats: Vec<Vec<WadName>>,
2222
pub walls: Vec<Vec<WadName>>,
2323
}
2424

2525

26-
#[deriving(Decodable, Encodable)]
26+
#[deriving(RustcDecodable, RustcEncodable)]
2727
pub struct ThingMetadata {
2828
pub thing_type: ThingType,
2929
pub sprite: WadName,
3030
pub sequence: String,
3131
}
3232

3333

34-
#[deriving(Decodable, Encodable)]
34+
#[deriving(RustcDecodable, RustcEncodable)]
3535
pub struct ThingDirectoryMetadata {
3636
pub decoration: Vec<ThingMetadata>
3737
}
3838

3939

40-
#[deriving(Decodable, Encodable)]
40+
#[deriving(RustcDecodable, RustcEncodable)]
4141
pub struct WadMetadata {
4242
pub sky: Vec<SkyMetadata>,
4343
pub animations: AnimationMetadata,
@@ -52,7 +52,7 @@ impl WadMetadata {
5252
pub fn from_text(text: &str) -> Result<WadMetadata, String> {
5353
let mut parser = toml::Parser::new(text);
5454
match parser.parse() {
55-
Some(value) => serialize::Decodable::decode(
55+
Some(value) => rustc_serialize::Decodable::decode(
5656
&mut toml::Decoder::new(toml::Value::Table(value)))
5757
.map_err(|e| show_decode_err(e)),
5858
None => Err(format!("Error parsing WadMetadata from TOML: {}",

0 commit comments

Comments
 (0)