All Projects → deltaphc → Raylib Rs

deltaphc / Raylib Rs

Licence: other
Rust bindings for raylib

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Raylib Rs

Shipyard
Entity Component System focused on usability and speed.
Stars: ✭ 247 (-6.08%)
Mutual labels:  game-development, gamedev
Flaxengine
Flax Engine – multi-platform 3D game engine
Stars: ✭ 3,127 (+1088.97%)
Mutual labels:  game-development, gamedev
Methanekit
🎲 Modern 3D graphics made simple with cross-platform C++17 meta-API on top of DirectX 12 & Metal (Vulkan is coming)
Stars: ✭ 197 (-25.1%)
Mutual labels:  game-development, gamedev
Deadsimple Pixel Perfect Camera
An exceedingly easy-to-use pixel perfect orthographic camera script for 2D scenes in Unity. Punch in a few specs and you've got a working pixel perfect camera. It's that easy.
Stars: ✭ 186 (-29.28%)
Mutual labels:  game-development, gamedev
Luascript
Lua language support for Godot Engine
Stars: ✭ 240 (-8.75%)
Mutual labels:  game-development, gamedev
Engine
Cocos Creator is a complete package of game development tools and workflow, including a game engine, resource management, scene editing, game preview, debug and publish one project to multiple platforms.
Stars: ✭ 2,574 (+878.71%)
Mutual labels:  game-development, gamedev
Vulkan Renderer
A new 3D game engine using modern C++ and Vulkan API
Stars: ✭ 205 (-22.05%)
Mutual labels:  game-development, gamedev
Rimlight
Customizable rimlight shader for Unity that includes pulsation and noise scrolling. Give your scenes that extra oomph!
Stars: ✭ 170 (-35.36%)
Mutual labels:  game-development, gamedev
Kira
Library for expressive game audio.
Stars: ✭ 237 (-9.89%)
Mutual labels:  game-development, gamedev
Entitas Cpp
Entitas++ is a fast Entity Component System (ECS) C++11 port of Entitas C#
Stars: ✭ 229 (-12.93%)
Mutual labels:  game-development, gamedev
React Native Donkey Kong
Donkey Kong remake using react-native-game-engine 🙉
Stars: ✭ 174 (-33.84%)
Mutual labels:  game-development, gamedev
Gdevelop
🎮 GDevelop is an open-source, cross-platform game engine designed to be used by everyone.
Stars: ✭ 3,221 (+1124.71%)
Mutual labels:  game-development, gamedev
Uecs
Ubpa Entity-Component-System (U ECS) in Unity3D-style
Stars: ✭ 174 (-33.84%)
Mutual labels:  game-development, gamedev
Godot Kickstarter 2019
Create your Own Games with Godot, the Free Game Engine: sources from the January Kickstarter project from GDQuest
Stars: ✭ 194 (-26.24%)
Mutual labels:  game-development, gamedev
Alimer
Cross-platform game engine.
Stars: ✭ 172 (-34.6%)
Mutual labels:  game-development, gamedev
Unity Shaders
✨ Shader demo - More than 300 examples
Stars: ✭ 198 (-24.71%)
Mutual labels:  game-development, gamedev
Swissarmylib
Collection of helpful utilities we use in our Unity projects.
Stars: ✭ 154 (-41.44%)
Mutual labels:  game-development, gamedev
Fxgl
Stars: ✭ 2,378 (+804.18%)
Mutual labels:  game-development, gamedev
Awesome Haxe Gamedev
Resources for game development on haxe
Stars: ✭ 213 (-19.01%)
Mutual labels:  game-development, gamedev
Panda3d
Powerful, mature open-source cross-platform game engine for Python and C++, developed by Disney and CMU
Stars: ✭ 3,035 (+1053.99%)
Mutual labels:  game-development, gamedev

logo

rust crates.io docs discord

raylib-rs

raylib-rs is a Rust binding for raylib 3.5. It currently targets the stable Rust toolchain, version 1.31 or higher.

Please checkout the showcase directory to find usage examples!

Though this binding tries to stay close to the simple C API, it makes some changes to be more idiomatic for Rust.

  • Resources are automatically cleaned up when they go out of scope (or when std::mem::drop is called). This is essentially RAII. This means that "Unload" functions are not exposed (and not necessary unless you obtain a Weak resource using make_weak()).
  • Most of the Raylib API is exposed through RaylibHandle, which is for enforcing that Raylib is only initialized once, and for making sure the window is closed properly. RaylibHandle has no size and goes away at compile time. Because of mutability rules, Raylib-rs is thread safe!
  • A RaylibHandle and RaylibThread are obtained through raylib::init_window(...) or through the newer init() function which will allow you to build up some window options before initialization (replaces set_config_flags). RaylibThread should not be sent to any other threads, or used in a any syncronization primitives (Mutex, Arc) etc.
  • Manually closing the window is unnecessary, because CloseWindow is automatically called when RaylibHandle goes out of scope.
  • Model::set_material, Material::set_shader, and MaterialMap::set_texture methods were added since one cannot set the fields directly. Also enforces correct ownership semantics.
  • Font::from_data, Font::set_chars, and Font::set_texture methods were added to create a Font from loaded CharInfo data.
  • SubText and FormatText are omitted, and are instead covered by Rust's string slicing and Rust's format! macro, respectively.

Disclaimer: I created this binding as a way to learn Rust. There may be some things I can do better, or make more ergonomic for users. Feel free to make suggestions!

Installation

Supported Platforms

API Windows Linux macOS Web Android Raspberry Pi
core ✔️ ✔️ ✔️ 🚧
rgui ✔️ ✔️ ✔️
physac 🚧 🚧 🚧
rlgl ✔️ ✔️

Build Dependencies

Requires glfw, cmake, and curl. Tips on making things work smoothly on all platforms is appreciated. Follow instructions for building raylib for your platform here

  1. Add the dependency to your Cargo.toml:
[dependencies]
raylib = "3.5"
  1. Start coding!
use raylib::prelude::*;

fn main() {
    let (mut rl, thread) = raylib::init()
        .size(640, 480)
        .title("Hello, World")
        .build();

    while !rl.window_should_close() {
        let mut d = rl.begin_drawing(&thread);

        d.clear_background(Color::WHITE);
        d.draw_text("Hello, world!", 12, 12, 20, Color::BLACK);
    }
}

Tech Notes

  • Structs holding resources have RAII/move semantics, including: Image, Texture2D, RenderTexture2D, Font, Mesh, Shader, Material, Model, Wave, Sound, Music, and AudioStream.
  • Functions dealing with string data take in &str and/or return an owned String, for the sake of safety. The exception to this is the gui draw functions which take &CStr to avoid per frame allocations. The rstr! macro helps make this easy.
  • In C, LoadFontData returns a pointer to a heap-allocated array of CharInfo structs. In this Rust binding, said array is copied into an owned Vec<CharInfo>, the original data is freed, and the owned Vec is returned.
  • In C, GetDroppedFiles returns a pointer to an array of strings owned by raylib. Again, for safety and also ease of use, this binding copies said array into a Vec<String> which is returned to the caller.
  • I've tried to make linking automatic, though I've only tested on Windows 10, Ubuntu, and MacOS 15. Other platforms may have other considerations.

Extras

  • In addition to the base library, there is also a convenient ease module which contains various interpolation/easing functions ported from raylib's easings.h, as well as a Tween struct to assist in using these functions.
  • Equivalent math and vector operations, ported from raymath.h, are impled on the various Vector and Matrix types. Operator overloading is used for more intuitive design.

Testing

The raylib-test crate tests the bindings by opening a window, and checking the results of various functions. It requires nightly to use.

Future Goals

  • Port raylib examples over to Rust.
  • More tests.
  • More platform testing.
  • Even more testing.
  • Physac port?

Contribution & Support

All contributions are welcome. Chat about raylib on discord

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].