gui: Split OpenGL into OpenGL (glow), OpenGL ES (wgpu)

This commit is contained in:
Luke Street 2025-07-29 20:49:09 -06:00
parent c327ed3ea8
commit f5d3d5f10a
3 changed files with 10 additions and 5 deletions

View File

@ -465,7 +465,7 @@ impl App {
Backend::Vulkan => "Vulkan", Backend::Vulkan => "Vulkan",
Backend::Metal => "Metal", Backend::Metal => "Metal",
Backend::Dx12 => "DirectX 12", Backend::Dx12 => "DirectX 12",
Backend::Gl => "OpenGL", Backend::Gl => "OpenGL ES",
Backend::BrowserWebGpu => "WebGPU", Backend::BrowserWebGpu => "WebGPU",
} }
.to_string(); .to_string();
@ -474,7 +474,7 @@ impl App {
#[cfg(feature = "glow")] #[cfg(feature = "glow")]
if let Some(gl) = &cc.gl { if let Some(gl) = &cc.gl {
use eframe::glow::HasContext; use eframe::glow::HasContext;
app.view_state.graphics_state.active_backend = "OpenGL (Fallback)".to_string(); app.view_state.graphics_state.active_backend = "OpenGL".to_string();
app.view_state.graphics_state.active_device = app.view_state.graphics_state.active_device =
unsafe { gl.get_parameter_string(0x1F01) }; // GL_RENDERER unsafe { gl.get_parameter_string(0x1F01) }; // GL_RENDERER
} }

View File

@ -95,7 +95,8 @@ fn main() -> ExitCode {
GraphicsBackend::Dx12 => wgpu::Backends::DX12, GraphicsBackend::Dx12 => wgpu::Backends::DX12,
GraphicsBackend::Metal => wgpu::Backends::METAL, GraphicsBackend::Metal => wgpu::Backends::METAL,
GraphicsBackend::Vulkan => wgpu::Backends::VULKAN, GraphicsBackend::Vulkan => wgpu::Backends::VULKAN,
GraphicsBackend::OpenGL => wgpu::Backends::GL, GraphicsBackend::OpenGLES => wgpu::Backends::GL,
GraphicsBackend::OpenGL => wgpu::Backends::empty(),
}; };
WgpuSetup::CreateNew(setup) WgpuSetup::CreateNew(setup)
} }

View File

@ -26,7 +26,8 @@ pub enum GraphicsBackend {
Vulkan, Vulkan,
Metal, Metal,
Dx12, Dx12,
OpenGL, OpenGL, // glow
OpenGLES, // wgpu
} }
static ALL_BACKENDS: &[GraphicsBackend] = &[ static ALL_BACKENDS: &[GraphicsBackend] = &[
@ -35,6 +36,7 @@ static ALL_BACKENDS: &[GraphicsBackend] = &[
GraphicsBackend::Metal, GraphicsBackend::Metal,
GraphicsBackend::Dx12, GraphicsBackend::Dx12,
GraphicsBackend::OpenGL, GraphicsBackend::OpenGL,
GraphicsBackend::OpenGLES,
]; ];
#[derive(Clone, Debug, Default, serde::Deserialize, serde::Serialize)] #[derive(Clone, Debug, Default, serde::Deserialize, serde::Serialize)]
@ -67,7 +69,8 @@ impl GraphicsBackend {
} }
GraphicsBackend::Metal => cfg!(all(feature = "wgpu", target_os = "macos")), GraphicsBackend::Metal => cfg!(all(feature = "wgpu", target_os = "macos")),
GraphicsBackend::Dx12 => cfg!(all(feature = "wgpu", target_os = "windows")), GraphicsBackend::Dx12 => cfg!(all(feature = "wgpu", target_os = "windows")),
GraphicsBackend::OpenGL => true, GraphicsBackend::OpenGL => cfg!(feature = "glow"),
GraphicsBackend::OpenGLES => cfg!(all(feature = "wgpu", target_os = "windows")),
} }
} }
@ -78,6 +81,7 @@ impl GraphicsBackend {
GraphicsBackend::Metal => "Metal", GraphicsBackend::Metal => "Metal",
GraphicsBackend::Dx12 => "DirectX 12", GraphicsBackend::Dx12 => "DirectX 12",
GraphicsBackend::OpenGL => "OpenGL", GraphicsBackend::OpenGL => "OpenGL",
GraphicsBackend::OpenGLES => "OpenGL ES",
} }
} }
} }