🎮 A simple 2D game framework written in Rust

Overview

Tetra

Build Status Crates.io Documentation License

Tetra is a simple 2D game framework written in Rust. It uses SDL2 for event handling and OpenGL 3.2+ for rendering.

Features

  • XNA/MonoGame-inspired API
  • Efficient 2D rendering, with draw call batching by default
  • Easy input handling, via polling or events, with support for gamepads
  • Deterministic game loop by default, à la Fix Your Timestep
  • Common building blocks built-in, such as:
    • Font rendering
    • Cameras
    • Screen scaling

Installation

To add Tetra to your project, add the following line to your Cargo.toml file:

tetra = "0.6"

You will also need to install the SDL2 native libraries - full details are provided in the documentation.

Examples

To get a simple window displayed on screen, the following code can be used:

use tetra::graphics::{self, Color};
use tetra::{Context, ContextBuilder, State};

struct GameState;

impl State for GameState {
    fn draw(&mut self, ctx: &mut Context) -> tetra::Result {
        // Cornflower blue, as is tradition
        graphics::clear(ctx, Color::rgb(0.392, 0.584, 0.929));
        Ok(())
    }
}

fn main() -> tetra::Result {
    ContextBuilder::new("Hello, world!", 1280, 720)
        .build()?
        .run(|_| Ok(GameState))
}

You can see this example in action by running cargo run --example hello_world.

The full list of examples is available here.

Support/Feedback

Tetra is fairly early in development, so you might run into bugs/flaky docs/general weirdness. Please feel free to open an issue/PR if you find something! You can also contact me via Twitter or the Rust Game Development Discord.

Comments
  • Rendering on MacBook Pro only covers quarter of the screen

    Rendering on MacBook Pro only covers quarter of the screen

    Running the samples (or anything I build myself) on my MacBook Pro 2015 with 2560x1600 screen resolution, causes all rendering to only cover the lover left quarter of the window, doesn't matter if it's full screen or windowed. Most likely has something to do with DPI settings but I can't seem to impact this with tetra? Have tried to change internal vs external size on window, but nothing seems to change.

    Any ideas? SDL2 related I guess, since I do have these issues with "plain" SDL2 projects as well.

    Type: Bug Area: Graphics Platform Specific: macOS Area: High DPI Support 
    opened by johanlindfors 32
  • Black screen/shader issues on MacOS

    Black screen/shader issues on MacOS

    Running on osX mojave. Macbook pro retina. Download from GIT and run

    cargo run --example hello_world

    Compiling tetra v0.2.1 (/Users/pabloweremczuk/Documents/Proyectos/rust/tetra) Finished dev [unoptimized + debuginfo] target(s) in 6.41s Running target/debug/examples/texture OpenGL Device: AMD Radeon R9 M370X OpenGL Engine OpenGL Driver: 2.1 ATI-2.4.9 OpenGL Vendor: ATI Technologies Inc. Swap Interval: VSync Error: OpenGl("ERROR: 0:1: '' : version '130' is not supported\n")

    Type: Bug Area: Graphics Help Wanted Platform Specific: macOS 
    opened by WEREMSOFT 29
  • Add an example of using Tetra with an ECS library

    Add an example of using Tetra with an ECS library

    I'm not sure whether I plan on using anything as heavy duty as Specs for now, but it'd be good to have an example in the repository, both for the sake of documentation and to make sure any API changes we make play nicely.

    I ported my rl demo from GGEZ to Tetra and it seems to work well, although it's probably a bit more complicated than what we're looking for here.

    Type: Feature Request Area: Documentation Good First Issue 
    opened by 17cupsofcoffee 19
  • Black screen when using Mesa drivers (?)

    Black screen when using Mesa drivers (?)

    After installing the -lSDL2 dependency:

    apt-get install libsdl2-dev
    

    I can compile and run the examples (on Debian), but they all render black without error messages:

    $ uname -a
    Linux purism 4.15.0-2-amd64 #1 SMP Debian 4.15.11-1 (2018-03-20) x86_64 GNU/Linux
    $ cargo run --example hello_world
        Finished dev [unoptimized + debuginfo] target(s) in 0.05s
         Running `target/debug/examples/hello_world`
    OpenGL Device: Mesa DRI Intel(R) Iris 6100 (Broadwell GT3)
    OpenGL Driver: 3.0 Mesa 18.1.9
    OpenGL Vendor: Intel Open Source Technology Center
    Swap Interval: VSync
    
    Type: Bug Area: Graphics 
    opened by wahn 14
  • crash with

    crash with "Segmentation fault: 11" message when multiple gamepads connected.

    Summary

    My game randomly crashes at the start of the runtime with the error message Segmentation fault: 11 and this error appear when 2 gamepads connected with the computer before running the game using cargo run

    • error message after call cargo run Screen Shot 2021-09-10 at 8 37 19 pm

    • main function. I printing start main message when it start. Screen Shot 2021-09-10 at 8 37 01 pm

    • GameState::new(). It should called from main() with printing message main::new at start of the function. Screen Shot 2021-09-10 at 8 36 52 pm

    From the printing message. I assume that the game crash before enteringGameState::new()

    Steps to Reproduce

    • Connect 2 gamepads
    • call cargo run
    • using get_gamepad_name(), get_gamepad_axis_position(), is_key_down(), is_gamepad_button_down()
    • close the app by pressing Esc
    • call cargo run again. The error should appear. If it not appear try it again 2 or 3 times.

    Additional Info

    OSX Catalina 10.15.7 tetra = "0.6.2" gamepads:

    • Logitec Gamepad F310 USB
    • 8BitDo arcade stick bluetooth
    Type: Bug Area: Input Status: Needs Replicating Unsafe ☢ 
    opened by Im-Oab 13
  • Add a way to find information about the system

    Add a way to find information about the system

    Summary: There does not seem to be a way to find information about the system. It would be nice to at least be able to find the screen size before creating the context (or, if not possible, create a context without creating a window first).

    Why is this needed? Code examples show something like

    ContextBuilder::new("Hello, world!", 1280, 720)
        ...
    

    But that size may or may not be suitable for the screen. Being able to find out whether it's a massive 3440x1440 screen or a tiny Raspberry Pi 320x200 screen would be really useful. Ideally, this information should be available before creating a window, to avoid having to create a default sized window (or a full screen context) only to then find out that it's not a good size and change the size when the window is already visible.

    Type: Feature Request Area: Graphics API: Breaking Area: Platform 
    opened by cralian 12
  • Font rendering sizes are not correct

    Font rendering sizes are not correct

    Summary: I used a font that is made for pixel perfect text, at size 9. In tetra, it looks very blurry with size 9, but looks fine in size 10. Tried the font in godot engine, where it works fine at size 9, but not 10. The font is "Vector", from Chevy Ray's font pack. I am sure it is reproducible with other (free) fonts as well.

    Edit: I tried with another font that should be pixel perfect at size 10, but I could't get it to work at any whole pixel size.

    How it looks at size 9: image

    How it looks at size 10 (expected this at size 9): image

    Type: Bug Area: Graphics API: Breaking 
    opened by fossegutten 11
  • Sprites sliced from sheets sometimes displays off by 1 pixel

    Sprites sliced from sheets sometimes displays off by 1 pixel

    Summary: I'm managing my sprites with spritesheets. I slice sprites from sheets with DrawParams::clip(), and draw them on a position with DrawParams::position(). But, when I let the sprites move around, I noticed that they sometimes displays off by 1 pixel.

    Steps to reproduce: I wrote a minimal case, and here is the screenshot:

    issue

    I found this seems to be caused by passing DrawParams::position() some real numbers.

    Expected behavior: I expected position() does not affect sprite clipping, but actually it seems do. Is it a intended feature? If so, how can I ensure that the sprites are clipped pixel-perfectly?

    Additional info: system info: Debian testing, nvidia-driver 440.100-2

    Type: Bug Area: Graphics Area: Documentation Platform Specific: Nvidia 
    opened by taotao54321 11
  • Implement cameras/views

    Implement cameras/views

    Another one suggested by @xla on Twitter.

    This probably wouldn't be too hard to implement out of tree if someone's game required it, but it's such a common requirement that we probably want it built-in.

    Type: Feature Request Area: Graphics 
    opened by 17cupsofcoffee 11
  • Mesh does not support DrawParams::color

    Mesh does not support DrawParams::color

    Here is my mesh creation

            let (pos_i, uv_i) = (Vec2::new(0.0, 0.0), Vec2::new(0.0, 0.0));
            let (pos_j, uv_j) = (Vec2::new(1.25, 1.25), Vec2::new(0.5, 0.5));
            let (pos_k, uv_k) = (Vec2::new(0.0, 2.5), Vec2::new(0.0, 1.0));
            let particle_vertices = &[
                Vertex::new(pos_i, uv_i, Color::WHITE),
                Vertex::new(pos_j, uv_j, Color::WHITE),
                Vertex::new(pos_k, uv_k, Color::WHITE),
            ];
            let particle_mesh = VertexBuffer::with_usage(ctx, particle_vertices, BufferUsage::Static)?.into_mesh();
    

    When I draw it (and try to change the color with DrawParams)

                graphics::draw(
                    ctx,
                    &self.particle_mesh,
                    DrawParams::new()
                        .position(p.position)
                        .origin(Vec2::new(0.0, 2.5))
                        .scale(Vec2::new(p.scale, p.scale))
                        .color(p.color)                //-> p.color is a Color
                        .rotation(p.theta),
                );   
            }
    

    thinking my code had a problem, I performed the same test with the mesh.rs example (removing the texture). Same result, the color does not change

    Type: Bug Area: Graphics Area: Documentation API: Breaking 
    opened by LittleB0xes 10
  • Minimizing the window jumps up the CPU usage.

    Minimizing the window jumps up the CPU usage.

    Summary: Minimizing the window jumps up the CPU usage.

    Steps to reproduce: Run an empty application and minimize its window.

    Additional info: https://github.com/17cupsofcoffee/tetra/blob/62c9a264c8bd35585515e4e43375d5f835f4598f/src/context.rs#L155 Perhaps this problem occurs because std::thread::yield_now() does not wait properly when the application is idle.

    This issue is confirmed to occur on Windows and MacOS.

    • MacOS Activity Monitor on MacOS shows the percentage of usage of each logical core.

      • 1.7% -> 45% (My application)
      • 2% -> 80% (cargo run --release --example animation)
    • Windows cpu_usage

    Type: Bug Area: Platform 
    opened by sumibi-yakitori 10
  • Update lyon_tessellation requirement from 0.17.4 to 1.0.8

    Update lyon_tessellation requirement from 0.17.4 to 1.0.8

    Updates the requirements on lyon_tessellation to permit the latest version.

    Commits

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    Type: Dependency Update 
    opened by dependabot[bot] 0
  • Update half requirement from 1.8 to 2.2

    Update half requirement from 1.8 to 2.2

    Updates the requirements on half to permit the latest version.

    Release notes

    Sourced from half's releases.

    2.2.0

    Added

    • Add serialize_as_f32 and serialize_as_string functions when serde cargo feature is enabled. They allowing customizing the serialization by using #[serde(serialize_with="f16::serialize_as_f32")] attribute in serde derive macros. Closes #60.
    • Deserialize now supports deserializing from f32, f64, and string values in addition to its previous default deserialization. Closes #60.

    Fixed

    • Add #[inline] on fallback functions, which improved conversion execution on non-nightly rust by up to 50%. By @​Shnatsel.
    Changelog

    Sourced from half's changelog.

    [2.2.0] - 2022-12-30

    Added

    • Add serialize_as_f32 and serialize_as_string functions when serde cargo feature is enabled. They allowing customizing the serialization by using #[serde(serialize_with="f16::serialize_as_f32")] attribute in serde derive macros. Closes #60.
    • Deserialize now supports deserializing from f32, f64, and string values in addition to its previous default deserialization. Closes #60.

    Fixed

    • Add #[inline] on fallback functions, which improved conversion execution on non-nightly rust by up to 50%. By [@​Shnatsel].

    [2.1.0] - 2022-07-18

    Added

    • Add support for target_arch spirv. Some traits and functions are unavailble on this architecture. By [@​charles-r-earp].
    • Add total_cmp method to both float types. Closes #55, by [@​joseluis].

    [2.0.0] - 2022-06-21

    Changed

    • Breaking Change Minimum supported Rust version is now 1.58.
    • Breaking Change std is now enabled as a default cargo feature. Disable default features to continue using no_std support.
    • Migrated to Rust Edition 2021.
    • Added #[must_use] attributes to functions, as appropriate.

    Fixed

    • Fix a soundness bug with slice::as_ptr not correctly using mutable reference. By [@​Nilstrieb].

    Added

    • Added const conversion methods to both f16 and bf16. These methods never use hardware intrinsics, unlike the current conversion methods, which is why they are separated into new methods. The following const methods were added:
      • from_f32_const
      • from_f64_const
      • to_f32_const
      • to_f64_const
    • Added Neg trait support for borrowed values &f16 and &bf16. By [@​pthariensflame].
    • Added AsPrimitive implementations from and to self, usize, and isize. By [@​kali].

    Removed

    • Breaking Change The deprecated serialize cargo feature has been removed. Use serde cargo feature instead.
    • Breaking Change The deprecated consts module has been removed. Use associated constants on f16 instead.
    • Breaking Change The following deprecated functions have been removed:
      • f16::as_bits
      • slice::from_bits_mut
      • slice::to_bits_mut
      • slice::from_bits

    ... (truncated)

    Commits

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    Type: Dependency Update 
    opened by dependabot[bot] 0
  • Update hashbrown requirement from 0.12.0 to 0.13.1

    Update hashbrown requirement from 0.12.0 to 0.13.1

    Updates the requirements on hashbrown to permit the latest version.

    Changelog

    Sourced from hashbrown's changelog.

    [v0.13.1] - 2022-11-10

    Added

    • Added Equivalent trait to customize key lookups. (#350)
    • Added support for 16-bit targets. (#368)
    • Added RawTable::allocation_info which provides information about the memory usage of a table. (#371)

    Changed

    • Bumped MSRV to 1.61.0.
    • Upgraded to ahash 0.8. (#357)
    • Make with_hasher_in const. (#355)
    • The following methods have been removed from the RawTable API in favor of safer alternatives:
      • RawTable::erase_no_drop => Use RawTable::erase or RawTable::remove instead.
      • Bucket::read => Use RawTable::remove instead.
      • Bucket::drop => Use RawTable::erase instead.
      • Bucket::write => Use Bucket::as_mut instead.

    Fixed

    • Ensure that HashMap allocations don't exceed isize::MAX. (#362)
    • Fixed issue with field retagging in scopeguard. (#359)

    [v0.12.3] - 2022-07-17

    Fixed

    • Fixed double-drop in RawTable::clone_from. (#348)

    [v0.12.2] - 2022-07-09

    Added

    • Added Entry API for HashSet. (#342)
    • Added Extend<&'a (K, V)> for HashMap<K, V, S, A>. (#340)
    • Added length-based short-circuiting for hash table iteration. (#338)
    • Added a function to access the RawTable of a HashMap. (#335)

    Changed

    • Edited do_alloc to reduce LLVM IR generated. (#341)

    [v0.12.1] - 2022-05-02

    Fixed

    • Fixed underflow in RawIterRange::size_hint. (#325)

    ... (truncated)

    Commits
    • e6cd877 Version 0.13.1
    • 37071e5 Auto merge of #372 - Amanieu:unsafe-deprecated, r=Amanieu
    • 3263559 Remove Bucket and RawTable that are hard to use safely
    • bf272b6 Auto merge of #371 - stepancheg:alloc-info, r=Amanieu
    • 299b0f6 RawTable::allocation_info
    • f1c8537 Auto merge of #368 - Amanieu:16bit, r=Amanieu
    • cb0680c Add support for 16-bit targets
    • e39d245 Auto merge of #366 - JustForFun88:const_size_of, r=Amanieu
    • 4e39290 Make TableLayout::new::\<T>() and mem::needs_drop::\<T>() const
    • f3fa266 Make usize::min(mem::size_of::\<usize>(), mem::size_of::\<u64>()) const
    • Additional commits viewable in compare view

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    Type: Dependency Update 
    opened by dependabot[bot] 0
  • Update rodio requirement from 0.15.0 to 0.16.0

    Update rodio requirement from 0.15.0 to 0.16.0

    Updates the requirements on rodio to permit the latest version.

    Changelog

    Sourced from rodio's changelog.

    Version 0.16.0 (2022-09-14)

    • Update cpal to 0.14.
    • Update symphonia to 0.5.

    Version 0.15.0 (2022-01-23)

    • Remove requirement that the argument Decoder::new and LoopedDecoder::new implement Send.
    • Add optional symphonia backend.
    • WavDecoder's total_duration now returns the total duration of the sound rather than the remaining duration.
    • Add 32-bit signed in WAV decoding.
    • SineWave::new() now takes a f32 instead of a u32.
    • Add len() method to SpatialSink.

    Version 0.14.0 (2021-05-21)

    • Re-export cpal in full.
    • Replace panics when calling OutputStream::try_default, OutputStream::try_from_device with new StreamError variants.
    • OutputStream::try_default will now fallback to non-default output devices if an OutputStream cannot be created from the default device.

    Version 0.13.1 (2021-03-28)

    • Fix panic when no pulseaudio-alsa was installed.

    Version 0.13.0 (2020-11-03)

    • Update cpal to 0.13.
    • Add Android support.

    Version 0.12.0 (2020-10-05)

    • Breaking: Update cpal to 0.12.
    • Breaking: Rework API removing global "rodio audio processing" thread & adapting to the upstream cpal API changes.
    • Add new_X format specific methods to Decoder.
    • Fix resampler dependency on internal Vec::capacity behaviour.

    Version 0.11.0 (2020-03-16)

    • Update lewton to 0.10.
    • Breaking: Update cpal to 0.11

    Version 0.10.0 (2019-11-16)

    • Removal of nalgebra in favour of own code.
    • Fix a bug that switched channels when resuming after having paused.
    • Attempt all supported output formats if the default format fails in Sink::new.
    • Breaking: Update cpal to 0.10.

    ... (truncated)

    Commits

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    Type: Dependency Update 
    opened by dependabot[bot] 0
  • Instancing using instanced vertex attributes

    Instancing using instanced vertex attributes

    Summary

    I want to implement a non-breaking method for instanced draw calls without the size limit of uniform arrays. For this, I'd like to use instanced arrays as vertex attributes.

    The proposed API would look as follows:

    let shader = Shader::from_vertex_file(ctx, "path/to/vertex_file")?;
    shader.set_instanced_array(ctx, "a_offsets", offsets.as_slice()); // Offsets could be a Vec of any OpenGL attribute type
    graphics::set_shader(ctx, &shader);
    ...
    mesh.draw_instanced(ctx, 10_000, Vec2::new(16.0, 16.0));
    

    It is very similar to the current uniform approach. Therefore offsets in this concrete example requires at least 10000 entries.

    I am opening an issue for this, as I'd like to inform you about my intentions beforehand and because you may have some feedback or concerns regarding the API design or even overall idea.

    Sidenote: As I am very new to OpenGL and barely having much freetime due to school, side job and my diploma thesis, this contribution may well take some time till it is complete.

    Motivation/Examples

    I'd need this change for a game prototype I am writing. I need to draw the same object 100s of 1000s of times. This leaves quite a performance impact. Instancing would be the ideal solution, but tetra currently only supports instancing using uniform arrays, which have quite a significant size limitation, only allowing some 1000s instances. Using instanced arrays, this limit can practically be (almost) completely removed, allowing even more performance gain due to even less draw calls.

    One concrete use case would be very heavy particle effects, where half a million equal particles need to be drawn at the same time. Or for really suffisticated cellular automata simulations, where cellular states are better not to be stored as color in a texture but a more complex object.

    Alternatives Considered

    Two alternative API designs I've considered are the following:

    let shader = Shader::from_vertex_file(ctx, "path/to/vertex_file")?;
    graphics::set_shader(ctx, &shader);
    ...
    let mut offset_attribute = Vec::new();
    for i in 0..10_000 {
        offset_attribute.push(some_offset); // Push offsets to attribute
    }
    let mut attributes = Vec::new();
    attributes.push((3, offset_attribut)); // Push attribute location and per instance values
    
    graphics::set_instances(ctx, 10_000, attributes); // All draw calls inside will be instanced 10_000 times using the given attributes
    mesh.draw(ctx, Vec2::new(16.0, 16.0)); // Will be drawn 10000 times
    graphics::reset_instances(ctx); // All subsequent draw calls will be handled normally
    

    But I think this is too long and stateful.

    let shader = Shader::from_vertex_file(ctx, "path/to/vertex_file")?;
    graphics::set_shader(ctx, &shader);
    ...
    let mut offset_attribute = Vec::new();
    for i in 0..10_000 {
        offset_attribute.push(some_offset); // Push offsets to attribute
    }
    let mut attributes = Vec::new();
    attributes.push((3, offset_attribut)); // Push attribute location and per instance values
    
    mesh.draw_instanced_array(ctx, 10_000, Vec2::new(16.0, 16.0), attributes); // Draws the mesh 10000 times using the given attributes
    

    This is concise and effective, but in my humble opinion the originally proposed design better integrates into the current "workflow" for instancing.

    Type: Feature Request 
    opened by TimerErTim 3
  • "static-link" doesn't work for "sdl2 0.35.2" on OSX

    Summary

    Hi, I am writing this for anyone with the same issue and looking for a solution to solve/avoid it.

    Summary:

    Buld the app with sdl2 = { version = "0.35.2", features = ["bundled", "static-link"] } on OSX Catalina will throw build error.

    I think It is related to this issue https://github.com/Rust-SDL2/rust-sdl2/issues/1203

    I work around it by changing the version to sdl2 = { version = "0.35.1", features = ["bundled", "static-link"] } sdl2-sys = "=0.35.1"

    Steps to Reproduce

    Build app on OSX (Catalina) with sdl2 = { version = "0.35.2", features = ["bundled", "static-link"] }

    Additional Info

    No response

    Type: Bug 
    opened by Im-Oab 0
Releases(0.7.0)
Owner
Joe Clay
java by day, rust by night • they/them
Joe Clay
Solana Game Server is a decentralized game server running on Solana, designed for game developers

Solana Game Server* is the first decentralized Game Server (aka web3 game server) designed for game devs. (Think web3 SDK for game developers as a ser

Tardigrade Life Sciences, Inc 16 Dec 1, 2022
My first attempt at game programming. This is a simple target shooting game built in macroquad.

sergio My first attempt at game programming. This is a simple target shooting game built in macroquad. Rules Hit a target to increase score by 1 Score

Laz 1 Jan 11, 2022
A game of snake written in Rust using the Bevy game engine, targeting WebGL2

Snake using the Bevy Game Engine Prerequisites cargo install cargo-make Build and serve WASM version Set your local ip address in Makefile.toml (loca

Michael Dorst 0 Dec 26, 2021
A small, portable and extensible game framework written in Rust.

What is This? Crayon is a small, portable and extensible game framework, which loosely inspired by some amazing blogs on bitsquid, molecular and flooo

JK Mao 174 Oct 22, 2022
🎮 A 2D game framework written in Rust

Nova Nova is a 2D game framework written in Rust. ⚠️ Use at your own risk! This framework is designed as a base for my own projects, rather than as a

Joe Clay 10 Dec 17, 2022
A safe, fast and cross-platform 2D component-based game framework written in rust

shura shura is a safe, fast and cross-platform 2D component-based game framework written in rust. shura helps you to manage big games with a component

Andri 28 Jan 17, 2023
A simple Minecraft written in Rust with the Piston game engine

hematite A simple Minecraft written in Rust with the Piston game engine How To Open a World This method is only for personal use. Never distribute cop

PistonDevelopers 1.7k Dec 22, 2022
A simple space shooter game. Runs in the terminal using characters-based UI. Fully written in Rust, using the "ruscii" library.

Thrust - a terminal shooter game Originally created as a project for the "Missing Semester" course at JKU Linz (338.006). The game is entirely written

Mathias Wöß 3 Jan 16, 2023
2-player game made with Rust and "ggez" engine, based on "Conway's Game of Life"

fight-for-your-life A 2-player game based on the "Conway's Game of Life", made with Rust and the game engine "ggez". Create shapes on the grid that wi

Petros 3 Oct 25, 2021
A tetris game I wrote in rust using ncurses. I'm sure that there's a better way to write a tetris game, and the code may be sus, but it techinically works

rustetris A tetris game I wrote in rust using ncurses. I'm sure that there's a better way to write a tetris game, and the code may be sus, but it tech

Eric G 3 Oct 15, 2022
Wasm game of life - A Rust and WebAssembly tutorial implementing the Game of Life

wasm_game_of_life Conway's Game of Life in Rust and WebAssembly Contributing | Chat Built with ?? ?? by The Rust and WebAssembly Working Group About T

Rust and WebAssembly 236 Dec 24, 2022
Conway's Game of Life implemented for Game Boy Advance in Rust

game-of-life An implementation of a Conway's Game of Life environment on GBA. The ultimate game should have two modes: Edit and Run mode which can be

Shane Snover 1 Feb 16, 2022
Heavy - an opinionated, efficient, relatively lightweight, and tightly Lua-integrated game framework for Rust

Heavy - an opinionated, efficient, relatively lightweight, and tightly Lua-integrated game framework for Rust Slow down, upon the teeth of Orange Heav

Shea Leffler 12 Mar 18, 2022
2d Endless Runner Game made with Bevy Game Engine

Cute-runner A 2d Endless Runner Game made with Bevy Game Engine. Table of contents Project Infos Usage Screenshots Disclaimer Project Infos Date: Sept

JoaoMarinho 2 Jul 15, 2022
A game for the game jam "1-Button Jam 2021"

One click ninja A game for the game jam "1-Button Jam 2021" written in Rust with the Bevy engine. A rhythm game, where you play a soldier that can def

Alex Helfet 7 Apr 12, 2022
A game made in one week for the Bevy engine's first game jam

¿Quien es el MechaBurro? An entry for the first Bevy game jam following the theme of "Unfair Advantage." It was made in one week using the wonderful B

mike 20 Dec 23, 2022
A Client/Server game networking plugin using QUIC, for the Bevy game engine.

Bevy Quinnet A Client/Server game networking plugin using QUIC, for the Bevy game engine. Bevy Quinnet QUIC as a game networking protocol Features Roa

Gilles Henaux 65 Feb 20, 2023
Managed game servers, matchmaking, and DDoS mitigation that lets you focus on building your game

Managed game servers, matchmaking, and DDoS mitigation that lets you focus on building your game. Home - Docs - Twitter - Discord ?? Features Everythi

Rivet 58 Jun 25, 2023
Work-in-Progress, opinionated game framework built on Bevy.

Bones A work-in-progress, opinionated game meta-engine built on Bevy. Under development for future use in the Jumpy game, and possibly other FishFolk

Fish Folk 9 Jan 3, 2023