-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
eframe glow backend: Clear render target before calling
App::update
(…
- Loading branch information
Showing
7 changed files
with
146 additions
and
60 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "test_inline_glow_paint" | ||
version = "0.1.0" | ||
authors = ["Emil Ernerfeldt <[email protected]>"] | ||
license = "MIT OR Apache-2.0" | ||
edition = "2021" | ||
rust-version = "1.72" | ||
publish = false | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
eframe = { path = "../../crates/eframe" } | ||
env_logger = "0.10" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Test that we can paint to the screen using glow directly. | ||
|
||
use eframe::egui; | ||
use eframe::glow; | ||
|
||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`). | ||
let options = eframe::NativeOptions { | ||
renderer: eframe::Renderer::Glow, | ||
..Default::default() | ||
}; | ||
eframe::run_native( | ||
"My test app", | ||
options, | ||
Box::new(|_cc| Box::<MyTestApp>::default()), | ||
)?; | ||
Ok(()) | ||
} | ||
|
||
#[derive(Default)] | ||
struct MyTestApp {} | ||
|
||
impl eframe::App for MyTestApp { | ||
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) { | ||
use glow::HasContext as _; | ||
let gl = frame.gl().unwrap(); | ||
|
||
#[allow(unsafe_code)] | ||
unsafe { | ||
gl.disable(glow::SCISSOR_TEST); | ||
gl.viewport(0, 0, 100, 100); | ||
gl.clear_color(1.0, 0.0, 1.0, 1.0); // purple | ||
gl.clear(glow::COLOR_BUFFER_BIT); | ||
} | ||
|
||
egui::Window::new("Floating Window").show(ctx, |ui| { | ||
ui.label("The background should be purple."); | ||
}); | ||
} | ||
} |