Skip to content
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

Make examples be compiled correctly #39

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions src/examples/basic/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
15 changes: 7 additions & 8 deletions src/examples/triangle/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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 {
Expand All @@ -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
Expand All @@ -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
Expand Down