Skip to content

Commit

Permalink
Merge pull request #29 from jbrd/bevy-0.13
Browse files Browse the repository at this point in the history
Issue #27 - Update for Bevy 0.13
  • Loading branch information
jbrd authored Apr 11, 2024
2 parents e346778 + f430907 commit 699e443
Show file tree
Hide file tree
Showing 7 changed files with 1,084 additions and 152 deletions.
22 changes: 18 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,25 @@ categories = ["game-engines", "graphics", "gui", "rendering"]
description = "A Dear ImGui integration for the Bevy game engine."
readme = "README.md"
repository = "https://github.com/jbrd/bevy_mod_imgui"
rust-version = "1.70.0"
rust-version = "1.77.0"
exclude = [".github/", ".gitignore"]

[dependencies]
bevy = "0.12.0"
imgui = "0.11.0"
imgui-wgpu = "0.24.0"
wgpu = "0.17.1"
wgpu = "0.19.3"

# For imgui_wgpu_rs_local
# imgui-wgpu = "0.24.0" # temporarily bundling imgui-wgpu with this crate
bytemuck = "1"
log = "0.4"
smallvec = "1"

[dependencies.bevy]
version = "0.13"
default-features = false
features = ["bevy_core_pipeline", "bevy_render"]

[dev-dependencies.bevy]
version = "0.13"
default-features = false
features = ["bevy_core_pipeline", "bevy_pbr", "bevy_render"]
27 changes: 22 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ If there is a large enough appetite for this crate, I may consider taking it fur

## Compatibility Table

|`bevy_mod_imgui`|`bevy` |`wgpu` |`imgui` |`imgui-wgpu`|
|----------------|--------|--------|--------|------------|
| 0.3.* (NEXT) | 0.13.* | 0.19.* | TBC | TBC |
| 0.2.* | 0.12.* | 0.17.1 | 0.11.* | 0.24.* |
| 0.1.* | 0.11.* | 0.16.* | 0.11.* | 0.23.* |
|`bevy_mod_imgui`|`bevy` |`wgpu` |`imgui` |`imgui-wgpu` |
|----------------|--------|--------|--------|------------------|
| 0.3.* | 0.13.* | 0.19.* | 0.11.* | 0.24.0 (bundled) |
| 0.2.* | 0.12.* | 0.17.1 | 0.11.* | 0.24.* |
| 0.1.* | 0.11.* | 0.16.* | 0.11.* | 0.23.* |

## Changelog

* `0.3.0` - Updated dependencies for Bevy `0.13.0` with bundled `imgui-wgpu-rs`.
* `0.2.1` - Fix Issue #20 - unchecked window lookup which could cause panic during exit
* `0.2.0` - Updated dependencies for Bevy `0.12.0`
* `0.1.1` - Fix Issue #20 - unchecked window lookup which could cause panic during exit (backported from `0.2.1`)
Expand All @@ -59,3 +60,19 @@ All code in this repository is permissively dual-licensed under:

* MIT License - [LICENSE-MIT](LICENSE-MIT)
* Apache License, Version 2.0 - [LICENSE-APACHE](LICENSE-APACHE)

## Bundled Software License Notices

### imgui-wgpu-rs

This software contains portions of code derived from [imgui-wgpu-rs](https://github.com/Yatekii/imgui-wgpu-rs/tree/master).
https://github.com/Yatekii/imgui-wgpu-rs/tree/master
Licensed under the Apache License

Copyright (c) 2019 Steven Wittens

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 changes: 4 additions & 8 deletions examples/hello-world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,20 @@ fn setup(
) {
// plane
commands.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Plane {
size: 5.0,
subdivisions: 1,
})),
material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()),
mesh: meshes.add(Plane3d::default().mesh().size(5.0, 5.0)),
material: materials.add(Color::rgb(0.3, 0.5, 0.3)),
..default()
});
// cube
commands.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()),
mesh: meshes.add(Cuboid::default().mesh()),
material: materials.add(Color::rgb(0.8, 0.7, 0.6)),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..default()
});
// light
commands.spawn(PointLightBundle {
point_light: PointLight {
intensity: 1500.0,
shadows_enabled: true,
..default()
},
Expand Down
13 changes: 13 additions & 0 deletions src/imgui_wgpu_rs_local/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Bundled Module - imgui_wgpu_rs 0.24.0

This software contains portions of code derived from [imgui-wgpu-rs](https://github.com/Yatekii/imgui-wgpu-rs/tree/master).
https://github.com/Yatekii/imgui-wgpu-rs/tree/master
Licensed under the Apache License

Copyright (c) 2019 Steven Wittens

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
81 changes: 81 additions & 0 deletions src/imgui_wgpu_rs_local/imgui.wgsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
Copyright (c) 2019 Steven Wittens

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

struct Uniforms {
u_Matrix: mat4x4<f32>,
};

struct VertexInput {
@location(0) a_Pos: vec2<f32>,
@location(1) a_UV: vec2<f32>,
@location(2) a_Color: vec4<f32>,
};

struct VertexOutput {
@location(0) v_UV: vec2<f32>,
@location(1) v_Color: vec4<f32>,
@builtin(position) v_Position: vec4<f32>,
};

@group(0) @binding(0)
var<uniform> uniforms: Uniforms;

@vertex
fn vs_main(in: VertexInput) -> VertexOutput {
var out: VertexOutput;
out.v_UV = in.a_UV;
out.v_Color = in.a_Color;
out.v_Position = uniforms.u_Matrix * vec4<f32>(in.a_Pos.xy, 0.0, 1.0);
return out;
}

struct FragmentOutput {
@location(0) o_Target: vec4<f32>,
};

@group(1) @binding(0)
var u_Texture: texture_2d<f32>;
@group(1) @binding(1)
var u_Sampler: sampler;

fn srgb_to_linear(srgb: vec4<f32>) -> vec4<f32> {
let color_srgb = srgb.rgb;
let selector = ceil(color_srgb - 0.04045); // 0 if under value, 1 if over
let under = color_srgb / 12.92;
let over = pow((color_srgb + 0.055) / 1.055, vec3<f32>(2.4));
let result = mix(under, over, selector);
return vec4<f32>(result, srgb.a);
}

@fragment
fn fs_main_linear(in: VertexOutput) -> FragmentOutput {
let color = srgb_to_linear(in.v_Color);

return FragmentOutput(color * textureSample(u_Texture, u_Sampler, in.v_UV));
}

@fragment
fn fs_main_srgb(in: VertexOutput) -> FragmentOutput {
let color = in.v_Color;

return FragmentOutput(color * textureSample(u_Texture, u_Sampler, in.v_UV));
}
Loading

0 comments on commit 699e443

Please sign in to comment.