From 384eb80e894853b392a74710a0f0dec5283ba207 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Fri, 29 Aug 2025 13:37:53 +0200 Subject: [PATCH] opengl: make mixed device use a non-fatal error --- src/gfx_apis/gl.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gfx_apis/gl.rs b/src/gfx_apis/gl.rs index c2440002..283ee59c 100644 --- a/src/gfx_apis/gl.rs +++ b/src/gfx_apis/gl.rs @@ -329,7 +329,10 @@ fn fill_boxes3(ctx: &GlRenderContext, boxes: &[[f32; 2]], color: &Color) { } fn render_texture(ctx: &GlRenderContext, tex: &CopyTexture) { - let texture = tex.tex.as_gl(); + let Some(texture) = tex.tex.as_gl() else { + log::error!("A non-OpenGL texture was passed into OpenGL"); + return; + }; if !texture.gl.contents_valid.get() { log::error!("Ignoring texture with invalid contents"); return; @@ -437,10 +440,8 @@ fn handle_explicit_sync(ctx: &GlRenderContext, img: Option<&Rc>, sync: } impl dyn GfxTexture { - fn as_gl(&self) -> &Texture { - (self as &dyn Any) - .downcast_ref() - .expect("Non-gl texture passed into gl") + fn as_gl(&self) -> Option<&Texture> { + (self as &dyn Any).downcast_ref() } }