Skip to content

Commit

Permalink
Update egui + disable egui by default (asny#270)
Browse files Browse the repository at this point in the history
* Almost working

* Use released egui (ContextRef + fix fonts)

* Revert example changes

* Fix examples

* Fixes

* Fix web

* egui-gui feature is no longer default

* Update rust.yml

* Avoid ContextRef (Context again impl Send+Sync)

* Avoid changes to canvas

* docs

* Remove unused shaders

* gui module + Readme description
  • Loading branch information
asny authored Aug 3, 2022
1 parent 2336a2f commit 5a857ff
Show file tree
Hide file tree
Showing 20 changed files with 66 additions and 181 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: build

on:
push:
branches:
- master
pull_request:
branches:
- master
Expand Down
15 changes: 12 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ rustdoc-args = ["--cfg", "docsrs"]
targets = ["x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc", "wasm32-unknown-unknown"]

[features]
default = ["window", "egui-gui"]
default = ["window"]
window = ["glutin"] # Window module
egui-gui = ["egui"] # Additional GUI features
egui-gui = ["egui_glow", "egui"] # Additional GUI features

[dependencies]
glow = "0.11"
cgmath = "0.18"
three-d-asset = "0.3"
thiserror = "1"
egui = { version = "0.13", optional = true }
egui = { version = "0.18", optional = true }
egui_glow = { version = "0.18", optional = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
glutin = { version = "0.29", optional = true }
Expand All @@ -51,6 +52,7 @@ path = "examples/triangle/src/main.rs"
[[example]]
name = "screen"
path = "examples/screen/src/main.rs"
required-features = ["egui-gui"]

[[example]]
name = "mandelbrot"
Expand All @@ -75,6 +77,7 @@ path = "examples/texture/src/main.rs"
[[example]]
name = "volume"
path = "examples/volume/src/main.rs"
required-features = ["egui-gui"]

[[example]]
name = "picking"
Expand All @@ -83,22 +86,27 @@ path = "examples/picking/src/main.rs"
[[example]]
name = "environment"
path = "examples/environment/src/main.rs"
required-features = ["egui-gui"]

[[example]]
name = "pbr"
path = "examples/pbr/src/main.rs"
required-features = ["egui-gui"]

[[example]]
name = "lighting"
path = "examples/lighting/src/main.rs"
required-features = ["egui-gui"]

[[example]]
name = "lights"
path = "examples/lights/src/main.rs"
required-features = ["egui-gui"]

[[example]]
name = "image"
path = "examples/image/src/main.rs"
required-features = ["egui-gui"]

[[example]]
name = "fog"
Expand All @@ -111,6 +119,7 @@ path = "examples/fireworks/src/main.rs"
[[example]]
name = "statues"
path = "examples/statues/src/main.rs"
required-features = ["egui-gui"]

[[example]]
name = "wireframe"
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ A OpenGL/WebGL/OpenGL ES renderer which seeks to make graphics simple but still
- tools (2D or 3D)
- games (2D or 3D)

The crate consist of three main modules for drawing, `context`, `core` and `renderer`, and an optional `window` module for easy setup:
The crate consist of three main modules for drawing, `context`, `core` and `renderer`, and an optional `window` module for easy setup and an optional `gui` integration module:

| Module | Description
| :---------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`context`](https://docs.rs/three-d/0/three_d/context/) | Low-level rendering module - requires a solid understanding of graphics concepts. Gives you complete control over both setup and rendering.
| [`core`](https://docs.rs/three-d/0/three_d/core/) | Mid-level rendering module - requires at least some knowledge about graphics concepts. Use this if you want to write your own shaders and but don't want to spend time on setup and error handling. Can be combined with low-level functionality in the `context` module.
| [`renderer`](https://docs.rs/three-d/0/three_d/renderer/) | High-level rendering module - requires no knowledge about graphics concepts. Use this if you just want to draw something on the screen. Features include methods for rendering different types of standard objects with different types of shading. Can be combined seamlessly with the mid-level features in the `core` module as well as functionality in the `context` module. |
| [`window`](https://docs.rs/three-d/0/three_d/window/) (requires the `"window"` feature) | Contains functionality for creating a window on both cross-platform native and web. Also contain render loop, event handling and camera control functionality. Can be replaced by anything that provides an OpenGL or WebGL2 graphics context, for example [eframe](https://github.com/emilk/egui/tree/master/eframe) as shown in [this](https://github.com/emilk/egui/blob/master/eframe/examples/custom_3d_three-d.rs) example.
| [`gui`](https://docs.rs/three-d/0/three_d/gui/) | Contains functionality for using the immediate mode GUI [egui](https://crates.io/crates/egui) (requires the `"egui-gui"` feature).

In addition, the [three-d-asset](https://github.com/asny/three-d-asset) crate enables loading, deserializing, serializing and saving 3D assets, for example 3D models, textures etc.

Expand Down
2 changes: 1 addition & 1 deletion examples/environment/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
three-d = { path = "../../" }
three-d = { path = "../../", features=["egui-gui"] }
three-d-asset = {version = "0.3", features = ["hdr", "http"] }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion examples/headless/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
three-d = { path = "../../", default-features = false, features=["window"] }
three-d = { path = "../../" }

[target.'cfg(target_arch = "wasm32")'.dependencies]
log = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion examples/image/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
three-d = { path = "../../" }
three-d = { path = "../../", features=["egui-gui"] }
three-d-asset = {version = "0.3", features = ["hdr", "http"] }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
three-d = { path = "../../" }
three-d = { path = "../../", features=["egui-gui"] }
three-d-asset = {version = "0.3", features = ["gltf", "jpeg", "http"] }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion examples/lights/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
three-d = { path = "../../" }
three-d = { path = "../../", features=["egui-gui"] }
three-d-asset = {version = "0.3", features = ["gltf", "png", "jpeg", "http"] }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion examples/pbr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
three-d = { path = "../../" }
three-d = { path = "../../", features=["egui-gui"] }
three-d-asset = {version = "0.3", features = ["gltf", "hdr", "jpeg", "http"] }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion examples/screen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
three-d = { path = "../../", default-features = false, features=["window", "egui-gui"] }
three-d = { path = "../../", features=["egui-gui"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
log = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion examples/shapes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
three-d = { path = "../../", default-features = false, features=["window"] }
three-d = { path = "../../" }

[target.'cfg(target_arch = "wasm32")'.dependencies]
log = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion examples/shapes2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
three-d = { path = "../../", default-features = false, features=["window"] }
three-d = { path = "../../" }

[target.'cfg(target_arch = "wasm32")'.dependencies]
log = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion examples/statues/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
three-d = { path = "../../" }
three-d = { path = "../../", features=["egui-gui"] }
three-d-asset = {version = "0.3", features = ["obj", "png", "http"] }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion examples/triangle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
three-d = { path = "../../", default-features = false, features=["window"] }
three-d = { path = "../../" }

[target.'cfg(target_arch = "wasm32")'.dependencies]
log = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion examples/volume/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
three-d = { path = "../../" }
three-d = { path = "../../", features=["egui-gui"] }
three-d-asset = {version = "0.3", features = ["vol", "http"] }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion src/core/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ impl std::fmt::Debug for Context {
}

impl std::ops::Deref for Context {
type Target = crate::context::Context;
type Target = Arc<crate::context::Context>;
fn deref(&self) -> &Self::Target {
&self.context
}
Expand Down
Loading

0 comments on commit 5a857ff

Please sign in to comment.