Skip to content

Commit

Permalink
Use similar pipeline blend as egui crates (#37)
Browse files Browse the repository at this point in the history
* Use similar pipeline blend as egui crates

* Modify subpass example to be more useful

* Allow multisampling

* Use config options to allow more versatile use cases (e.g. sample count)

* Update readme

* Remove the srgb flag

* Fix clippy

* Fix fmt

* Get samples from subpass

* Bump version

* Update workflows with cache
  • Loading branch information
hakolao authored Feb 9, 2023
1 parent 7d577d3 commit 33d8a47
Show file tree
Hide file tree
Showing 12 changed files with 503 additions and 102 deletions.
18 changes: 16 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ jobs:
with:
toolchain: nightly
override: true

- name: Rust Lint Cache
uses: Swatinem/rust-cache@v2
with:
shared-key: "${{ runner.os }}-rust-lint"
- run: rustup component add rustfmt
- name: check rustfmt
run: cargo fmt -- --check --color always

- run: rustup component add clippy
- run: cargo fetch
- name: cargo clippy
Expand All @@ -35,6 +37,10 @@ jobs:
- name: Ninja Install
run: pip install ninja
- uses: actions/checkout@v3
- name: Rust Windows Cache
uses: Swatinem/rust-cache@v2
with:
shared-key: "${{ runner.os }}-rust-windows"
- name: Build
run: cargo build --verbose
- name: Run tests
Expand All @@ -43,6 +49,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Rust Linux Cache
uses: Swatinem/rust-cache@v2
with:
shared-key: "${{ runner.os }}-rust-linux"
- name: Build
run: cargo build --verbose
- name: Run tests
Expand All @@ -51,6 +61,10 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Rust Macos Cache
uses: Swatinem/rust-cache@v2
with:
shared-key: "${{ runner.os }}-rust-macos"
- name: Build
run: cargo build --verbose
- name: Run tests
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "egui_winit_vulkano"
version = "0.22.0"
version = "0.23.0"
authors = ["hakolao <[email protected]>"]
edition = "2018"
description = "Egui immediate mode gui integration with winit and Vulkano"
Expand Down
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ The aim of this is to allow a simple enough API to separate UI nicely out of you
2. Create Gui integration with the surface & gfx queue

```rust
// Has its own renderpass (is_overlay = false means that the renderpass will clear the image, true means
// that the caller is responsible for clearing the image
let mut gui = Gui::new(&event_loop, renderer.surface(), None, renderer.queue(), false);
// Has its own renderpass. Modify GuiConfig to determine image clear behavior etc.
let mut gui = Gui::new(&event_loop, renderer.surface(), renderer.queue(), GuiConfig::default());
// Or with subpass. This means that you must create the renderpass yourself. Egui subpass will then draw on your
// image.
let mut gui = Gui::new_with_subpass(&event_loop, renderer.surface(), None, renderer.queue(), subpass);
let mut gui = Gui::new_with_subpass(&event_loop, renderer.surface(), renderer.queue(), subpass, GuiConfig::default());
```

3. Inside your event loop, update `gui` integration with `WindowEvent`
Expand Down Expand Up @@ -67,10 +66,7 @@ sudo apt-get install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev
# Examples

```sh
cargo run --example wholesome
cargo run --example minimal
cargo run --example subpass
cargo run --example demo_app
./run_all_examples.sh
```

# Notes
Expand Down
24 changes: 9 additions & 15 deletions examples/demo_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// notice may not be copied, modified, or distributed except
// according to those terms.

use egui_winit_vulkano::Gui;
use egui_winit_vulkano::{Gui, GuiConfig};
use vulkano_util::{
context::{VulkanoConfig, VulkanoContext},
window::{VulkanoWindows, WindowDescriptor},
Expand Down Expand Up @@ -38,23 +38,17 @@ pub fn main() {
// Create gui as main render pass (no overlay means it clears the image each frame)
let mut gui1 = {
let renderer = windows.get_renderer_mut(window1).unwrap();
Gui::new(
&event_loop,
renderer.surface(),
Some(renderer.swapchain_format()),
renderer.graphics_queue(),
false,
)
Gui::new(&event_loop, renderer.surface(), renderer.graphics_queue(), GuiConfig {
preferred_format: Some(renderer.swapchain_format()),
..Default::default()
})
};
let mut gui2 = {
let renderer = windows.get_renderer_mut(window2).unwrap();
Gui::new(
&event_loop,
renderer.surface(),
Some(renderer.swapchain_format()),
renderer.graphics_queue(),
false,
)
Gui::new(&event_loop, renderer.surface(), renderer.graphics_queue(), GuiConfig {
preferred_format: Some(renderer.swapchain_format()),
..Default::default()
})
};
// Display the demo application that ships with egui.
let mut demo_app1 = egui_demo_lib::DemoWindows::default();
Expand Down
12 changes: 3 additions & 9 deletions examples/minimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#![allow(clippy::eq_op)]

use egui::{ScrollArea, TextEdit, TextStyle};
use egui_winit_vulkano::Gui;
use egui_winit_vulkano::{Gui, GuiConfig};
use vulkano_util::{
context::{VulkanoConfig, VulkanoContext},
window::{VulkanoWindows, WindowDescriptor},
Expand All @@ -37,13 +37,7 @@ pub fn main() {
// Create gui as main render pass (no overlay means it clears the image each frame)
let mut gui = {
let renderer = windows.get_primary_renderer_mut().unwrap();
Gui::new(
&event_loop,
renderer.surface(),
Some(vulkano::format::Format::B8G8R8A8_SRGB),
renderer.graphics_queue(),
false,
)
Gui::new(&event_loop, renderer.surface(), renderer.graphics_queue(), GuiConfig::default())
};
// Create gui state (pass anything your state requires)
let mut code = CODE.to_owned();
Expand Down Expand Up @@ -114,6 +108,6 @@ pub fn main() {
const CODE: &str = r#"
# Some markup
```
let mut gui = Gui::new(&event_loop, renderer.surface(), None, renderer.queue());
let mut gui = Gui::new(&event_loop, renderer.surface(), None, renderer.queue(), SampleCount::Sample1);
```
"#;
Loading

0 comments on commit 33d8a47

Please sign in to comment.