mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 22:00:03 -04:00
Take Glow context using Arc. (#1640)
This allows usage with a Glow context that is passed between threads.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#![allow(unsafe_code)]
|
||||
|
||||
use std::{collections::HashMap, rc::Rc};
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
use egui::{
|
||||
emath::Rect,
|
||||
@@ -42,7 +42,7 @@ impl TextureFilterExt for TextureFilter {
|
||||
/// This struct must be destroyed with [`Painter::destroy`] before dropping, to ensure OpenGL
|
||||
/// objects have been properly deleted and are not leaked.
|
||||
pub struct Painter {
|
||||
gl: Rc<glow::Context>,
|
||||
gl: Arc<glow::Context>,
|
||||
|
||||
max_texture_side: usize,
|
||||
|
||||
@@ -82,7 +82,7 @@ impl Painter {
|
||||
/// * failed to create postprocess on webgl with `sRGB` support
|
||||
/// * failed to create buffer
|
||||
pub fn new(
|
||||
gl: Rc<glow::Context>,
|
||||
gl: Arc<glow::Context>,
|
||||
pp_fb_extent: Option<[i32; 2]>,
|
||||
shader_prefix: &str,
|
||||
) -> Result<Painter, String> {
|
||||
@@ -219,7 +219,7 @@ impl Painter {
|
||||
}
|
||||
|
||||
/// Access the shared glow context.
|
||||
pub fn gl(&self) -> &std::rc::Rc<glow::Context> {
|
||||
pub fn gl(&self) -> &Arc<glow::Context> {
|
||||
&self.gl
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ use glow::HasContext as _;
|
||||
/// Uses a framebuffer to render everything in linear color space and convert it back to `sRGB`
|
||||
/// in a separate "post processing" step
|
||||
pub(crate) struct PostProcess {
|
||||
gl: std::rc::Rc<glow::Context>,
|
||||
gl: std::sync::Arc<glow::Context>,
|
||||
pos_buffer: glow::Buffer,
|
||||
index_buffer: glow::Buffer,
|
||||
vao: crate::vao::VertexArrayObject,
|
||||
@@ -21,7 +21,7 @@ pub(crate) struct PostProcess {
|
||||
|
||||
impl PostProcess {
|
||||
pub(crate) unsafe fn new(
|
||||
gl: std::rc::Rc<glow::Context>,
|
||||
gl: std::sync::Arc<glow::Context>,
|
||||
shader_prefix: &str,
|
||||
is_webgl_1: bool,
|
||||
[width, height]: [i32; 2],
|
||||
|
||||
@@ -12,7 +12,7 @@ pub struct EguiGlow {
|
||||
}
|
||||
|
||||
impl EguiGlow {
|
||||
pub fn new(window: &winit::window::Window, gl: std::rc::Rc<glow::Context>) -> Self {
|
||||
pub fn new(window: &winit::window::Window, gl: std::sync::Arc<glow::Context>) -> Self {
|
||||
let painter = crate::Painter::new(gl, None, "")
|
||||
.map_err(|error| {
|
||||
tracing::error!("error occurred in initializing painter:\n{}", error);
|
||||
|
||||
Reference in New Issue
Block a user