From 5dc7fef49b4a82a778f2e85589001854ee1ce0f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9on=20van=20Velzen?= Date: Fri, 21 Feb 2014 20:59:33 +0100 Subject: [PATCH] Make examples be compiled correctly --- Makefile | 2 +- src/examples/basic/main.rs | 7 +++---- src/examples/triangle/main.rs | 15 +++++++-------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 14bf9928..3dfcdce8 100644 --- a/Makefile +++ b/Makefile @@ -53,7 +53,7 @@ examples: $(EXAMPLES:%=$(EXAMPLES_DIR)/%) $(EXAMPLES_DIR)/% : $(EXAMPLES:%=src/examples/%/main.rs) @mkdir -p $(EXAMPLES_DIR) - @echo $(RUSTC) -L/usr/lib -L/usr/local/lib -Llib --out-dir=$(EXAMPLES_DIR) -O src/examples/$*/main.rs + $(RUSTC) -L/usr/lib -L/usr/local/lib -o $(EXAMPLES_DIR)/$* -O -C link-args="-lglfw" src/examples/$*/main.rs gen: src/gen/main.rs @mkdir -p bin diff --git a/src/examples/basic/main.rs b/src/examples/basic/main.rs index 7cb50be6..0f142d5b 100644 --- a/src/examples/basic/main.rs +++ b/src/examples/basic/main.rs @@ -13,14 +13,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -extern crate glfw; +extern crate native; +extern crate glfw = "glfw-rs"; extern crate gl; -#[link_args="-lglfw"] extern {} - #[start] fn start(argc: int, argv: **u8) -> int { - std::rt::start_on_main_thread(argc, argv, main) + native::start(argc, argv, main) } fn main() { diff --git a/src/examples/triangle/main.rs b/src/examples/triangle/main.rs index 77940169..e0241c8e 100644 --- a/src/examples/triangle/main.rs +++ b/src/examples/triangle/main.rs @@ -16,7 +16,8 @@ #[feature(globs)]; #[feature(macro_rules)]; -extern crate glfw; +extern crate native; +extern crate glfw = "glfw-rs"; extern crate gl; use std::cast; @@ -27,8 +28,6 @@ use std::vec; use gl::types::*; -#[link_args="-lglfw"] extern {} - // Vertex data static VERTEX_DATA: [GLfloat, ..6] = [ 0.0, 0.5, @@ -53,7 +52,7 @@ static FS_SRC: &'static str = #[start] fn start(argc: int, argv: **u8) -> int { - std::rt::start_on_main_thread(argc, argv, main) + native::start(argc, argv, main) } fn compile_shader(src: &str, ty: GLenum) -> GLuint { @@ -72,8 +71,8 @@ fn compile_shader(src: &str, ty: GLenum) -> GLuint { let mut len = 0; gl::GetShaderiv(shader, gl::INFO_LOG_LENGTH, &mut len); let mut buf = vec::from_elem(len as uint - 1, 0u8); // subtract 1 to skip the trailing null character - gl::GetShaderInfoLog(shader, len, ptr::mut_null(), vec::raw::to_mut_ptr(buf) as *mut GLchar); - fail!(str::raw::from_utf8(buf)); + gl::GetShaderInfoLog(shader, len, ptr::mut_null(), buf.as_mut_ptr() as *mut GLchar); + fail!(str::raw::from_utf8(buf).to_owned()); } } shader @@ -94,8 +93,8 @@ fn link_program(vs: GLuint, fs: GLuint) -> GLuint { let mut len: GLint = 0; gl::GetProgramiv(program, gl::INFO_LOG_LENGTH, &mut len); let mut buf = vec::from_elem(len as uint - 1, 0u8); // subtract 1 to skip the trailing null character - gl::GetProgramInfoLog(program, len, ptr::mut_null(), vec::raw::to_mut_ptr(buf) as *mut GLchar); - fail!(str::raw::from_utf8(buf)); + gl::GetProgramInfoLog(program, len, ptr::mut_null(), buf.as_mut_ptr() as *mut GLchar); + fail!(str::raw::from_utf8(buf).to_owned()); } } program