Skip to content

Commit

Permalink
add simple gui.
Browse files Browse the repository at this point in the history
  • Loading branch information
leddoo committed Mar 25, 2022
1 parent ed7b142 commit fc2ba04
Show file tree
Hide file tree
Showing 19 changed files with 6,060 additions and 104 deletions.
4,060 changes: 4,060 additions & 0 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bevy = {git = "https://github.com/bevyengine/bevy.git", rev = "b697e73"}
bevy = {git = "https://github.com/bevyengine/bevy.git", rev = "b697e73", features = ["dynamic"]}
bevy_egui = { path = "deps/bevy_egui-0.12.1" }
bevy_fly_camera = "0.8.0"
bytemuck = "*"
rand = "*"
futures-lite = "1.12.0"
futures-lite = "1.12.0"

[profile.release]
debug = 1
6 changes: 6 additions & 0 deletions deps/bevy_egui-0.12.1/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Rust
/target
Cargo.lock

# JetBrains
.idea
35 changes: 35 additions & 0 deletions deps/bevy_egui-0.12.1/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[package]
name = "bevy_egui"
version = "0.12.1"
authors = ["mvlabat <[email protected]>"]
description = "A plugin for Egui integration into Bevy"
license = "MIT"
edition = "2021"
repository = "https://github.com/mvlabat/bevy_egui"
exclude = ["assets/**/*", ".github/**/*"]

[package.metadata.docs.rs]
all-features = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
default = ["manage_clipboard", "open_url"]
manage_clipboard = ["arboard", "thread_local"]
multi_threaded = ["egui/multi_threaded"]
open_url = ["webbrowser"]

[dependencies]
bevy = {git = "https://github.com/bevyengine/bevy.git", rev = "b697e73", features = ["dynamic"]}
egui = { version = "0.17", features = ["convert_bytemuck"] }
webbrowser = { version = "0.5.5", optional = true }
winit = { version = "0.26.0", features = ["x11"], default-features = false }
bytemuck = { version = "1.7.0", features = ["derive"] }
wgpu = "0.12.0"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
arboard = { version = "2.0.1", optional = true }
thread_local = { version = "1.1.0", optional = true }

[dev-dependencies]
once_cell = "1.9.0"
version-sync = "0.9.2"
21 changes: 21 additions & 0 deletions deps/bevy_egui-0.12.1/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Vladyslav Batyrenko

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.
51 changes: 51 additions & 0 deletions deps/bevy_egui-0.12.1/src/egui.wgsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
struct EguiTransform {
scale: vec2<f32>;
translation: vec2<f32>;
};

[[group(0), binding(0)]]
var<uniform> egui_transform: EguiTransform;

struct VertexOutput {
[[location(0)]] uv: vec2<f32>;
[[location(1)]] color: vec4<f32>;
[[builtin(position)]] pos: vec4<f32>;
};

// 0-1 linear from 0-255 sRGB
fn linear_from_srgb(srgb: vec3<f32>) -> vec3<f32> {
let cutoff = vec3<f32>(srgb < vec3<f32>(10.31475));
let lower = srgb / vec3<f32>(3294.6);
let higher = pow((srgb + vec3<f32>(14.025)) / vec3<f32>(269.025), vec3<f32>(2.4));
return mix(higher, lower, cutoff);
}

// 0-1 linear from 0-255 sRGBA
fn linear_from_srgba(srgba: vec4<f32>) -> vec4<f32> {
return vec4<f32>(linear_from_srgb(srgba.rgb), srgba.a / 255.0);
}

[[stage(vertex)]]
fn vs_main(
[[location(0)]] position: vec2<f32>,
[[location(1)]] uv: vec2<f32>,
[[location(2)]] color: vec4<f32>, // 0-1 range
) -> VertexOutput {
var out: VertexOutput;
out.uv = uv;
out.color = linear_from_srgba(color * 255.0);
out.pos = vec4<f32>(position * egui_transform.scale + egui_transform.translation, 0.0, 1.0);
return out;
}

[[group(1), binding(0)]]
var t_egui: texture_2d<f32>;
[[group(1), binding(1)]]
var s_egui: sampler;

[[stage(fragment)]]
fn fs_main(in: VertexOutput) -> [[location(0)]] vec4<f32> {
let color = in.color * textureSample(t_egui, s_egui, in.uv);

return color;
}
Loading

0 comments on commit fc2ba04

Please sign in to comment.