#raylib #imgui #graphics #gamedev

raylib_imgui_rs

A Raylib integration with DearImGui in Rust!

2 unstable releases

new 0.2.0 Dec 2, 2024
0.1.0 Nov 15, 2024

#201 in Graphics APIs

Download history 98/week @ 2024-11-13 13/week @ 2024-11-20 97/week @ 2024-11-27

208 downloads per month

Custom license

24KB
429 lines

raylib_imgui_rs

Crates.io Version

raylib logo animated A Raylib integration with DearImGui in Rust!

Based on rlImgui

Setup:

In Cargo.toml:

[dependencies]
raylib_imgui_rs = "<Latest version here>"

In main.rs:

use imgui::{Context, FontSource};
use raylib::prelude::*;
use raylib_imgui_rs::Renderer;

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

    let mut imgui = Context::create();
    imgui.fonts().add_font(&[FontSource::DefaultFontData { config: None }]);

    let mut renderer = Renderer::create(&mut imgui, &mut rl, &thread);

    while !rl.window_should_close() {
        renderer.update(&mut imgui, &mut rl);
        
        {
            let ui = imgui.new_frame();
            // Draw Imgui stuff here
        }
        
        {
            let mut d = rl.begin_drawing(&thread);

            d.clear_background(Color::WHITE);
            // Draw raylib stuff here

            renderer.render(&mut imgui, &mut d);
        }
    }
}

Dependencies

~18–26MB
~410K SLoC