Code Monkey home page Code Monkey logo

rust-sdl's Introduction

Rust-SDL

Bindings for SDL in Rust

Overview

Rust-SDL is a library for talking to SDL from Rust. Low-level C components are wrapped in Rust code to make them more idiomatic and abstract away inappropriate manual memory management.

In addition, it provides optional APIs to a number of common SDL extension libraries.

Rust-SDL uses the MIT license.

Requirements

Optional

Installation

Clone this repo, run cargo build. To see an example of the code in use, rustc -L ./target src/sdl-demo/main.rs.

SDL_mixer and SDL_image are available through separate packages, from within their respective directories, run cargo build to build. They depend on the main SDL library.

When things go wrong

Rust, and Rust-SDL, are both still heavily in development, and you may run into teething issues when using this. Before panicking, check that you're using the latest Master branch of Rust, check that you've updated Rust-SDL to the latest version, and run cargo clean. If that fails, please let us know on the issue tracker.

rust-sdl's People

Contributors

angrylawyer avatar brson avatar catamorphism avatar dpc avatar eskatrem avatar frozencow avatar fzzzy avatar itdaniher avatar jdm avatar lgrz avatar lifthrasiir avatar lstat avatar luqmana avatar mikezaby avatar mmeyerho avatar mstewartgallus avatar mvdnes avatar nikomatsakis avatar noj avatar pcwalton avatar pdovy avatar phillipwalters avatar radarsat1 avatar robn avatar rossmeikleham avatar rossmurray avatar sfackler avatar theneikos avatar xirdus avatar z0w0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rust-sdl's Issues

Linking issues with rustpkg and OSX

Hey, so rust-sdl isn't compiling with rustpkg on OSX. It builds fine using the Makefile. But with rustpkg I'm getting some linking issues.

error: linking with `cc` failed with code 1
note: cc arguments: -L/usr/local/lib/rustc/x86_64-apple-darwin/lib -m64 -o /Users/stephenbelanger/.rustpkg/work/sdl-7f49efacedcf6bba-0.3.0/lib/libsdl-34b7eedb9132850-0.3.0.dylib /Users/stephenbelanger/.rustpkg/work/sdl-7f49efacedcf6bba-0.3.0/lib/sdl.o -L/usr/local/lib/rustc/x86_64-apple-darwin/lib -lcore-c3ca5d77d81b46c1-0.6 -L/usr/local/lib/rustc/x86_64-apple-darwin/lib -lstd-4782a756585a81-0.6 -L. -lSDLXmain -framework AppKit -framework Foundation -dynamiclib -Wl,-install_name,@rpath/libsdl-34b7eedb9132850-0.3.0.dylib -Wl,-no_compact_unwind -lmorestack -lrustrt -Wl,-rpath,@executable_path/../../../../../../usr/local/lib/rustc/x86_64-apple-darwin/lib -Wl,-rpath,/usr/local/lib/rustc/x86_64-apple-darwin/lib -Wl,-rpath,/usr/local/Cellar/rust/0.6/lib/rustc/x86_64-apple-darwin/lib

When I run sdl-config --libs I get -L/usr/local/lib -lSDLmain -lSDL -Wl,-framework,Cocoa. It seems to coincide with the $(SDLXMAIN) block in the Makefile. I'm not sure how to replicate that in pkg.rs though.

dealing with macports' placement of libraries

MacPorts puts libraries in /opt/local/lib, which causes problems in two places: first, in the configure file, /opt/local/lib isn't one of the places it looks for the .dylib files. That's easy enough to hack in. Slightly more problematically, I couldn't figure out how to add "-L /opt/local/lib" into the linker flags. I finally just jammed it directly into the linker flags source in sdl.rs, using

// Setup linking for all targets.
#[cfg(target_os="macos")]
mod mac {
    #[cfg(mac_framework)]
    #[link_args="-framework SDL"]
    extern {}

    #[cfg(mac_dylib)]
    #[link_args="-L /opt/local/lib -lSDL"]
    extern {}
}

... but that's completely gross. I didn't see a way to do computation on the right-hand-side of the #[link_args=...] attribute, though I didn't spend more than 5 minutes digging.

event::get_key_state() returns bogus Key values

I tried to use fmt!("%?", sdl::event::get_key_state()) and it failed with

rust: task failed at 'enum value matched no variant', [...]/rust/src/libcore/repr.rs:628

The first (Key, bool) pair at fault seems to be the one where the Key tag is represented by 10, which isn't filtered by wrap_key() yet isn't defined as a variant of the enum, so I guess it's not filtering the right ranges.

Shipping rust-sdl on cargo

I am quite sure you already know, but crates.io is now available !
It is time to make this awesome crate easily available to the world, why not adding it to the list right now ?

Some of the functions can return Null, possibly

So, while writing a tutorial for playing with Rust, I realised that I was manually handling a Null that I probably shouldn't be:

let surface = sdl::video::set_video_mode(640, 480, 31, ~[sdl::video::HWSurface], ~[sdl::video::DoubleBuf]);

if surface == ptr::null() {
    return result::Err(#fmt("Unable to create surface: %s", sdl::get_error()));
}

I think there are other SDL functions that might be able to spit out nulls. Nulls are pretty against the whole ethos of Rust, so should we be intercepting these in the SDL library, and instead return an option type/result type? I'm happy to tackle this if so. The only downside I could feasibly see is that it stops being as much of a direct mapping to SDL.

cannot link against rust-sdl

No code can link to Rust-SDL. Even the demo doesn't work correctly.

ross@ubuntu:~/Downloads/rust-sdl$ make demos
rustc -L . demo/demo.rc -o demos
error: linking with `cc` failed with code 1
note: cc arguments: -L/usr/local/lib/rustc/i686-unknown-linux-gnu/lib -m32 -o demos demos.o -L/usr/local/lib/rustc/i686-unknown-linux-gnu/lib -lstd-6c65cf4b443341b1-0.7 -L. -lsdl-95460b1b072257-0.3.0 -lrustrt -lrt -lpthread -lSDL_image -lSDL_mixer -lSDL -L. -lrt -ldl -lm -lmorestack -lrustrt -Wl,-rpath,$ORIGIN/../../../../usr/local/lib/rustc/i686-unknown-linux-gnu/lib -Wl,-rpath,$ORIGIN/. -Wl,-rpath,/usr/local/lib/rustc/i686-unknown-linux-gnu/lib -Wl,-rpath,/home/ross/Downloads/rust-sdl/.
note: demos.o: In function `video::main::anon::expr_fn_3673':
demos.rc:(.text+0x13b): undefined reference to `sdl::init::_4b172b18e7d8114b::_030'
demos.rc:(.text+0x980): undefined reference to `sdl::quit::_722cebd03df97be::_030'
collect2: ld returned 1 exit status

error: aborting due to previous error
make: *** [demos] Error 101

This is because in src/sdl.rc it says "mod sdl" instead of "pub mod sdl"

OSX linking error when making demo: "Undefined symbol __SDL_main "

$ make demos
rustc -L . demo/demo.rc -o demos
demo/video.rs:3:4: 3:11 warning: unused import [-W unused-imports (default)]
demo/video.rs:3 use std::rt;
                    ^~~~~~~
error: linking with `cc` failed with code 1
note: cc arguments: -L/usr/local/rust-master/lib/rustc/x86_64-apple-darwin/lib -m64 -o demos demos.o -L/usr/local/rust-master/lib/rustc/x86_64-apple-darwin/lib -lstd-6c65cf4b443341b1-0.8-pre -L. -lsdl-95460b1b072257-0.3.0 -lSDL_image -lSDL_mixer -lSDL -lSDLmain -framework Foundation -framework AppKit -L. -L/Users/james/Code/rust-sdl/.rust -L/Users/james/Code/rust-sdl -Wl,-no_compact_unwind -lmorestack -lrustrt -Wl,-rpath,@executable_path/../../../../usr/local/rust-master/lib/rustc/x86_64-apple-darwin/lib -Wl,-rpath,@executable_path/. -Wl,-rpath,/usr/local/rust-master/lib/rustc/x86_64-apple-darwin/lib -Wl,-rpath,/Users/james/Code/rust-sdl/.
note: ld: warning: directory not found for option '-L/Users/james/Code/rust-sdl/.rust'
Undefined symbols for architecture x86_64:
  "_SDL_main", referenced from:
      -[SDLMain applicationDidFinishLaunching:] in libSDLmain.a(SDLMain.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: aborting due to previous error
make: *** [demos] Error 101

src/video.rs:5:4: 5:22 error: unresolved import: there is no `RngUtil` in `std::rand`

On Rust master branch, get the following error after a fresh clone:

$ ./configure

$ make
rustc --cfg image --cfg mixer src/sdl.rc -o libsdl.dummy
src/video.rs:5:4: 5:22 error: unresolved import: there is no `RngUtil` in `std::rand`
src/video.rs:5 use std::rand::RngUtil;
                   ^~~~~~~~~~~~~~~~~~
src/video.rs:5:4: 5:22 error: failed to resolve import `std::rand::RngUtil`
src/video.rs:5 use std::rand::RngUtil;
                   ^~~~~~~~~~~~~~~~~~
error: aborting due to 2 previous errors
make: *** [libsdl.dummy] Error 101

No binding for SDL_Delay

Having SDL_Delay would be useful for certain kinds of programs, and the binding wouldn't be difficult to add to the library. The only difficulty is figuring out where exactly it would belong.

foldl-error building bindings with rust / master

Hey All!

I'm just getting started with Rust and trying to compile rust-sdl so I have a familiar set of libraries with which to play. I just built rust from the master branch on github at github.com/mozilla/rust and attempted to compile rust-sdl, yielding the following series of errors: http://itdaniher.com/p?EsRD.

I'm running F18, x64, and have all relevant libraries installed.

If anyone has a chance to take a look, I'd appreciate it.

Thanks!
Ian

Demo still uses `sdl::start`

Simply removing the call to sdl::start in demo/video.rs allows the demo to be compiled, but then it fails when run:

$ ./demo/demo
2013-09-05 15:23:01.713 demo[54886:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error (1000) creating CGSWindow on line 259'
*** First throw call stack:
(
)
libc++abi.dylib: terminate called throwing an exception
Abort trap: 6

I'm not sure this is a related or completely different problem.

use of filter_mapped needs to be changed?

Looks like the inevitable march towards external iterators broke rust-sdl in more ways than one, of late.

rust-lang/rust@de0d696

Rather than have filter_mapped as a method(?) of a vector, we now have to cast(?) vectors to be an iterator via .iter() and call the filter_mapped(?) method(?)

I'm stumbling over terminology, but I think that's the general idea. If I get a chance, I'll try and fix this.

Issue running demo app in OSX 10.9 Mavericks

I have compiled and installed rust on my machine, along with SDL 1.2.15 with homebrew.

The demo app compiles fine. But when I run it, it does nothing. It seems to be the call to sdl::video::set_video_mode that does not return a Result.

Usage of deprecated std::num::FromPrimitive

Trying to get rust-sdl working, I found that events.rs uses std::num::FromPrimitive which has been removed from rust by now (see rust-lang/rust#16920 for more information). Thus, rust-sdl will not compile with newest rust.

~/.cargo/git/checkouts/rust-sdl-917d0a231cab7c3c/master/src/sdl/event.rs:4:5: 4:28 error: unresolved import std::num::FromPrimitive. There is no FromPrimitive in std::num

Build Failure on OSX

Trying to build on OSX-10.8.2.
libSDL installed using macports.

./configure && make
make: *** No rule to make target /usr/local/lib/libSDLmain.a', needed bylibSDLXmain.a'. Stop.

Edited Makefile SDL_PREFIX to match where macports installed it:
SDL_PREFIX ?= /usr/local/lib
->
SDL_PREFIX ?= /opt/local/lib

make
rustc sdl.rc -o libsdl.dummy
error: linking with cc failed with code 1
note: cc arguments: -L/usr/local/lib/rustc/x86_64-apple-darwin/lib -m64 -o libsdl-34b7eedb9132850-0.2.dylib libsdl.o -L/usr/local/lib/rustc/x86_64-apple-darwin/lib -lcore-c3ca5d77d81b46c1-0.6 -L/usr/local/lib/rustc/x86_64-apple-darwin/lib -lstd-4782a756585a81-0.6 -L. -lSDLXmain -framework AppKit -framework Foundation -lSDL -dynamiclib -Wl,-install_name,@rpath/libsdl-34b7eedb9132850-0.2.dylib -lrustrt -Wl,-no_compact_unwind -lmorestack -Wl,-rpath,@executable_path/../../../../../usr/local/lib/rustc/x86_64-apple-darwin/lib -Wl,-rpath,/usr/local/lib/rustc/x86_64-apple-darwin/lib
note: ld: library not found for -lSDL
clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: aborting due to previous error
make: *** [libsdl.dummy] Error 101

doesn't link on ubuntu 12, cc: error: Foundation: No such file or directory

rust-sdl$ make
rustc --cfg image --cfg mixer src/sdl.rc -o libsdl.dummy
src/mixer.rs:3:4: 3:13 warning: unused import [-W unused-imports (default)]
src/mixer.rs:3 use std::uint;
^~~~~~~~~
warning: ignoring specified output filename for library.
error: linking with cc failed with code 1
note: cc arguments: -L/usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib -m64 -o libsdl-95460b1b072257-0.3.0.so libsdl.o -L/usr/local/lib/rustc/x86_64-unknown
-linux-gnu/lib -lstd-6c65cf4b443341b1-0.8-pre -lSDL_image -lSDL_mixer -lSDL -lSDLmain -framework Foundation -framework AppKit -lrustrt -lrt -lpthread -L/usr/
cn/rust/rust-sdl/.rust -L/usr/cn/rust/rust-sdl -shared -lrt -ldl -lm -lmorestack -lrustrt -Wl,-rpath,$ORIGIN/../../../local/lib/rustc/x86_64-unknown-linux-gn
u/lib -Wl,-rpath,/usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib
note: cc: error: Foundation: No such file or directory
cc: error: AppKit: No such file or directory

error: aborting due to previous error
make: *** [libsdl.dummy] Error 101

$/rust/rust-sdl$ git branch -v

  • master b5c0c39 Merge pull request #91 from pcwalton/remove-start

Issue running the demo app

I am getting the following error:

[hammackj@taco:~/Documents/opensource/rust-sdl]$ rustc -L$PWD demo/demo.rc
warning: no debug symbols in executable (-arch x86_64)
[hammackj@taco:~/Documents/opensource/rust-sdl]$ ./demo/demo
2013-10-25 23:38:10.990 demo[5196:1003] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error (1000) creating CGSWindow on line 263'
*** First throw call stack:
(
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6
[hammackj@taco:~/Documents/opensource/rust-sdl]$ 

I am trying to compile the demo. I am using OSX 10.9 with rust from brew. I am a bit new to rust, so I am not exactly sure what is needed to fix this.

Any tips/thoughts would be great.
Thanks

Rust runtime error when using audio callback and Arc<RWLock>>

Description

Currently I am trying to implement a audio in a multi-threaded rust program. One task will write data to an DList, and SDL should read from that and take the information (if available).

To accomplish this, I am using an Arc<RWLock<DList<u8>>>>, staticly created using the lazy_static library. However, when the audio callback is called, the program produces a runtime error.

One thing to note is that this also occurs when using a closure (which can run without using lazy_static). I found out about this by transforming the type pub type AudioCallback<'a> = |&mut [u8]|:'a;.

I am very unsure wether this is a Rust bug, or an rust-sdl one, so I thought on posting it here first.

Version

[mvdnes@vm-arch temp]$ rustc -v
rustc 0.11.0 (c97f885aee24dc28b82aa9d7a7d118d59c02ecbf 2014-07-06 20:36:35 +0000)

[mvdnes@vm-arch temp]$ uname -a
Linux vm-arch 3.15.3-1-ARCH #1 SMP PREEMPT Tue Jul 1 07:32:45 CEST 2014 x86_64 GNU/Linux

Trace

(gdb) break abort
Breakpoint 1 at 0x402960
(gdb) run
Starting program: /home/mvdnes/playground/temp/temp_fn 
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7ffff3501700 (LWP 14596)]


There are not many persons who know what wonders are opened to them in the
stories and visions of their youth; for when as children we listen and dream,
we think but half-formed thoughts, and when as men we try to remember, we are
dulled and prosaic with the poison of life. But some of us awake in the night
with strange phantasms of enchanted hills and gardens, of fountains that sing
in the sun, of golden cliffs overhanging murmuring seas, of plains that stretch
down to sleeping cities of bronze and stone, and of shadowy companies of heroes
that ride caparisoned white horses along the edges of thick forests; and then
we know that we have looked back through the ivory gates into that world of
wonder which was ours before we were wise and unhappy.[New Thread 0x7ffff2d00700 (LWP 14597)]


fatal runtime error:  assertion failed: !ptr.is_null()

Program received signal SIGILL, Illegal instruction.
[Switching to Thread 0x7ffff3501700 (LWP 14596)]
0x0000000000489389 in util::abort::h32d839b9b615b3ceFGa ()
(gdb) bt
#0  0x0000000000489389 in util::abort::h32d839b9b615b3ceFGa ()
#1  0x00000000004852bd in local_ptr::compiled::take::h440988594255534974 ()
#2  0x00000000004889c7 in lock::failing::h3c5abfc3d27477b87Gf ()
#3  0x0000000000488b9f in lock::PoisonOnFail$LT$$x27a$GT$::new::hdfa0c6885184b6a9NIf ()
#4  0x0000000000417925 in lock::RWLock$LT$T$GT$::write::h13551060966698419214 ()
#5  0x0000000000417411 in temp_fn::cb (v=...) at temp_fn.rs:17
#6  0x0000000000418b29 in cb::as_closure.2888 ()
#7  0x000000000045f920 in audio::native_callback::__rust_abi ()
#8  0x000000000045f7ea in audio::native_callback::hbf6648ec3943ccabVha ()
#9  0x00007ffff7b4c8b9 in ?? () from /usr/lib/libSDL-1.2.so.0
#10 0x00007ffff7b54b78 in ?? () from /usr/lib/libSDL-1.2.so.0
#11 0x00007ffff7b954f9 in ?? () from /usr/lib/libSDL-1.2.so.0
#12 0x00007ffff7729124 in start_thread () from /usr/lib/libpthread.so.0
#13 0x00007ffff72474bd in clone () from /usr/lib/libc.so.6
(gdb) 

Example code

#![feature(phase)]

#[phase(plugin, link)] extern crate log;
#[phase(plugin)] extern crate lazy_static;
extern crate sdl;

use std::sync::{Arc, RWLock};

lazy_static! {
    static ref FOO: Arc<RWLock<uint>> = Arc::new(RWLock::new(0));
}

fn cb(v: &mut [u8])
{
    let foo = FOO.clone();
    let mut data = foo.write();
    *data = 2;
    for i in range(0, v.len()) { v[i] = 0; }
}

fn main()
{
    let spec = sdl::audio::DesiredAudioSpec
    {   
        freq: 44100,
        format: sdl::audio::S8AudioFormat,
        channels: sdl::audio::Stereo,
        samples: 4096,
        callback: cb, 
    };  
    match sdl::audio::open(spec)
    {   
        Ok(_) => {}, 
        Err(()) => error!("Could not open audio"),
    }   
    sdl::audio::pause(false);
    std::io::timer::sleep(1000);
    sdl::audio::close();
}

provide `Debug` and `PartialEq`

It would be nice for development if most structs and enums would provide both Debug and PartialEq. For printing out values and for comparing during tests with assert_eq!. Would you accept a PR adding derive attributes?

Compiling on OS X - unresolved name std::as_c_str, std::as_buf

Just cloned the master branch of rust this morning.

$ rustc --version
rustc 0.8-pre (4cf3072 2013-07-25 05:22:44 -0700)
host: x86_64-apple-darwin

Getting the following errors on make. I don't know enough about Rust (yet) to fix this myself, so I figured I'd throw it over the wall at you guys.

$ make
rustc --cfg image --cfg mixer --cfg mac_dylib src/sdl.rc -o libsdl.dummy
src/video.rs:496:19: 496:32 error: unresolved name `str::as_c_str`.
src/video.rs:496                 do str::as_c_str("rb") |mode_buf| {
                                    ^~~~~~~~~~~~~
src/video.rs:495:15: 495:28 error: unresolved name `str::as_c_str`.
src/video.rs:495             do str::as_c_str(path.to_str()) |buf| {
                                ^~~~~~~~~~~~~
src/video.rs:621:19: 621:32 error: unresolved name `str::as_c_str`.
src/video.rs:621                 do str::as_c_str("wb") |mode_buf| {
                                    ^~~~~~~~~~~~~
src/video.rs:620:15: 620:28 error: unresolved name `str::as_c_str`.
src/video.rs:620             do str::as_c_str(path.to_str()) |buf| {
                                ^~~~~~~~~~~~~
src/wm.rs:38:5: 38:18 error: unresolved name `str::as_c_str`.
src/wm.rs:38        do str::as_c_str(icon) |icon_buf| {
                       ^~~~~~~~~~~~~
src/wm.rs:37:4: 37:17 error: unresolved name `str::as_c_str`.
src/wm.rs:37    do str::as_c_str(title) |title_buf| {
                   ^~~~~~~~~~~~~
src/img.rs:54:4: 54:15 error: unresolved name `str::as_buf`.
src/img.rs:54     str::as_buf(file.to_str(), |buf, _len| {
                  ^~~~~~~~~~~
src/mixer.rs:117:19: 117:32 error: unresolved name `str::as_c_str`.
src/mixer.rs:117                 do str::as_c_str("rb") |mode_buf| {
                                    ^~~~~~~~~~~~~
src/mixer.rs:116:15: 116:28 error: unresolved name `str::as_c_str`.
src/mixer.rs:116             do str::as_c_str(path.to_str()) |buf| {
                                ^~~~~~~~~~~~~
src/sdl.rs:161:7: 161:20 error: unresolved name `str::as_c_str`.
src/sdl.rs:161     do str::as_c_str(err) |buf| {
                      ^~~~~~~~~~~~~
error: aborting due to 10 previous errors
make: *** [libsdl.dummy] Error 101

A binding to SDL_PushEvent is needed

A binding to the SDL_PushEvent function is needed. In my code I plan to use the blocking function SDL_WaitEvent on the main thread, and use SDL_PushEvent to unblock the main thread so I can do rendering code, or whatever.

Segfault on OSX when closing a window through the window close button

When closing an SDL application that has surfaces allocated using the window close button, the application segfaults. I believe this is due to the Drop block being called on all surfaces as they fall out of scope, even though OSX has gone and cleared up the memory itself.

To reproduce:

  • initialize SDL
  • Set the video mode
  • Poll for events in a loop, with something to escape it on event::QuitEvent
  • Close the app through the window.
  • Crash.

It might be as simple as checking to see if SDL is initialized before trying to release a surface. I'll provide code to reproduce when I next have a chance.

Migrate to SDL2?

http://wiki.libsdl.org/moin.fcg/MigrationGuide

http://lists.libsdl.org/pipermail/sdl-libsdl.org/2013-August/089854.html

Better cross-platform support, better accelerated 2d graphics, and improvements to threading:

There's no SDL_main! Well, okay, there is, and it now does what it was always meant to: be a small piece of code that hides the difference between main() and WinMain() on Windows. There's no initialization code in it, and it's completely optional. This means you can use SDL without it taking over your mainline, which is nice for plugins that use SDL, or scripting languages with an SDL module. All the stuff you'd want the 1.2 SDL_main for is now in SDL_Init() where it belongs.

`SDL_ttf` support.

My game (rustyhex) needs some text. ;)

Will do this myself in some future (once I find some time) if no one else is going to do it faster.

Linking sdl-demo/sdl_main.rs fails

Hi, I'm trying to run the demo using the sdl_main.rs approach, but it does not seems to be working. This is the linking error I got:

error: linking with `cc` failed: exit code: 1
note: cc arguments: '-m64' '-L/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-o' 'sdl_main' 'sdl_main.o' '-lmorestack' '-nodefaultlibs' '-Wl,--as-needed' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libnative-83574243-0.11-pre.rlib' '/home/.../sdl/libsdl-e351513a-0.3.2.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-dd29dab1-0.11-pre.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-aad93cea-0.11-pre.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-3574b280-0.11-pre.rlib' '-L.' '-L/home/.../sdl/.rust' '-L/home/.../sdl' '-Wl,-Bdynamic' '-lSDL' '-ldl' '-lpthread' '-lgcc_s' '-lc' '-lm' '-Wl,-rpath,$ORIGIN/../../../../../../../usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-Wl,-rpath,/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lcompiler-rt'
note: /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status

error: aborting due to previous error

This is the Rust version I'm using:

rustc 0.11-pre-nightly (a5cd502 2014-04-22 02:06:35 -0700)
host: x86_64-unknown-linux-gnu

Running the main.rs demo worked fine. Any ideas?

Complete more bindings and make API follow Rust idioms

I don't think it's necessary to prefix all the key variants with "SDLK" for example. I've experimented with a more "rusty" looking API here: https://github.com/z0w0/rust-sdl/tree/revamp

Another example is the KeyboardEvent structs. If you take a look at how I did it, I just make one KeyEvent variant with a state boolean as to whether it was down or up, instead of both a keydown and keyup variant. I think this works nicely and gets rid of the need for an extra struct.

Secondly, these bindings still needs a lot of work to actually have all the SDL functions mirrored. I'll do my best to add what I can.

Upload 0.3.6 to cargo.io

The version 0.3.5 that is uploaded to crates.io is not the latest and it's not compiling with rust version 1.0.0, please upload the latest version.
Also it would be nice if there are the tags and releases for the new versions

Fails to run on Windows

After compiling with rustc sdl.rc --test, attempting to run sdl.exe results in the following:

 The procedure entry point _ZN2u814__extensions__9meth_61622eq16_b1aee21ec7f5ee53_05E could not be located in the dynamic link library sdl.exe

(or sdl-34b7eedb9132850-0.2.dll without --test, and with another test program.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.