- Notifications
You must be signed in to change notification settings - Fork17
A Rust wrapper and bindings of Allegro 5 game programming library
License
SiegeLord/RustAllegro
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A thinRust wrapper ofAllegro 5.
externcrate allegro;externcrate allegro_font;use allegro::*;use allegro_font::*;allegro_main!{let core =Core::init().unwrap();let font_addon =FontAddon::init(&core).unwrap();let display =Display::new(&core,800,600).unwrap();let timer =Timer::new(&core,1.0 /60.0).unwrap();let font =Font::new_builtin(&font_addon).unwrap();let queue =EventQueue::new(&core).unwrap(); queue.register_event_source(display.get_event_source()); queue.register_event_source(timer.get_event_source());letmut redraw =true; timer.start();'exit:loop{if redraw && queue.is_empty(){ core.clear_to_color(Color::from_rgb_f(0.0,0.0,0.0)); core.draw_text(&font,Color::from_rgb_f(1.0,1.0,1.0),(display.get_width() /2)asf32,(display.get_height() /2)asf32,FontAlign::Centre,"Welcome to RustAllegro!"); core.flip_display(); redraw =false;}match queue.wait_for_event(){DisplayClose{..} =>break'exit,TimerTick{..} => redraw =true, _ =>(),}}}
Seedocs.rs. Notethat it is very incomplete. You'll likely want to refer back to Allegro'sdocumentation somewhat heavily at this time.
The included packages are:
Wrappers:
- allegro
- allegro_acodec
- allegro_audio
- allegro_dialog
- allegro_font
- allegro_image
- allegro_primitives
- allegro_ttf
Bindings:
- allegro-sys
- allegro_acodec-sys
- allegro_audio-sys
- allegro_dialog-sys
- allegro_font-sys
- allegro_image-sys
- allegro_primitives-sys
- allegro_ttf-sys
Examples:
Theallegro-sys
package (and, transitively, the rest of the packages) detectswhich version of Allegro to bind by parsing the C header. The build script willlook for it in some common locations, but sometimes you will need to help it byspecifying theALLEGRO_INCLUDE_DIR
environment variable when invokingcargo build
. This directory should contain theallegro5
directory with all of theheaders inside it. The build script will define the following two metadataentries that the crates that depend on it can use to determine which version isused:
sub_version
- The sub version of Allegro (e.g. for 5.1.10 the sub version is 1)wip_version
- The wip version of Allegro (e.g. for 5.1.10 the wip version is 10).
Note that theCore::init()
will attempt to verify that the bindingcorresponds to the version of the library you're linking to.
There are a few features that might come in useful:
link_none
- Do not try to link the standard Allegro libraries, incase you want to link the monolith library or have otherneeds.link_debug
- Link to the debug versions of the Allegro libraries. Canbe combined withlink_static
.link_static
- Link to the static versions of the Allegro libraries.Note that you'll have to link the various dependencylibraries yourself. Can be combined withlink_debug
.
Additionally, you can specify a link directory by setting aALLEGRO_LINK_DIR
.
RustAllegro works well with the official pre-compiled binaries. First,download the official binaries fromhttp://liballeg.org. You'll want tomatch the ABI of your Rust installation. GNU ABI on 32 bit can loadAllegro 32 bit MSVC binaries, but otherwise you'll want to match theplatform and ABI exactly. Let's say you extract the binaries toC:/allegro
. That directory will contain the include, bin and libdirectories. To compile and run the RustAllegro examples, do thefollowing from the RustAllegro'sexamples
directory:
- If you're using MSYS:
export ALLEGRO_INCLUDE_DIR=C:/allegro/includeexport ALLEGRO_LINK_DIR=C:/allegro/libcargo build
- If you're using cmd directly:
set ALLEGRO_INCLUDE_DIR=C:/allegro/includeset ALLEGRO_LINK_DIR=C:/allegro/libcargo build
Now you need to copy the Allegro DLLs next to the generated executables(which will probably be under target/debug directory). Now you shouldbe able to run the examples (make sure to run them from RustAllegro'sexamples
directory, so they can find the various data files theyrequire).
About
A Rust wrapper and bindings of Allegro 5 game programming library
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors7
Uh oh!
There was an error while loading.Please reload this page.