From 3bded769df1fbfdfa74984e295defff865db776f Mon Sep 17 00:00:00 2001 From: Jack Moffitt Date: Fri, 29 Mar 2013 17:57:43 -0600 Subject: [PATCH 1/3] Update to Rust 0.6 syntax. --- base.rs | 2 +- dummy.rs | 2 +- macos.rs | 11 +++++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/base.rs b/base.rs index 033954d..fe04457 100644 --- a/base.rs +++ b/base.rs @@ -2,7 +2,7 @@ use geom::size::Size2D; pub trait ShareContext { // Creates a new context for GL object sharing. - static fn new(size: Size2D) -> Self; + fn new(size: Size2D) -> Self; // Flushes the context. fn flush(&self); diff --git a/dummy.rs b/dummy.rs index f352aa1..6529454 100644 --- a/dummy.rs +++ b/dummy.rs @@ -8,7 +8,7 @@ struct DummyContext { } impl ShareContext for DummyContext { - static fn new(_size: Size2D) -> DummyContext { + fn new(_size: Size2D) -> DummyContext { DummyContext { unused: 0 } diff --git a/macos.rs b/macos.rs index 5079b1a..909bdc2 100644 --- a/macos.rs +++ b/macos.rs @@ -2,7 +2,6 @@ pub extern mod core_foundation; pub extern mod io_surface; pub extern mod opengles; -use mod platform::opengles::cgl; use mod platform::opengles::gl2; use core::cast::transmute; @@ -10,6 +9,7 @@ use core::ptr::{null, to_unsafe_ptr}; use geom::size::Size2D; use platform::io_surface::{IOSurface, kIOSurfaceBytesPerElement, kIOSurfaceBytesPerRow}; use platform::io_surface::{kIOSurfaceHeight, kIOSurfaceIsGlobal, kIOSurfaceWidth}; +use platform::io_surface::IOSurfaceMethods; use platform::opengles::cgl::{CGLChoosePixelFormat, CGLContextObj, CGLCreateContext}; use platform::opengles::cgl::{CGLLockContext, CGLSetCurrentContext, CGLTexImageIOSurface2D}; use platform::opengles::cgl::{kCGLNoError, kCGLPFACompliant, kCGLPFADoubleBuffer}; @@ -66,9 +66,8 @@ pub fn init_cgl() -> CGLContextObj { } -pub fn init_surface(+size: Size2D) -> IOSurface { +pub fn init_surface(size: Size2D) -> IOSurface { use platform::core_foundation::boolean::{CFBooleanRef, CFBoolean}; - use platform::core_foundation::number::{CFNumberRef, CFNumber}; use number = platform::core_foundation::number::CFNumber::new; use string = platform::core_foundation::string::CFString::wrap_extern; @@ -111,7 +110,7 @@ pub fn init_texture() -> GLuint { } // Assumes the texture is already bound via gl2::bind_texture(). -pub fn bind_surface_to_texture(context: &CGLContextObj, surface: &IOSurface, +size: Size2D) { +pub fn bind_surface_to_texture(context: &CGLContextObj, surface: &IOSurface, size: Size2D) { // FIXME: There should be safe wrappers for this. unsafe { let gl_error = CGLTexImageIOSurface2D(*context, @@ -134,7 +133,7 @@ pub fn bind_texture_to_framebuffer(texture: GLuint) { } impl ShareContext for MacContext { - static fn new(size: Size2D) -> MacContext { + fn new(size: Size2D) -> MacContext { // Initialize CGL. let context = init_cgl(); @@ -163,7 +162,7 @@ impl ShareContext for MacContext { gl2::finish(); } - fn id() -> int { + fn id(&self) -> int { self.surface.get_id() as int } } From 055562a049a4739502279e621af7db87f89c1140 Mon Sep 17 00:00:00 2001 From: Jack Moffitt Date: Mon, 1 Apr 2013 10:05:42 -0600 Subject: [PATCH 2/3] Remove fail_unless!. --- macos.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/macos.rs b/macos.rs index 909bdc2..519d60c 100644 --- a/macos.rs +++ b/macos.rs @@ -46,20 +46,20 @@ pub fn init_cgl() -> CGLContextObj { let gl_error = CGLChoosePixelFormat(transmute(&attributes[0]), to_unsafe_ptr(&pixel_format), to_unsafe_ptr(&pixel_format_count)); - fail_unless!(gl_error == kCGLNoError); + assert!(gl_error == kCGLNoError); // Create the context. let cgl_context = null(); let gl_error = CGLCreateContext(pixel_format, null(), to_unsafe_ptr(&cgl_context)); - fail_unless!(gl_error == kCGLNoError); + assert!(gl_error == kCGLNoError); // Set the context. let gl_error = CGLSetCurrentContext(cgl_context); - fail_unless!(gl_error == kCGLNoError); + assert!(gl_error == kCGLNoError); // Lock the context. let gl_error = CGLLockContext(cgl_context); - fail_unless!(gl_error == kCGLNoError); + assert!(gl_error == kCGLNoError); return cgl_context; } @@ -122,14 +122,14 @@ pub fn bind_surface_to_texture(context: &CGLContextObj, surface: &IOSurface, siz UNSIGNED_INT_8_8_8_8_REV, transmute(copy surface.obj), 0); - fail_unless!(gl_error == kCGLNoError); + assert!(gl_error == kCGLNoError); } } pub fn bind_texture_to_framebuffer(texture: GLuint) { gl2::bind_texture(TEXTURE_RECTANGLE_ARB, 0); gl2::framebuffer_texture_2d(FRAMEBUFFER, COLOR_ATTACHMENT0, TEXTURE_RECTANGLE_ARB, texture, 0); - fail_unless!(gl2::check_framebuffer_status(FRAMEBUFFER) == FRAMEBUFFER_COMPLETE); + assert!(gl2::check_framebuffer_status(FRAMEBUFFER) == FRAMEBUFFER_COMPLETE); } impl ShareContext for MacContext { From e0cf406a595e539e7e65c21a397b60be3427f7a7 Mon Sep 17 00:00:00 2001 From: Jack Moffitt Date: Mon, 1 Apr 2013 10:05:49 -0600 Subject: [PATCH 3/3] Remove unused imports. --- macos.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macos.rs b/macos.rs index 519d60c..d3c52a0 100644 --- a/macos.rs +++ b/macos.rs @@ -67,7 +67,7 @@ pub fn init_cgl() -> CGLContextObj { pub fn init_surface(size: Size2D) -> IOSurface { - use platform::core_foundation::boolean::{CFBooleanRef, CFBoolean}; + use platform::core_foundation::boolean::CFBoolean; use number = platform::core_foundation::number::CFNumber::new; use string = platform::core_foundation::string::CFString::wrap_extern;