Egui bindings for macroquad

Overview

egui bindings for macroquad

Latest version Documentation MIT Apache

This is the easiest way to use egui. Just two functions!

Web demo.

Usage

You need to call ui when you need to get information from ui. Then, only after that function you must call draw function when you need to draw egui contents. All this functions should be called each frame and once per frame.

Here is the small example on how to use this library:

use macroquad::prelude::*;

#[macroquad::main("egui with macroquad")]
async fn main() {
    loop {
        clear_background(WHITE);

        // Process keys, mouse etc.

        egui_macroquad::ui(|egui_ctx| {
            egui::Window::new("egui ❤ macroquad")
                .show(egui_ctx, |ui| {
                    ui.label("Test");
                });
        });

        // Draw things before egui

        egui_macroquad::draw();
        
        // Draw things after egui

        next_frame().await;
    }
}

Building

Building for native and for web works just as in macroquad. You can read about it here. Or you could look at building example at egui-miniquad.

But for wasm you will need to include two more .js files, which is plugins for quads, instruction is written here.

Comments
  • [Bug] Can't interact with anything if click out of menubutton

    [Bug] Can't interact with anything if click out of menubutton

    I will be saying menubutton in this post, but it applies to comboboxes as well, and probably anything that opens a drop-down menu. If you open the menubutton, you can select options from the drop-down menu. If you click outside this menu, it closes. Simple stuff. My issue is that the menubutton works fine if you click in the same Egui window to close it, but if you click anywhere else, you can no longer interact with not just the menubutton, but anything in that Egui window. Not like it gets disabled, it looks just fine, you just can't click it. I can send code if needed, I don't think it's too necessary. Any ideas? Thanks!

    opened by Siliwolf 6
  • Fix miniquad scaling compatibility

    Fix miniquad scaling compatibility

    It seems egui-macroquad is not currently compatible with the latest egui-miniquad after https://github.com/not-fl3/egui-miniquad/pull/40 was merged. ~~I'm basing this off of https://github.com/optozorax/egui-macroquad/pull/20 as that seems to be related to the original macroquad issue.~~

    ~~I'm not entirely sure if that is required, but the PR doesn't compile with miniquad after the fix.~~

    This PR makes egui-macroquad work with latest egui-miniquad again, and based on my quick testing it seems UI scaling works with these changes.

    ~~Maybe a question for @buxx or @emilk, does the egui_mq_cfg still make sense after those changes?~~

    ~~I'm also not sure if mq::Context should be exposed up via egui_macroquad::ui(...), but since this causes existing code to fail to compile I thought it probably shouldn't? It's not a big change, but I don't know the reason why it was added in the first place, so it's hard for me to judge if it should be ignored at the level of egui-macroquad or passed up as a breaking change.~~

    edit: Removed the egui_mq_cfg from #20 since it's not needed anymore

    opened by darthdeus 5
  • update egui and egui-miniquad versions

    update egui and egui-miniquad versions

    Hello,

    Unable to run demo with current master :

    ➜  egui-macroquad git:(master) ✗ cargo run --example demo         
       Compiling egui-macroquad v0.11.0 (/home/bastiensevajol/Projets/egui-macroquad)
    error[E0277]: expected a `FnOnce<(&egui::Context,)>` closure, found `F`
       --> src/lib.rs:81:37
        |
    81  |         self.0.run(gl.quad_context, f);
        |                ---                  ^ expected an `FnOnce<(&egui::Context,)>` closure, found `F`
        |                |
        |                required by a bound introduced by this call
        |
        = note: expected a closure taking 2 arguments, but one taking 1 argument was given
    note: required by a bound in `EguiMq::run`
       --> /home/bastiensevajol/.cargo/registry/src/github.com-1ecc6299db9ec823/egui-miniquad-0.11.0/src/lib.rs:145:66
        |
    145 |     pub fn run(&mut self, mq_ctx: &mut mq::Context, run_ui: impl FnOnce(&egui::Context)) {
        |                                                                  ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `EguiMq::run`
    
    error[E0061]: this function takes 3 arguments but 2 arguments were supplied
       --> src/lib.rs:113:16
        |
    113 |         self.0.mouse_motion_event(x, y);
        |                ^^^^^^^^^^^^^^^^^^ -  - supplied 2 arguments
        |                |
        |                expected 3 arguments
        |
    note: associated function defined here
       --> /home/bastiensevajol/.cargo/registry/src/github.com-1ecc6299db9ec823/egui-miniquad-0.11.0/src/lib.rs:204:12
        |
    204 |     pub fn mouse_motion_event(&mut self, ctx: &mut mq::Context, x: f32, y: f32) {
        |            ^^^^^^^^^^^^^^^^^^
    
    error[E0061]: this function takes 3 arguments but 2 arguments were supplied
       --> src/lib.rs:117:16
        |
    117 |         self.0.mouse_wheel_event(dx, dy);
        |                ^^^^^^^^^^^^^^^^^ --  -- supplied 2 arguments
        |                |
        |                expected 3 arguments
        |
    note: associated function defined here
       --> /home/bastiensevajol/.cargo/registry/src/github.com-1ecc6299db9ec823/egui-miniquad-0.11.0/src/lib.rs:210:12
        |
    210 |     pub fn mouse_wheel_event(&mut self, _ctx: &mut mq::Context, dx: f32, dy: f32) {
        |            ^^^^^^^^^^^^^^^^^
    
    Some errors have detailed explanations: E0061, E0277.
    For more information about an error, try `rustc --explain E0061`.
    error: could not compile `egui-macroquad` due to 3 previous errors
    

    Update egui and egui-miniquad dependencies solved most of the problems (see MR). But now I got :

    ➜  egui-macroquad git:(follow-dependencies) ✗ cargo run --example demo        
       Compiling egui-macroquad v0.11.0 (/home/bastiensevajol/Projets/egui-macroquad)
    error[E0308]: mismatched types
      --> examples/demo.rs:30:38
       |
    30 |                 egui_demo_windows.ui(egui_ctx);
       |                                      ^^^^^^^^ expected struct `egui::context::Context`, found struct `egui::Context`
       |
       = note: expected reference `&egui::context::Context`
                  found reference `&egui::Context`
       = note: perhaps two different versions of crate `egui` are being used?
    
    For more information about this error, try `rustc --explain E0308`.
    error: could not compile `egui-macroquad` due to previous error
    

    Not sure to understand what to do :thinking:

    opened by buxx 4
  • Compiler error when building demo examples

    Compiler error when building demo examples

    Hi guys! Tried to build demo example using on MacOs 12.4, but it fails with 3 errors:

    error[E0277]: expected a FnOnce<(&egui::Context,)> closure, found F --> src/lib.rs:81:37 | 81 | self.0.run(gl.quad_context, f); | --- ^ expected an FnOnce<(&egui::Context,)> closure, found F | | | required by a bound introduced by this call | = note: expected a closure taking 2 arguments, but one taking 1 argument was given note: required by a bound in EguiMq::run --> /Users/*/.cargo/registry/src/github.com-1ecc6299db9ec823/egui-miniquad-0.11.0/src/lib.rs:145:66 | 145 | pub fn run(&mut self, mq_ctx: &mut mq::Context, run_ui: impl FnOnce(&egui::Context)) { | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in EguiMq::run

    error[E0061]: this function takes 3 arguments but 2 arguments were supplied --> src/lib.rs:113:16 | 113 | self.0.mouse_motion_event(x, y); | ^^^^^^^^^^^^^^^^^^ - - supplied 2 arguments | | | expected 3 arguments | note: associated function defined here --> /Users/*/.cargo/registry/src/github.com-1ecc6299db9ec823/egui-miniquad-0.11.0/src/lib.rs:204:12 | 204 | pub fn mouse_motion_event(&mut self, ctx: &mut mq::Context, x: f32, y: f32) { | ^^^^^^^^^^^^^^^^^^

    error[E0061]: this function takes 3 arguments but 2 arguments were supplied --> src/lib.rs:117:16 | 117 | self.0.mouse_wheel_event(dx, dy); | ^^^^^^^^^^^^^^^^^ -- -- supplied 2 arguments | | | expected 3 arguments | note: associated function defined here --> /Users/*/.cargo/registry/src/github.com-1ecc6299db9ec823/egui-miniquad-0.11.0/src/lib.rs:210:12 | 210 | pub fn mouse_wheel_event(&mut self, _ctx: &mut mq::Context, dx: f32, dy: f32) { | ^^^^^^^^^^^^^^^^^

    Some errors have detailed explanations: E0061, E0277. For more information about an error, try rustc --explain E0061. error: could not compile egui-macroquad due to 3 previous errors

    opened by EvoTeamDevelop 3
  • Build error on new Macroquad version

    Build error on new Macroquad version

    error: failed to select a version for `miniquad`.
        ... required by package `egui-miniquad v0.8.0`
        ... which satisfies dependency `egui-miniquad = "^0.8.0"` of package `egui-macroquad v0.8.0`
        ... which satisfies dependency `egui-macroquad = "^0.8.0"` of package `rrr-render v0.0.1 (L:\git\flashflashrevolution\games\rrr\crates\render)`
    versions that meet the requirements `=0.3.0-alpha.43` are: 0.3.0-alpha.43
    
    all possible versions conflict with previously selected packages.
    
      previously selected package `miniquad v0.3.0-alpha.42`
        ... which satisfies dependency `miniquad = "=0.3.0-alpha.42"` of package `macroquad v0.3.13`
        ... which satisfies dependency `macroquad = "^0.3.13"` of package `rrr-render v0.0.1 (L:\git\flashflashrevolution\games\rrr\crates\render)`
    
    failed to select a version for `miniquad` which could resolve this conflict
    
    [dependencies]
    rrr = { path = "../rrr", version = "0.0.1" }
    egui = "0.16.1"
    egui-macroquad = "0.8.0"
    macroquad = { version = "0.3.13", default-features = false }
    

    The change is macroquad 0.3.6 to 0.3.13. I'm not sure if this is a egui dependency declaration problem, or a macroquad/miniquad one, or if it's me.

    opened by Zageron 3
  • [Bug] Resizing doesn't work

    [Bug] Resizing doesn't work

    When trying to resize windows/panels it doesn't work diagonally and horizontally, but vertically it, for some reason, decides to not resize itself but to move on the Y axis following the cursor

    opened by alexmozaidze 3
  • Unable to install  latest version with macroquad = 0.3.15

    Unable to install latest version with macroquad = 0.3.15

    With:

    [dependencies]
    "macroquad" = "=0.3.15"
    "egui-macroquad" = "0.9.0"
    

    I am unable to install:

        Updating crates.io index
    error: failed to select a version for `miniquad`.
        ... required by package `egui-miniquad v0.9.0`
        ... which satisfies dependency `egui-miniquad = "^0.9.0"` of package `egui-macroquad v0.9.0`
        ... which satisfies dependency `egui-macroquad = "^0.9.0"` of package `routemaster v0.1.0 (/home/jack/git/routemaster)
    `
    versions that meet the requirements `=0.3.0-alpha.43` are: 0.3.0-alpha.43
    
    all possible versions conflict with previously selected packages.
    
      previously selected package `miniquad v0.3.0-alpha.45`
        ... which satisfies dependency `miniquad = "=0.3.0-alpha.45"` of package `macroquad v0.3.15`
        ... which satisfies dependency `macroquad = "=0.3.15"` of package `routemaster v0.1.0 (/home/jack/git/routemaster)`
    
    failed to select a version for `miniquad` which could resolve this conflict
    

    I think this is because egui-miniquad has a dep on miniquad alpha 0.43, but macroquad now depends on miniquad alpha 0.45.

    Is it possible to push a new version of egui-miniquad or maybe ease the dependency strictness?

    Thanks!

    opened by jackfranklin 2
  • Rendering Broken

    Rendering Broken

    This is what happens when I run the example in a fresh clone of the repo:

    image

    image

    All of the input works, but the rendering is messed up. I tried running the egui-miniquad example too, to see if the issue was there instead, but the egui-miniquad build displayed normally.

    opened by LagMeester4000 2
  • Update version of macroquad in Cargo.toml

    Update version of macroquad in Cargo.toml

    It's a bit out of date =)

    Could you set it to use "any version above ..." rather than use an explicit version? That way it would work with all current and future versions of Macroquad!

    opened by Pebaz 2
  • Usage of egui Context.set_pixels_per_point don't work

    Usage of egui Context.set_pixels_per_point don't work

    Hello,

    I'm trying to use Context.set_pixels_per_point don't work function, but it has no effect. Example :by modifying README example :

            egui_macroquad::ui(|egui_ctx| {
                egui::Window::new("egui ❤ macroquad").show(egui_ctx, |ui| {
                    ui.ctx().set_pixels_per_point(2.0);
                    ui.label("Test");
                });
            });
    

    Note : I tried to call it with egui_macroquad::cfg(|egui_cfg| egui_cfg.set_pixels_per_point(2.0)); without effect too.

    Do you know why it has no effect ?

    opened by buxx 1
  • Consider turning off default-features for macroquad

    Consider turning off default-features for macroquad

    I'm attempting to use kira with both egui and macroquad. Unfortunately macroquad and kira have a native dependency conflict.

    The solution is to disable the default audio feature on macroquad but I'm unable to do so because egui-macroquad keeps them on.

    opened by noc7c9 1
  • set macroquads default features to false

    set macroquads default features to false

    Sets default features for macroquad to false since egui-macroquad doesn't need audio (macroquad default features is only audio)

    also noticed #10 which for some reason got reverted back at some point

    opened by Ricky12Awesome 0
  • Set render target

    Set render target

    Is it possible for equi-macroquad to use the current macroquad camera settings? Ideally it would use the camera's zoom/rotation/etc, but most important is the current camera's render_target. I want to be able to render egui to a texture, but it's not currently possible with egui-macroquad.

    opened by brianwp3000 1
Owner
ilya sheprut
youtu.be/1q0sHf_n_2Y
ilya sheprut
A presentation about egui, implemented in egui

egui presentation A presentation about egui, implemented in egui. You can view the presentation at https://emilk.github.io/egui_presentation/. TODO Li

Emil Ernerfeldt 9 Aug 24, 2023
Egui bindings for miniquad

egui bindings for miniquad native On Linux you first must run apt install libx11-dev libxi-dev libgl1-mesa-dev (miniquad dependencies). cargo run --re

Fedor Logachev 48 Dec 28, 2022
This project attempts to allow the creation of reusable egui-themes

egui stylist Note this project is considered to be experimental and -- while used in personal projects -- may have API breaking changes without warnin

Jacobsky 22 Dec 1, 2022
A simple GUI version of the pH calibration tool written in egui, based on the eframe template.

caliphui A simple GUI version of the pH calibration tool written in egui, based on the eframe template. Usage Native binaries are provided under relea

Peter Dunne 0 Dec 29, 2021
FLTK frontend for Egui WGPU backend.

Egui FLTK Frontend FLTK Frontend for Egui WGPU Backend On linux Debian/Ubuntu, make sure to install the latest main requirements: sudo apt-get update

Adia Robbie 5 Oct 25, 2022
egui: an easy-to-use immediate mode GUI in pure Rust

?? egui: an easy-to-use GUI in pure Rust egui is a simple, fast, and highly portable immediate mode GUI library for Rust. egui runs on the web, native

Emil Ernerfeldt 12.6k Jan 3, 2023
D3D11 backend for egui library. Presumably for mods/cheats development

D3D11 backend for egui library. Presumably for mods/cheats development. Currently few features from egui are missing. WIP.

sy1ntexx 24 Jan 4, 2023
Render egui with skia!

Skia backend for egui This is a drawing backend for egui that uses skia-safe. Usage Have a look at the metal or cpu examples to get started. Run the e

null 14 Dec 19, 2022
a day-planner/calendar app based on egui

Malakal Malakal is a day planner application. I crafted it because I was not able to find a comfortable calendar application for Linux. I myself have

null 5 Dec 21, 2022
Example showing how to use tokio and egui together.

Example using tokio with egui This example uses reqwest to send an HTTP request to httpbin. The parsed response contains an increment value (as provid

Jay Oster 10 Dec 25, 2022
A render-backend independant egui backend for sdl2

A Sdl2 + Egui Backend An egui backend for sdl2 unbound to any renderer-backend. You can include it like so: [dependencies] egui_sdl2_platform = "0.1.0

null 4 Dec 16, 2022
egui backend for D3D9.

egui-d3d9 egui backend for D3D9. Primarily intended for source games like CS:GO and GMod. It's not perfect by far, but it'll do. This is a rewrite of

unknowntrojan 6 Dec 25, 2022
A tool for creating egui Visuals (themes).

egui-visuals-utility A tool for creating egui Visuals (themes). The code is rather messy and might crash but it seems to work. To load the theme use s

null 7 Jan 13, 2023
egui port to Car Thing (and maybe an alternative Car Thing UI?)

tt This project contains a port of egui to the Spotify Car Thing although in the future I also plan for it to contain a custom Car Thing UI. Technical

Andy Bao 7 Dec 30, 2022
Create dynamic grid-based layouts for egui

egui_grid Create dynamic grid layouts for egui. Grids are flexible, easy to create, with behavior similar to egui_extra's strip creation. They're comp

null 6 Apr 18, 2023
Provides event handling for egui in SDL2 window applications.

egui-sdl2-event Provides event handling for egui when SDL2 is used as the windowing system. This crate does not perform any rendering, but it can be c

Valtteri Vallius 8 Feb 15, 2023
An interactive JSON tree visualiser for egui, with search and highlight functionality.

egui_json_tree An interactive JSON tree visualiser for egui, with search and highlight functionality. Usage use egui::{Color32}; use egui_json_tree::{

null 13 Sep 1, 2023
egui integration for ash (Vulkan).

egui-ash egui integration for ash (Vulkan). This crate natively supports the multi-viewports feature added since version 0.24 of egui. You can use gpu

Orito Itsuki 6 Dec 24, 2023
A Vulkan renderer for egui using Ash.

egui-ash-renderer A Vulkan renderer for egui using Ash. This is meant to add support for egui in your existing Vulkan/ash applications. Not a full efr

Adrien Bennadji 4 Apr 10, 2024