aboutsummaryrefslogtreecommitdiffstats
path: root/src/android/mod.rs
diff options
context:
space:
mode:
authorTomaka17 <pierre.krieger1708@gmail.com>2014-11-05 16:42:18 +0100
committerTomaka17 <pierre.krieger1708@gmail.com>2014-11-05 16:42:18 +0100
commit584bb3e7df751d55aad189eacd85b1cd6c5aa5c5 (patch)
tree91711433533faa6b44f62eb752d54c0a39129e12 /src/android/mod.rs
parent7ce851dad9102c28ee2fd372ed9fd62e73364da9 (diff)
downloadglutin-584bb3e7df751d55aad189eacd85b1cd6c5aa5c5.tar.gz
glutin-584bb3e7df751d55aad189eacd85b1cd6c5aa5c5.zip
Use a proper error type for window creation
Diffstat (limited to 'src/android/mod.rs')
-rw-r--r--src/android/mod.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/android/mod.rs b/src/android/mod.rs
index 7198553..4b1c7eb 100644
--- a/src/android/mod.rs
+++ b/src/android/mod.rs
@@ -2,7 +2,7 @@ extern crate android_glue;
extern crate native;
use libc;
-use {Event, WindowBuilder};
+use {CreationError, OsError, Event, WindowBuilder};
pub struct Window {
display: ffi::egl::types::EGLDisplay,
@@ -35,18 +35,18 @@ impl MonitorID {
}
impl Window {
- pub fn new(_builder: WindowBuilder) -> Result<Window, String> {
+ pub fn new(_builder: WindowBuilder) -> Result<Window, CreationError> {
use std::{mem, ptr};
let native_window = unsafe { android_glue::get_native_window() };
if native_window.is_null() {
- return Err(format!("Android's native window is null"));
+ return Err(OsError(format!("Android's native window is null")));
}
let display = unsafe {
let display = ffi::egl::GetDisplay(mem::transmute(ffi::egl::DEFAULT_DISPLAY));
if display.is_null() {
- return Err("No EGL display connection available".to_string());
+ return Err(OsError("No EGL display connection available".to_string()));
}
display
};
@@ -58,7 +58,7 @@ impl Window {
let mut minor: ffi::egl::types::EGLint = mem::uninitialized();
if ffi::egl::Initialize(display, &mut major, &mut minor) == 0 {
- return Err(format!("eglInitialize failed"))
+ return Err(OsError(format!("eglInitialize failed")))
}
(major, minor)
@@ -79,11 +79,11 @@ impl Window {
if ffi::egl::ChooseConfig(display, attribute_list.as_ptr(), &mut config, 1,
&mut num_config) == 0
{
- return Err(format!("eglChooseConfig failed"))
+ return Err(OsError(format!("eglChooseConfig failed")))
}
if num_config <= 0 {
- return Err(format!("eglChooseConfig returned no available config"))
+ return Err(OsError(format!("eglChooseConfig returned no available config")))
}
config
@@ -94,7 +94,7 @@ impl Window {
let context = unsafe {
let context = ffi::egl::CreateContext(display, config, ptr::null(), ptr::null());
if context.is_null() {
- return Err(format!("eglCreateContext failed"))
+ return Err(OsError(format!("eglCreateContext failed")))
}
context
};
@@ -104,7 +104,7 @@ impl Window {
let surface = unsafe {
let surface = ffi::egl::CreateWindowSurface(display, config, native_window, ptr::null());
if surface.is_null() {
- return Err(format!("eglCreateWindowSurface failed"))
+ return Err(OsError(format!("eglCreateWindowSurface failed")))
}
surface
};