mirror of
https://github.com/encounter/rust-sdl2.git
synced 2026-07-10 21:18:41 -07:00
Merge pull request #115 from AngryLawyer/strbuf-to-string
Updated to match latest changes to strings
This commit is contained in:
@@ -7,7 +7,7 @@ use std::vec::Vec;
|
||||
|
||||
struct ParseBranch {
|
||||
matches: Vec<u8>,
|
||||
result: Option<StrBuf>,
|
||||
result: Option<String>,
|
||||
children: Vec<ParseBranch>,
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ pub fn branchify(options: &[(&str, &str)], case_sensitive: bool) -> Vec<ParseBra
|
||||
fn go_down_moses(branch: &mut ParseBranch, mut chariter: Chars, result: &str, case_sensitive: bool) {
|
||||
match chariter.next() {
|
||||
Some(c) => {
|
||||
let first_case = if case_sensitive { c as u8 } else { c.to_ascii().to_upper().to_byte() };
|
||||
let first_case = if case_sensitive { c as u8 } else { c.to_ascii().to_uppercase().to_byte() };
|
||||
for next_branch in branch.children.mut_iter() {
|
||||
if next_branch.matches.as_slice()[0] == first_case {
|
||||
go_down_moses(next_branch, chariter, result, case_sensitive);
|
||||
@@ -38,7 +38,7 @@ pub fn branchify(options: &[(&str, &str)], case_sensitive: bool) -> Vec<ParseBra
|
||||
let mut subbranch = ParseBranch::new();
|
||||
subbranch.matches.push(first_case);
|
||||
if !case_sensitive {
|
||||
let second_case = c.to_ascii().to_lower().to_byte();
|
||||
let second_case = c.to_ascii().to_lowercase().to_byte();
|
||||
if first_case != second_case {
|
||||
subbranch.matches.push(second_case);
|
||||
}
|
||||
|
||||
@@ -45,11 +45,11 @@ fn Key(code: uint, ident: &'static str) -> Key {
|
||||
}
|
||||
|
||||
impl Key {
|
||||
fn ident(&self) -> StrBuf {
|
||||
fn ident(&self) -> String {
|
||||
self.ident.to_owned()
|
||||
}
|
||||
|
||||
fn padded_ident(&self) -> StrBuf {
|
||||
fn padded_ident(&self) -> String {
|
||||
self.ident().append(" ".repeat(unsafe { longest_ident } - self.ident().len()).as_slice())
|
||||
}
|
||||
|
||||
|
||||
@@ -44,11 +44,11 @@ fn ScanCode(code: uint, ident: &'static str) -> ScanCode {
|
||||
}
|
||||
|
||||
impl ScanCode {
|
||||
fn ident(&self) -> StrBuf {
|
||||
fn ident(&self) -> String {
|
||||
self.ident.to_owned()
|
||||
}
|
||||
|
||||
fn padded_ident(&self) -> StrBuf {
|
||||
fn padded_ident(&self) -> String {
|
||||
self.ident().append(" ".repeat(unsafe { longest_ident } - self.ident().len()).as_slice())
|
||||
}
|
||||
|
||||
|
||||
+11
-11
@@ -152,7 +152,7 @@ pub fn get_num_audio_drivers() -> int {
|
||||
unsafe { ll::SDL_GetNumAudioDrivers() as int }
|
||||
}
|
||||
|
||||
pub fn get_audio_driver(index: int) -> StrBuf {
|
||||
pub fn get_audio_driver(index: int) -> String {
|
||||
unsafe {
|
||||
let buf = ll::SDL_GetAudioDriver(index as c_int);
|
||||
CString::new(buf, false).as_str().unwrap().into_owned()
|
||||
@@ -163,14 +163,14 @@ pub fn get_num_audio_devices(iscapture: int) -> int {
|
||||
unsafe { ll::SDL_GetNumAudioDevices(iscapture as c_int) as int }
|
||||
}
|
||||
|
||||
pub fn get_audio_device_name(index: int, iscapture: int) -> StrBuf {
|
||||
pub fn get_audio_device_name(index: int, iscapture: int) -> String {
|
||||
unsafe {
|
||||
let buf = ll::SDL_GetAudioDeviceName(index as c_int, iscapture as c_int);
|
||||
CString::new(buf, false).as_str().unwrap().into_owned()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn audio_init(name: &str) -> Result<(), StrBuf> {
|
||||
pub fn audio_init(name: &str) -> Result<(), String> {
|
||||
let ret = name.with_c_str(|buf| {
|
||||
unsafe { ll::SDL_AudioInit(buf) }
|
||||
});
|
||||
@@ -185,7 +185,7 @@ pub fn audio_quit() {
|
||||
unsafe { ll::SDL_AudioQuit() }
|
||||
}
|
||||
|
||||
pub fn get_current_audio_driver() -> StrBuf {
|
||||
pub fn get_current_audio_driver() -> String {
|
||||
unsafe {
|
||||
let buf = ll::SDL_GetCurrentAudioDriver();
|
||||
CString::new(buf, false).as_str().unwrap().into_owned()
|
||||
@@ -221,13 +221,13 @@ extern "C" fn c_audio_callback(userdata: *c_void, stream: *uint8_t, len: c_int)
|
||||
|
||||
|
||||
impl<'a> AudioSpec<'a> {
|
||||
pub fn load_wav(path: &Path) -> Result<(AudioSpec, CVec<u8>), StrBuf> {
|
||||
pub fn load_wav(path: &Path) -> Result<(AudioSpec, CVec<u8>), String> {
|
||||
AudioSpec::load_wav_rw(&try!(RWops::from_file(path, "rb")))
|
||||
}
|
||||
|
||||
pub fn load_wav_rw(src: &RWops) -> Result<(AudioSpec, CVec<u8>), StrBuf> {
|
||||
pub fn load_wav_rw(src: &RWops) -> Result<(AudioSpec, CVec<u8>), String> {
|
||||
assert_eq!(mem::size_of::<AudioSpec>(), mem::size_of::<ll::SDL_AudioSpec>());
|
||||
let mut spec = unsafe { mem::uninit::<AudioSpec>() };
|
||||
let mut spec = unsafe { mem::uninitialized::<AudioSpec>() };
|
||||
let audio_buf = ptr::null::<u8>();
|
||||
let audio_len = 0u32;
|
||||
unsafe {
|
||||
@@ -261,9 +261,9 @@ impl AudioDevice {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn open(device: Option<&str>, iscapture: int, spec: &AudioSpec) -> Result<(AudioDevice, AudioSpec), StrBuf> {
|
||||
pub fn open(device: Option<&str>, iscapture: int, spec: &AudioSpec) -> Result<(AudioDevice, AudioSpec), String> {
|
||||
//! SDL_OpenAudioDevice
|
||||
let obtained = unsafe { mem::uninit::<AudioSpec>() };
|
||||
let obtained = unsafe { mem::uninitialized::<AudioSpec>() };
|
||||
unsafe {
|
||||
let device_c_str = match device {
|
||||
None => ptr::null(),
|
||||
@@ -334,7 +334,7 @@ impl Drop for AudioCVT {
|
||||
|
||||
impl AudioCVT {
|
||||
pub fn new(src_format: AudioFormat, src_channels: u8, src_rate: int,
|
||||
dst_format: AudioFormat, dst_channels: u8, dst_rate: int) -> Result<AudioCVT, StrBuf> {
|
||||
dst_format: AudioFormat, dst_channels: u8, dst_rate: int) -> Result<AudioCVT, String> {
|
||||
unsafe {
|
||||
let c_cvt_p = libc::malloc(mem::size_of::<ll::SDL_AudioCVT>() as size_t) as *mut ll::SDL_AudioCVT;
|
||||
let ret = ll::SDL_BuildAudioCVT(c_cvt_p,
|
||||
@@ -348,7 +348,7 @@ impl AudioCVT {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn convert(&self, src: CVec<u8>) -> Result<CVec<u8>, StrBuf> {
|
||||
pub fn convert(&self, src: CVec<u8>) -> Result<CVec<u8>, String> {
|
||||
//! Convert audio data to a desired audio format.
|
||||
|
||||
unsafe {
|
||||
|
||||
+6
-6
@@ -563,9 +563,9 @@ pub enum Event {
|
||||
KeyDownEvent(uint, video::Window, KeyCode, ScanCode, Mod),
|
||||
KeyUpEvent(uint, video::Window, KeyCode, ScanCode, Mod),
|
||||
/// (timestamp, window, text, start, length)
|
||||
TextEditingEvent(uint, video::Window, StrBuf, int, int),
|
||||
TextEditingEvent(uint, video::Window, String, int, int),
|
||||
/// (timestamp, window, text)
|
||||
TextInputEvent(uint, video::Window, StrBuf),
|
||||
TextInputEvent(uint, video::Window, String),
|
||||
|
||||
/// (timestamp, window, which, [MouseState], x, y, xrel, yrel)
|
||||
MouseMotionEvent(uint, video::Window, uint, MouseState, int, int,
|
||||
@@ -614,7 +614,7 @@ pub enum Event {
|
||||
ClipboardUpdateEvent(uint),
|
||||
|
||||
/// (timestamp, filename)
|
||||
DropFileEvent(uint, StrBuf),
|
||||
DropFileEvent(uint, String),
|
||||
|
||||
/// (timestamp, Window, type, code)
|
||||
UserEvent(uint, video::Window, uint, int),
|
||||
@@ -1062,7 +1062,7 @@ pub fn poll_event() -> Event {
|
||||
}
|
||||
|
||||
/// Wait indefinitely for the next available event.
|
||||
pub fn wait_event() -> Result<Event, StrBuf> {
|
||||
pub fn wait_event() -> Result<Event, String> {
|
||||
let raw = null_event();
|
||||
let success = unsafe { ll::SDL_WaitEvent(&raw) == 1 as c_int };
|
||||
|
||||
@@ -1071,7 +1071,7 @@ pub fn wait_event() -> Result<Event, StrBuf> {
|
||||
}
|
||||
|
||||
/// Wait until the specified timeout (in milliseconds) for the next available event.
|
||||
pub fn wait_event_timeout(timeout: int) -> Result<Event, StrBuf> {
|
||||
pub fn wait_event_timeout(timeout: int) -> Result<Event, String> {
|
||||
let raw = null_event();
|
||||
let success = unsafe { ll::SDL_WaitEventTimeout(&raw, timeout as c_int) ==
|
||||
1 as c_int };
|
||||
@@ -1133,7 +1133,7 @@ pub fn register_events(num: int) -> Option<uint> {
|
||||
}
|
||||
|
||||
/// add an event to the event queue
|
||||
pub fn push_event(event: Event) -> Result<(), StrBuf> {
|
||||
pub fn push_event(event: Event) -> Result<(), String> {
|
||||
match event.to_ll() {
|
||||
Some(raw_event) => {
|
||||
let ok = unsafe { ll::SDL_PushEvent(&raw_event) == 1 };
|
||||
|
||||
@@ -114,7 +114,7 @@ pub fn get_scancode_from_key(key: KeyCode) -> ScanCode {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_scancode_name(scancode: ScanCode) -> StrBuf {
|
||||
pub fn get_scancode_name(scancode: ScanCode) -> String {
|
||||
unsafe {
|
||||
str::raw::from_c_str(ll::SDL_GetScancodeName(scancode.code() as u32))
|
||||
}
|
||||
@@ -128,7 +128,7 @@ pub fn get_scancode_from_name(name: &str) -> ScanCode {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_key_name(key: KeyCode) -> StrBuf {
|
||||
pub fn get_key_name(key: KeyCode) -> String {
|
||||
unsafe {
|
||||
str::raw::from_c_str(ll::SDL_GetKeyName(key.code()))
|
||||
}
|
||||
|
||||
+3
-3
@@ -87,7 +87,7 @@ impl Drop for Cursor {
|
||||
}
|
||||
|
||||
impl Cursor {
|
||||
pub fn new(data: &[u8], mask: &[u8], width: int, height: int, hot_x: int, hot_y: int) -> Result<Cursor, StrBuf> {
|
||||
pub fn new(data: &[u8], mask: &[u8], width: int, height: int, hot_x: int, hot_y: int) -> Result<Cursor, String> {
|
||||
unsafe {
|
||||
let raw = ll::SDL_CreateCursor(data.as_ptr(),
|
||||
mask.as_ptr(),
|
||||
@@ -103,7 +103,7 @@ impl Cursor {
|
||||
}
|
||||
|
||||
// TODO: figure out how to pass Surface in here correctly
|
||||
pub fn from_surface(surface: &surface::Surface, hot_x: int, hot_y: int) -> Result<Cursor, StrBuf> {
|
||||
pub fn from_surface(surface: &surface::Surface, hot_x: int, hot_y: int) -> Result<Cursor, String> {
|
||||
unsafe {
|
||||
let raw = ll::SDL_CreateColorCursor(surface.raw(), hot_x as i32,
|
||||
hot_y as i32);
|
||||
@@ -116,7 +116,7 @@ impl Cursor {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_system(cursor: SystemCursor) -> Result<Cursor, StrBuf> {
|
||||
pub fn from_system(cursor: SystemCursor) -> Result<Cursor, String> {
|
||||
unsafe {
|
||||
let raw = ll::SDL_CreateSystemCursor(cursor as u32);
|
||||
|
||||
|
||||
+39
-39
@@ -158,7 +158,7 @@ bitflags!(flags RendererFlags: u32 {
|
||||
|
||||
#[deriving(Eq)]
|
||||
pub struct RendererInfo {
|
||||
pub name: StrBuf,
|
||||
pub name: String,
|
||||
pub flags: RendererFlags,
|
||||
pub texture_formats: Vec<pixels::PixelFormatFlag>,
|
||||
pub max_texture_width: int,
|
||||
@@ -219,7 +219,7 @@ impl<S> Drop for Renderer<S> {
|
||||
}
|
||||
|
||||
impl Renderer<Window> {
|
||||
pub fn from_window(window: Window, index: RenderDriverIndex, renderer_flags: RendererFlags) -> Result<Renderer<Window>, StrBuf> {
|
||||
pub fn from_window(window: Window, index: RenderDriverIndex, renderer_flags: RendererFlags) -> Result<Renderer<Window>, String> {
|
||||
let index = match index {
|
||||
DriverAuto => -1,
|
||||
DriverIndex(x) => x
|
||||
@@ -236,7 +236,7 @@ impl Renderer<Window> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_with_window(width: int, height: int, window_flags: video::WindowFlags) -> Result<Renderer<Window>, StrBuf> {
|
||||
pub fn new_with_window(width: int, height: int, window_flags: video::WindowFlags) -> Result<Renderer<Window>, String> {
|
||||
let raw_window: *video::ll::SDL_Window = ptr::null();
|
||||
let raw_renderer: *ll::SDL_Renderer = ptr::null();
|
||||
let result = unsafe { ll::SDL_CreateWindowAndRenderer(width as c_int, height as c_int, window_flags.bits(), &raw_window, &raw_renderer) == 0};
|
||||
@@ -254,7 +254,7 @@ impl Renderer<Window> {
|
||||
}
|
||||
|
||||
impl Renderer<Surface> {
|
||||
pub fn from_surface(surface: surface::Surface) -> Result<Renderer<Surface>, StrBuf> {
|
||||
pub fn from_surface(surface: surface::Surface) -> Result<Renderer<Surface>, String> {
|
||||
let result = unsafe { ll::SDL_CreateSoftwareRenderer(surface.raw()) };
|
||||
if result == ptr::null() {
|
||||
Ok(Renderer {
|
||||
@@ -284,7 +284,7 @@ impl<S> Renderer<S> {
|
||||
#[inline]
|
||||
pub fn owned(&self) -> bool { self.owned }
|
||||
|
||||
pub fn set_draw_color(&self, color: pixels::Color) -> Result<(), StrBuf> {
|
||||
pub fn set_draw_color(&self, color: pixels::Color) -> Result<(), String> {
|
||||
let ret = match color {
|
||||
pixels::RGB(r, g, b) => {
|
||||
unsafe { ll::SDL_SetRenderDrawColor(self.raw, r, g, b, 255) }
|
||||
@@ -297,7 +297,7 @@ impl<S> Renderer<S> {
|
||||
else { Err(get_error()) }
|
||||
}
|
||||
|
||||
pub fn get_draw_color(&self) -> Result<pixels::Color, StrBuf> {
|
||||
pub fn get_draw_color(&self) -> Result<pixels::Color, String> {
|
||||
let r: u8 = 0;
|
||||
let g: u8 = 0;
|
||||
let b: u8 = 0;
|
||||
@@ -310,7 +310,7 @@ impl<S> Renderer<S> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clear(&self) -> Result<(), StrBuf> {
|
||||
pub fn clear(&self) -> Result<(), String> {
|
||||
let ret = unsafe { ll::SDL_RenderClear(self.raw) };
|
||||
if ret == 0 { Ok(()) }
|
||||
else { Err(get_error()) }
|
||||
@@ -320,7 +320,7 @@ impl<S> Renderer<S> {
|
||||
unsafe { ll::SDL_RenderPresent(self.raw) }
|
||||
}
|
||||
|
||||
pub fn get_output_size(&self) -> Result<(int, int), StrBuf> {
|
||||
pub fn get_output_size(&self) -> Result<(int, int), String> {
|
||||
let width: c_int = 0;
|
||||
let height: c_int = 0;
|
||||
|
||||
@@ -333,7 +333,7 @@ impl<S> Renderer<S> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create_texture(&self, format: pixels::PixelFormatFlag, access: TextureAccess, width: int, height: int) -> Result<Texture, StrBuf> {
|
||||
pub fn create_texture(&self, format: pixels::PixelFormatFlag, access: TextureAccess, width: int, height: int) -> Result<Texture, String> {
|
||||
let result = unsafe { ll::SDL_CreateTexture(self.raw, format as uint32_t, access as c_int, width as c_int, height as c_int) };
|
||||
if result == ptr::null() {
|
||||
Err(get_error())
|
||||
@@ -342,7 +342,7 @@ impl<S> Renderer<S> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create_texture_from_surface(&self, surface: &surface::Surface) -> Result<Texture, StrBuf> {
|
||||
pub fn create_texture_from_surface(&self, surface: &surface::Surface) -> Result<Texture, String> {
|
||||
let result = unsafe { ll::SDL_CreateTextureFromSurface(self.raw, surface.raw()) };
|
||||
if result == ptr::null() {
|
||||
Err(get_error())
|
||||
@@ -355,7 +355,7 @@ impl<S> Renderer<S> {
|
||||
unsafe { ll::SDL_RenderTargetSupported(self.raw) == 1 }
|
||||
}
|
||||
|
||||
pub fn set_render_target(&self, texture: Option<&Texture>) -> Result<(), StrBuf> {
|
||||
pub fn set_render_target(&self, texture: Option<&Texture>) -> Result<(), String> {
|
||||
unsafe {
|
||||
let actual_texture = match texture {
|
||||
Some(texture) => mem::transmute(texture.raw),
|
||||
@@ -369,7 +369,7 @@ impl<S> Renderer<S> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_render_target(&self) -> Result<Texture, StrBuf> {
|
||||
pub fn get_render_target(&self) -> Result<Texture, String> {
|
||||
let raw = unsafe { ll::SDL_GetRenderTarget(self.raw) };
|
||||
|
||||
if raw == ptr::null() {
|
||||
@@ -382,7 +382,7 @@ impl<S> Renderer<S> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_logical_size(&self, width: int, height: int) -> Result<(), StrBuf> {
|
||||
pub fn set_logical_size(&self, width: int, height: int) -> Result<(), String> {
|
||||
let ret = unsafe { ll::SDL_RenderSetLogicalSize(self.raw, width as c_int, height as c_int) };
|
||||
|
||||
if ret == 0 { Ok(()) }
|
||||
@@ -399,7 +399,7 @@ impl<S> Renderer<S> {
|
||||
(width as int, height as int)
|
||||
}
|
||||
|
||||
pub fn set_viewport(&self, rect: &Rect) -> Result<(), StrBuf> {
|
||||
pub fn set_viewport(&self, rect: &Rect) -> Result<(), String> {
|
||||
let ret = unsafe { ll::SDL_RenderSetViewport(self.raw, rect) };
|
||||
|
||||
if ret == 0 { Ok(()) }
|
||||
@@ -417,7 +417,7 @@ impl<S> Renderer<S> {
|
||||
rect
|
||||
}
|
||||
|
||||
pub fn set_clip_rect(&self, rect: &Rect) -> Result<(), StrBuf> {
|
||||
pub fn set_clip_rect(&self, rect: &Rect) -> Result<(), String> {
|
||||
let ret = unsafe { ll::SDL_RenderSetClipRect(self.raw, rect) };
|
||||
|
||||
if ret == 0 { Ok(()) }
|
||||
@@ -435,7 +435,7 @@ impl<S> Renderer<S> {
|
||||
rect
|
||||
}
|
||||
|
||||
pub fn set_scale(&self, scale_x: f64, scale_y: f64) -> Result<(), StrBuf> {
|
||||
pub fn set_scale(&self, scale_x: f64, scale_y: f64) -> Result<(), String> {
|
||||
let ret = unsafe { ll::SDL_RenderSetScale(self.raw, scale_x as c_float, scale_y as c_float) };
|
||||
|
||||
if ret == 0 { Ok(()) }
|
||||
@@ -449,14 +449,14 @@ impl<S> Renderer<S> {
|
||||
(scale_x as f64, scale_y as f64)
|
||||
}
|
||||
|
||||
pub fn draw_point(&self, point: Point) -> Result<(), StrBuf> {
|
||||
pub fn draw_point(&self, point: Point) -> Result<(), String> {
|
||||
let ret = unsafe { ll::SDL_RenderDrawPoint(self.raw, point.x, point.y) };
|
||||
|
||||
if ret == 0 { Ok(()) }
|
||||
else { Err(get_error()) }
|
||||
}
|
||||
|
||||
pub fn draw_points(&self, points: &[Point]) -> Result<(), StrBuf> {
|
||||
pub fn draw_points(&self, points: &[Point]) -> Result<(), String> {
|
||||
let ret = unsafe {
|
||||
ll::SDL_RenderDrawPoints(self.raw, mem::transmute(points.as_ptr()), points.len() as c_int)
|
||||
};
|
||||
@@ -465,14 +465,14 @@ impl<S> Renderer<S> {
|
||||
else { Err(get_error()) }
|
||||
}
|
||||
|
||||
pub fn draw_line(&self, start: Point, end: Point) -> Result<(), StrBuf> {
|
||||
pub fn draw_line(&self, start: Point, end: Point) -> Result<(), String> {
|
||||
let ret = unsafe { ll::SDL_RenderDrawLine(self.raw, start.x, start.y, end.x, end.y) };
|
||||
|
||||
if ret == 0 { Ok(()) }
|
||||
else { Err(get_error()) }
|
||||
}
|
||||
|
||||
pub fn draw_lines(&self, points: &[Point]) -> Result<(), StrBuf> {
|
||||
pub fn draw_lines(&self, points: &[Point]) -> Result<(), String> {
|
||||
let ret = unsafe {
|
||||
ll::SDL_RenderDrawLines(self.raw, mem::transmute(points.as_ptr()), points.len() as c_int)
|
||||
};
|
||||
@@ -481,14 +481,14 @@ impl<S> Renderer<S> {
|
||||
else { Err(get_error()) }
|
||||
}
|
||||
|
||||
pub fn draw_rect(&self, rect: &Rect) -> Result<(), StrBuf> {
|
||||
pub fn draw_rect(&self, rect: &Rect) -> Result<(), String> {
|
||||
let ret = unsafe { ll::SDL_RenderDrawRect(self.raw, rect) };
|
||||
|
||||
if ret == 0 { Ok(()) }
|
||||
else { Err(get_error()) }
|
||||
}
|
||||
|
||||
pub fn draw_rects(&self, rects: &[Rect]) -> Result<(), StrBuf> {
|
||||
pub fn draw_rects(&self, rects: &[Rect]) -> Result<(), String> {
|
||||
let ret = unsafe {
|
||||
ll::SDL_RenderDrawRects(self.raw, mem::transmute(rects.as_ptr()), rects.len() as c_int)
|
||||
};
|
||||
@@ -497,14 +497,14 @@ impl<S> Renderer<S> {
|
||||
else { Err(get_error()) }
|
||||
}
|
||||
|
||||
pub fn fill_rect(&self, rect: &Rect) -> Result<(), StrBuf> {
|
||||
pub fn fill_rect(&self, rect: &Rect) -> Result<(), String> {
|
||||
let ret = unsafe { ll::SDL_RenderFillRect(self.raw, rect) };
|
||||
|
||||
if ret == 0 { Ok(()) }
|
||||
else { Err(get_error()) }
|
||||
}
|
||||
|
||||
pub fn fill_rects(&self, rects: &[Rect]) -> Result<(), StrBuf> {
|
||||
pub fn fill_rects(&self, rects: &[Rect]) -> Result<(), String> {
|
||||
let ret = unsafe {
|
||||
ll::SDL_RenderFillRects(self.raw, mem::transmute(rects.as_ptr()), rects.len() as c_int)
|
||||
};
|
||||
@@ -513,7 +513,7 @@ impl<S> Renderer<S> {
|
||||
else { Err(get_error()) }
|
||||
}
|
||||
|
||||
pub fn copy(&self, texture: &Texture, src: Option<Rect>, dst: Option<Rect>) -> Result<(), StrBuf> {
|
||||
pub fn copy(&self, texture: &Texture, src: Option<Rect>, dst: Option<Rect>) -> Result<(), String> {
|
||||
let ret = unsafe {
|
||||
ll::SDL_RenderCopy(
|
||||
self.raw,
|
||||
@@ -534,7 +534,7 @@ impl<S> Renderer<S> {
|
||||
}
|
||||
|
||||
//TODO: Check whether RendererFlip is supposed to be combinable
|
||||
pub fn copy_ex(&self, texture: &Texture, src: Option<Rect>, dst: Option<Rect>, angle: f64, center: Option<Point>, flip: RendererFlip) -> Result<(), StrBuf> {
|
||||
pub fn copy_ex(&self, texture: &Texture, src: Option<Rect>, dst: Option<Rect>, angle: f64, center: Option<Point>, flip: RendererFlip) -> Result<(), String> {
|
||||
let ret = unsafe {
|
||||
ll::SDL_RenderCopyEx(
|
||||
self.raw,
|
||||
@@ -560,7 +560,7 @@ impl<S> Renderer<S> {
|
||||
else { Err(get_error()) }
|
||||
}
|
||||
|
||||
pub fn read_pixels(&self, rect: Option<Rect>, format: pixels::PixelFormatFlag) -> Result<CVec<u8>, StrBuf> {
|
||||
pub fn read_pixels(&self, rect: Option<Rect>, format: pixels::PixelFormatFlag) -> Result<CVec<u8>, String> {
|
||||
unsafe {
|
||||
let (actual_rect, w, h) = match rect {
|
||||
Some(rect) => (mem::transmute(&rect), rect.w as uint, rect.h as uint),
|
||||
@@ -609,7 +609,7 @@ impl Drop for Texture {
|
||||
|
||||
impl Texture {
|
||||
|
||||
pub fn query(&self) -> Result<TextureQuery, StrBuf> {
|
||||
pub fn query(&self) -> Result<TextureQuery, String> {
|
||||
let format: uint32_t = 0;
|
||||
let access: c_int = 0;
|
||||
let width: c_int = 0;
|
||||
@@ -628,14 +628,14 @@ impl Texture {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_color_mod(&self, red: u8, green: u8, blue: u8) -> Result<(), StrBuf> {
|
||||
pub fn set_color_mod(&self, red: u8, green: u8, blue: u8) -> Result<(), String> {
|
||||
let ret = unsafe { ll::SDL_SetTextureColorMod(self.raw, red, green, blue) };
|
||||
|
||||
if ret == 0 { Ok(()) }
|
||||
else { Err(get_error()) }
|
||||
}
|
||||
|
||||
pub fn get_color_mod(&self) -> Result<(u8, u8, u8), StrBuf> {
|
||||
pub fn get_color_mod(&self) -> Result<(u8, u8, u8), String> {
|
||||
let r = 0;
|
||||
let g = 0;
|
||||
let b = 0;
|
||||
@@ -648,14 +648,14 @@ impl Texture {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_alpha_mod(&self, alpha: u8) -> Result<(), StrBuf> {
|
||||
pub fn set_alpha_mod(&self, alpha: u8) -> Result<(), String> {
|
||||
let ret = unsafe { ll::SDL_SetTextureAlphaMod(self.raw, alpha) };
|
||||
|
||||
if ret == 0 { Ok(()) }
|
||||
else { Err(get_error()) }
|
||||
}
|
||||
|
||||
pub fn get_alpha_mod(&self) -> Result<u8, StrBuf> {
|
||||
pub fn get_alpha_mod(&self) -> Result<u8, String> {
|
||||
let alpha = 0;
|
||||
let result = unsafe { ll::SDL_GetTextureAlphaMod(self.raw, &alpha) == 0 };
|
||||
|
||||
@@ -666,14 +666,14 @@ impl Texture {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_blend_mode(&self, blend: BlendMode) -> Result<(), StrBuf> {
|
||||
pub fn set_blend_mode(&self, blend: BlendMode) -> Result<(), String> {
|
||||
let ret = unsafe { ll::SDL_SetTextureBlendMode(self.raw, FromPrimitive::from_i64(blend as i64).unwrap()) };
|
||||
|
||||
if ret == 0 { Ok(()) }
|
||||
else { Err(get_error()) }
|
||||
}
|
||||
|
||||
pub fn get_blend_mode(&self) -> Result<BlendMode, StrBuf> {
|
||||
pub fn get_blend_mode(&self) -> Result<BlendMode, String> {
|
||||
let blend: i64 = 0;
|
||||
let result = unsafe { ll::SDL_GetTextureBlendMode(self.raw, &FromPrimitive::from_i64(blend as i64).unwrap()) == 0 };
|
||||
if result {
|
||||
@@ -683,7 +683,7 @@ impl Texture {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update(&self, rect: Option<Rect>, pixel_data: &[u8], pitch: int) -> Result<(), StrBuf> {
|
||||
pub fn update(&self, rect: Option<Rect>, pixel_data: &[u8], pitch: int) -> Result<(), String> {
|
||||
let ret = unsafe {
|
||||
let actual_rect = match rect {
|
||||
Some(rect) => mem::transmute(&rect),
|
||||
@@ -697,7 +697,7 @@ impl Texture {
|
||||
else { Err(get_error()) }
|
||||
}
|
||||
|
||||
pub fn lock(&self, rect: Option<Rect>) -> Result<CVec<u8>, StrBuf> {
|
||||
pub fn lock(&self, rect: Option<Rect>) -> Result<CVec<u8>, String> {
|
||||
let q = try!(self.query());
|
||||
unsafe {
|
||||
let actual_rect = match rect {
|
||||
@@ -721,7 +721,7 @@ impl Texture {
|
||||
unsafe { ll::SDL_UnlockTexture(self.raw) }
|
||||
}
|
||||
|
||||
pub fn gl_bind_texture(&self) -> Result<(f64, f64), StrBuf> {
|
||||
pub fn gl_bind_texture(&self) -> Result<(f64, f64), String> {
|
||||
let texw: c_float = 0.0;
|
||||
let texh: c_float = 0.0;
|
||||
|
||||
@@ -753,7 +753,7 @@ impl Texture {
|
||||
}
|
||||
|
||||
|
||||
pub fn get_num_render_drivers() -> Result<int, StrBuf> {
|
||||
pub fn get_num_render_drivers() -> Result<int, String> {
|
||||
let result = unsafe { ll::SDL_GetNumRenderDrivers() };
|
||||
if result > 0 {
|
||||
Ok(result as int)
|
||||
@@ -762,7 +762,7 @@ pub fn get_num_render_drivers() -> Result<int, StrBuf> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_render_driver_info(index: int) -> Result<RendererInfo, StrBuf> {
|
||||
pub fn get_render_driver_info(index: int) -> Result<RendererInfo, String> {
|
||||
let out = ll::SDL_RendererInfo {
|
||||
name: ptr::null(),
|
||||
flags: 0,
|
||||
|
||||
+2
-2
@@ -52,7 +52,7 @@ impl_owned_accessors!(RWops, close_on_drop)
|
||||
|
||||
/// A structure that provides an abstract interface to stream I/O.
|
||||
impl RWops {
|
||||
pub fn from_file(path: &Path, mode: &str) -> Result<RWops, StrBuf> {
|
||||
pub fn from_file(path: &Path, mode: &str) -> Result<RWops, String> {
|
||||
let raw = unsafe {
|
||||
ll::SDL_RWFromFile(path.to_c_str().unwrap(), mode.to_c_str().unwrap())
|
||||
};
|
||||
@@ -60,7 +60,7 @@ impl RWops {
|
||||
else { Ok(RWops{raw: raw, close_on_drop: true}) }
|
||||
}
|
||||
|
||||
pub fn from_bytes(buf: &[u8]) -> Result<RWops, StrBuf> {
|
||||
pub fn from_bytes(buf: &[u8]) -> Result<RWops, String> {
|
||||
let raw = unsafe {
|
||||
ll::SDL_RWFromConstMem(buf.as_ptr() as *c_void, buf.len() as c_int)
|
||||
};
|
||||
|
||||
+1
-1
@@ -111,7 +111,7 @@ pub fn was_inited(flags: InitFlag) -> InitFlag {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_error() -> StrBuf {
|
||||
pub fn get_error() -> String {
|
||||
unsafe {
|
||||
let cstr = ll::SDL_GetError();
|
||||
|
||||
|
||||
+6
-6
@@ -105,7 +105,7 @@ impl_raw_constructor!(Surface -> Surface (raw: *ll::SDL_Surface, owned: bool))
|
||||
|
||||
impl Surface {
|
||||
pub fn new(surface_flags: SurfaceFlag, width: int, height: int, bpp: int,
|
||||
rmask: u32, gmask: u32, bmask: u32, amask: u32) -> Result<Surface, StrBuf> {
|
||||
rmask: u32, gmask: u32, bmask: u32, amask: u32) -> Result<Surface, String> {
|
||||
unsafe {
|
||||
let raw = ll::SDL_CreateRGBSurface(surface_flags.bits(), width as c_int, height as c_int, bpp as c_int,
|
||||
rmask, gmask, bmask, amask);
|
||||
@@ -166,7 +166,7 @@ impl Surface {
|
||||
unsafe { ll::SDL_UnlockSurface(self.raw); }
|
||||
}
|
||||
|
||||
pub fn from_bmp(path: &Path) -> Result<Surface, StrBuf> {
|
||||
pub fn from_bmp(path: &Path) -> Result<Surface, String> {
|
||||
let raw = unsafe {
|
||||
ll::SDL_LoadBMP_RW(try!(rwops::RWops::from_file(path, "rb")).raw(), 0)
|
||||
};
|
||||
@@ -175,7 +175,7 @@ impl Surface {
|
||||
else { Ok(Surface{raw: raw, owned: true}) }
|
||||
}
|
||||
|
||||
pub fn save_bmp(&self, path: &Path) -> Result<(), StrBuf> {
|
||||
pub fn save_bmp(&self, path: &Path) -> Result<(), String> {
|
||||
let ret = unsafe {
|
||||
ll::SDL_SaveBMP_RW(self.raw, try!(rwops::RWops::from_file(path, "rb")).raw(), 0)
|
||||
};
|
||||
@@ -201,7 +201,7 @@ impl Surface {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_color_key(&self, enable: bool, color: pixels::Color) -> Result<(), StrBuf> {
|
||||
pub fn set_color_key(&self, enable: bool, color: pixels::Color) -> Result<(), String> {
|
||||
let key = color.to_u32(&self.get_pixel_format());
|
||||
let result = unsafe {
|
||||
ll::SDL_SetColorKey(self.raw, ::std::bool::to_bit(enable), key)
|
||||
@@ -213,7 +213,7 @@ impl Surface {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_color_key(&self) -> Result<pixels::Color, StrBuf> {
|
||||
pub fn get_color_key(&self) -> Result<pixels::Color, String> {
|
||||
let key: u32 = 0;
|
||||
let result = unsafe {
|
||||
ll::SDL_GetColorKey(self.raw, &key)
|
||||
@@ -237,7 +237,7 @@ impl Surface {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_color_mod(&self) -> Result<pixels::Color, StrBuf> {
|
||||
pub fn get_color_mod(&self) -> Result<pixels::Color, String> {
|
||||
let r: u8 = 0;
|
||||
let g: u8 = 0;
|
||||
let b: u8 = 0;
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ pub fn get_version() -> Version {
|
||||
}
|
||||
|
||||
/// Get the code revision of SDL that is linked against your program.
|
||||
pub fn get_revision() -> StrBuf {
|
||||
pub fn get_revision() -> String {
|
||||
unsafe {
|
||||
let ret = ll::SDL_GetRevision();
|
||||
CString::new(ret, false).as_str().unwrap().into_owned()
|
||||
|
||||
+23
-23
@@ -343,7 +343,7 @@ impl Drop for Window {
|
||||
}
|
||||
|
||||
impl Window {
|
||||
pub fn new(title: &str, x: WindowPos, y: WindowPos, width: int, height: int, window_flags: WindowFlags) -> Result<Window, StrBuf> {
|
||||
pub fn new(title: &str, x: WindowPos, y: WindowPos, width: int, height: int, window_flags: WindowFlags) -> Result<Window, String> {
|
||||
unsafe {
|
||||
let raw = title.with_c_str(|buff| {
|
||||
ll::SDL_CreateWindow(
|
||||
@@ -364,7 +364,7 @@ impl Window {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_id(id: u32) -> Result<Window, StrBuf> {
|
||||
pub fn from_id(id: u32) -> Result<Window, String> {
|
||||
let raw = unsafe { ll::SDL_GetWindowFromID(id) };
|
||||
if raw == ptr::null() {
|
||||
Err(get_error())
|
||||
@@ -373,7 +373,7 @@ impl Window {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_display_index(&self) -> Result<int, StrBuf> {
|
||||
pub fn get_display_index(&self) -> Result<int, String> {
|
||||
let result = unsafe { ll::SDL_GetWindowDisplayIndex(self.raw) };
|
||||
if result < 0 {
|
||||
return Err(get_error())
|
||||
@@ -394,7 +394,7 @@ impl Window {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_display_mode(&self, display_mode: &DisplayMode) -> Result<DisplayMode, StrBuf> {
|
||||
pub fn get_display_mode(&self, display_mode: &DisplayMode) -> Result<DisplayMode, String> {
|
||||
let dm = empty_sdl_display_mode();
|
||||
|
||||
let result = unsafe {
|
||||
@@ -432,7 +432,7 @@ impl Window {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_title(&self) -> StrBuf {
|
||||
pub fn get_title(&self) -> String {
|
||||
unsafe {
|
||||
let cstr = ll::SDL_GetWindowTitle(self.raw);
|
||||
str::raw::from_c_str(mem::transmute_copy(&cstr))
|
||||
@@ -522,7 +522,7 @@ impl Window {
|
||||
unsafe { ll::SDL_SetWindowFullscreen(self.raw, fullscreen_type as uint32_t) == 0 }
|
||||
}
|
||||
|
||||
pub fn get_surface(&self) -> Result<Surface, StrBuf> {
|
||||
pub fn get_surface(&self) -> Result<Surface, String> {
|
||||
let raw = unsafe { ll::SDL_GetWindowSurface(self.raw) };
|
||||
|
||||
if raw == ptr::null() {
|
||||
@@ -574,7 +574,7 @@ impl Window {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_gamma_ramp(&self) -> Result<(Vec<u16>, Vec<u16>, Vec<u16>), StrBuf> {
|
||||
pub fn get_gamma_ramp(&self) -> Result<(Vec<u16>, Vec<u16>, Vec<u16>), String> {
|
||||
let red: Vec<u16> = Vec::with_capacity(256);
|
||||
let green: Vec<u16> = Vec::with_capacity(256);
|
||||
let blue: Vec<u16> = Vec::with_capacity(256);
|
||||
@@ -586,7 +586,7 @@ impl Window {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn gl_create_context(&self) -> Result<GLContext, StrBuf> {
|
||||
pub fn gl_create_context(&self) -> Result<GLContext, String> {
|
||||
let result = unsafe { ll::SDL_GL_CreateContext(self.raw) };
|
||||
if result == ptr::null() {
|
||||
Err(get_error())
|
||||
@@ -604,7 +604,7 @@ impl Window {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_num_video_drivers() -> Result<int, StrBuf> {
|
||||
pub fn get_num_video_drivers() -> Result<int, String> {
|
||||
let result = unsafe { ll::SDL_GetNumVideoDrivers() };
|
||||
if result < 0 {
|
||||
Err(get_error())
|
||||
@@ -613,7 +613,7 @@ pub fn get_num_video_drivers() -> Result<int, StrBuf> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_video_driver(id: int) -> StrBuf {
|
||||
pub fn get_video_driver(id: int) -> String {
|
||||
unsafe {
|
||||
let cstr = ll::SDL_GetVideoDriver(id as c_int);
|
||||
str::raw::from_c_str(mem::transmute_copy(&cstr))
|
||||
@@ -630,14 +630,14 @@ pub fn video_quit() {
|
||||
unsafe { ll::SDL_VideoQuit() }
|
||||
}
|
||||
|
||||
pub fn get_current_video_driver() -> StrBuf {
|
||||
pub fn get_current_video_driver() -> String {
|
||||
unsafe {
|
||||
let cstr = ll::SDL_GetCurrentVideoDriver();
|
||||
str::raw::from_c_str(mem::transmute_copy(&cstr))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_num_video_displays() -> Result<int, StrBuf> {
|
||||
pub fn get_num_video_displays() -> Result<int, String> {
|
||||
let result = unsafe { ll::SDL_GetNumVideoDisplays() };
|
||||
if result < 0 {
|
||||
Err(get_error())
|
||||
@@ -646,14 +646,14 @@ pub fn get_num_video_displays() -> Result<int, StrBuf> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_display_name(display_index: int) -> StrBuf {
|
||||
pub fn get_display_name(display_index: int) -> String {
|
||||
unsafe {
|
||||
let cstr = ll::SDL_GetDisplayName(display_index as c_int);
|
||||
str::raw::from_c_str(mem::transmute_copy(&cstr))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_display_bounds(display_index: int) -> Result<Rect, StrBuf> {
|
||||
pub fn get_display_bounds(display_index: int) -> Result<Rect, String> {
|
||||
let out: Rect = Rect::new(0, 0, 0, 0);
|
||||
let result = unsafe { ll::SDL_GetDisplayBounds(display_index as c_int, &out) == 0 };
|
||||
|
||||
@@ -664,7 +664,7 @@ pub fn get_display_bounds(display_index: int) -> Result<Rect, StrBuf> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_num_display_modes(display_index: int) -> Result<int, StrBuf> {
|
||||
pub fn get_num_display_modes(display_index: int) -> Result<int, String> {
|
||||
let result = unsafe { ll::SDL_GetNumDisplayModes(display_index as c_int) };
|
||||
if result < 0 {
|
||||
Err(get_error())
|
||||
@@ -673,7 +673,7 @@ pub fn get_num_display_modes(display_index: int) -> Result<int, StrBuf> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_display_mode(display_index: int, mode_index: int) -> Result<DisplayMode, StrBuf> {
|
||||
pub fn get_display_mode(display_index: int, mode_index: int) -> Result<DisplayMode, String> {
|
||||
let dm = empty_sdl_display_mode();
|
||||
let result = unsafe { ll::SDL_GetDisplayMode(display_index as c_int, mode_index as c_int, &dm) == 0};
|
||||
|
||||
@@ -684,7 +684,7 @@ pub fn get_display_mode(display_index: int, mode_index: int) -> Result<DisplayMo
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_desktop_display_mode(display_index: int) -> Result<DisplayMode, StrBuf> {
|
||||
pub fn get_desktop_display_mode(display_index: int) -> Result<DisplayMode, String> {
|
||||
let dm = empty_sdl_display_mode();
|
||||
let result = unsafe { ll::SDL_GetDesktopDisplayMode(display_index as c_int, &dm) == 0};
|
||||
|
||||
@@ -695,7 +695,7 @@ pub fn get_desktop_display_mode(display_index: int) -> Result<DisplayMode, StrBu
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_current_display_mode(display_index: int) -> Result<DisplayMode, StrBuf> {
|
||||
pub fn get_current_display_mode(display_index: int) -> Result<DisplayMode, String> {
|
||||
let dm = empty_sdl_display_mode();
|
||||
let result = unsafe { ll::SDL_GetCurrentDisplayMode(display_index as c_int, &dm) == 0};
|
||||
|
||||
@@ -706,7 +706,7 @@ pub fn get_current_display_mode(display_index: int) -> Result<DisplayMode, StrBu
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_closest_display_mode(display_index: int, mode: &DisplayMode) -> Result<DisplayMode, StrBuf> {
|
||||
pub fn get_closest_display_mode(display_index: int, mode: &DisplayMode) -> Result<DisplayMode, String> {
|
||||
let input = mode.to_ll();
|
||||
let out = empty_sdl_display_mode();
|
||||
|
||||
@@ -731,7 +731,7 @@ pub fn disable_screen_saver() {
|
||||
unsafe { ll::SDL_DisableScreenSaver() }
|
||||
}
|
||||
|
||||
pub fn gl_load_library(path: &str) -> Result<(), StrBuf> {
|
||||
pub fn gl_load_library(path: &str) -> Result<(), String> {
|
||||
unsafe {
|
||||
path.with_c_str(|path| {
|
||||
if ll::SDL_GL_LoadLibrary(path) == 0 {
|
||||
@@ -765,7 +765,7 @@ pub fn gl_set_attribute(attr: GLAttr, value: int) -> bool {
|
||||
unsafe { ll::SDL_GL_SetAttribute(FromPrimitive::from_u64(attr as u64).unwrap(), value as c_int) == 0 }
|
||||
}
|
||||
|
||||
pub fn gl_get_attribute(attr: GLAttr) -> Result<int, StrBuf> {
|
||||
pub fn gl_get_attribute(attr: GLAttr) -> Result<int, String> {
|
||||
let out: c_int = 0;
|
||||
|
||||
let result = unsafe { ll::SDL_GL_GetAttribute(FromPrimitive::from_u64(attr as u64).unwrap(), &out) } == 0;
|
||||
@@ -776,7 +776,7 @@ pub fn gl_get_attribute(attr: GLAttr) -> Result<int, StrBuf> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn gl_get_current_window() -> Result<Window, StrBuf> {
|
||||
pub fn gl_get_current_window() -> Result<Window, String> {
|
||||
let raw = unsafe { ll::SDL_GL_GetCurrentWindow() };
|
||||
if raw == ptr::null() {
|
||||
Err(get_error())
|
||||
@@ -785,7 +785,7 @@ pub fn gl_get_current_window() -> Result<Window, StrBuf> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn gl_get_current_context() -> Result<GLContext, StrBuf> {
|
||||
pub fn gl_get_current_context() -> Result<GLContext, String> {
|
||||
let raw = unsafe { ll::SDL_GL_GetCurrentContext() };
|
||||
if raw == ptr::null() {
|
||||
Err(get_error())
|
||||
|
||||
Reference in New Issue
Block a user