Skip to content

Commit

Permalink
Add basic example, update README.
Browse files Browse the repository at this point in the history
  • Loading branch information
TSnake41 committed Oct 17, 2023
1 parent 095deec commit a839d98
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[workspace]
members = ["raylib", "raylib-sys"]
members = ["raylib", "raylib-sys", "example"]
29 changes: 13 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# raylib-rs

raylib-rs is a Rust binding for [raylib](http://www.raylib.com/) 3.5. It currently targets the _stable_ Rust toolchain, version 1.31 or higher.
raylib-rs is a Rust binding for [raylib](http://www.raylib.com/) 4.5. It currently targets the _stable_ Rust toolchain, version 1.31 or higher.

Please checkout the showcase directory to find usage examples!

Expand All @@ -27,23 +27,20 @@ Though this binding tries to stay close to the simple C API, it makes some chang

## Supported Platforms

| API | Windows | Linux | macOS | Web | Android | Raspberry Pi |
| ------ | ------------------ | ------------------ | ------------------ | -------------- | ------- | ------------ |
| core | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :construction: | | |
| rgui | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | | |
| physac | :construction: | :construction: | :construction: | | | |
| rlgl | :heavy_check_mark: | :x: | :x: | | | |
| API | Windows | Linux | macOS | Web | Android | Raspberry Pi |
| ------ | ------------------ | ------------------ | ------------------ | ------------------ | ------------------ | ------------------ |
| core | :heavy_check_mark: | :heavy_check_mark: | :question: | :heavy_check_mark: | | :question: |
| rgui | :heavy_check_mark: | :heavy_check_mark: | :question: | :heavy_check_mark: | | :question: |
| physac | :heavy_check_mark: | :heavy_check_mark: | :question: | :heavy_check_mark: | | :question: |
| rlgl | :heavy_check_mark: | :heavy_check_mark: | :question: | :question: | | :question: |

## 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](https://github.com/raysan5/raylib/wiki)

1. Add the dependency to your `Cargo.toml`:

```toml
[dependencies]
raylib = { version = "3.7" }
raylib = { branch = "4.5.0-redesign", git = "https://github.com/TSnake41/raylib-rs" }
```

2. Start coding!
Expand All @@ -52,16 +49,16 @@ raylib = { version = "3.7" }
use raylib::prelude::*;

fn main() {
let (mut rl, thread) = raylib::init()
let (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);
rl.begin_drawing(&thread, |d| {
d.clear_background(Color::WHITE);
d.draw_text("Hello, world!", 12, 12, 20, Color::BLACK);
});
}
}
```
Expand Down
9 changes: 9 additions & 0 deletions example/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "example"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
raylib = { branch = "4.5.0-redesign", git = "https://github.com/TSnake41/raylib-rs" }
15 changes: 15 additions & 0 deletions example/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use raylib::prelude::*;

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

while !rl.window_should_close() {
rl.begin_drawing(&thread, |d| {
d.clear_background(Color::WHITE);
d.draw_text("Hello, world!", 12, 12, 20, Color::BLACK);
});
}
}

0 comments on commit a839d98

Please sign in to comment.