summaryrefslogtreecommitdiff
path: root/engine/src
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-06-04 19:27:34 +0200
committerHampusM <hampus@hampusmat.com>2026-06-04 19:27:34 +0200
commit370db2f2c4406f3373be9065cda8fcdb3929b693 (patch)
treed196dfd100ed22b91bcd88e2dc7720cc788de642 /engine/src
parentc5f04bc1ff1b96d3aa1f2e46693b0b2726167586 (diff)
refactor(engine): remove cfg aliasesHEADmaster
Diffstat (limited to 'engine/src')
-rw-r--r--engine/src/rendering/backend/opengl/glutin_compat.rs34
-rw-r--r--engine/src/windowing.rs29
-rw-r--r--engine/src/windowing/window/platform.rs2
3 files changed, 30 insertions, 35 deletions
diff --git a/engine/src/rendering/backend/opengl/glutin_compat.rs b/engine/src/rendering/backend/opengl/glutin_compat.rs
index 4cdf18a..ab8df90 100644
--- a/engine/src/rendering/backend/opengl/glutin_compat.rs
+++ b/engine/src/rendering/backend/opengl/glutin_compat.rs
@@ -35,15 +35,16 @@
use glutin::config::{Config, ConfigTemplateBuilder};
use glutin::display::{Display, DisplayApiPreference};
use glutin::error::Error as GlutinError;
-// #[cfg(x11_platform)]
-// use glutin::platform::x11::X11GlConfigExt;
use glutin::prelude::*;
use raw_window_handle::{DisplayHandle, RawWindowHandle, WindowHandle};
use crate::windowing::window::CreationAttributes as WindowCreationAttributes;
-#[cfg(all(not(egl_backend), not(glx_backend), not(wgl_backend), not(cgl_backend)))]
-compile_error!("Please select at least one api backend");
+#[cfg(all(not(windows), not(target_os = "macos"), not(target_os = "linux")))]
+compile_error!("Unsupported platform");
+
+#[cfg(target_family = "wasm")]
+compile_error!("Wasm targets are not supported");
/// The helper to perform [`Display`] creation and OpenGL platform
/// bootstrapping with the help of [`winit`] with little to no platform specific
@@ -115,7 +116,7 @@ impl DisplayBuilder
ConfigPickerFn: FnOnce(Box<dyn Iterator<Item = Config> + '_>) -> Option<Config>,
{
// XXX with WGL backend window should be created first.
- let raw_window_handle = if cfg!(wgl_backend) {
+ let raw_window_handle = if cfg!(windows) {
let Some(window_handle) = window_handle else {
return Err(Error::WindowRequired);
};
@@ -132,7 +133,7 @@ impl DisplayBuilder
// XXX the native window must be passed to config picker when WGL is used
// otherwise very limited OpenGL features will be supported.
let template_builder = if let Some(raw_window_handle) =
- raw_window_handle.filter(|_| cfg!(wgl_backend))
+ raw_window_handle.filter(|_| cfg!(windows))
{
template_builder.compatible_with_native_window(raw_window_handle)
} else {
@@ -142,7 +143,7 @@ impl DisplayBuilder
let template = template_builder.build();
// SAFETY: The RawWindowHandle passed on the config template
- // (when cfg(wgl_backend)) will always point to a valid object since it is
+ // (when cfg(windows)) will always point to a valid object since it is
// derived from the window_handle argument which when Some is a WindowHandle and
// WindowHandles always point to a valid object
let gl_configs = unsafe { gl_display.find_configs(template) }
@@ -152,7 +153,7 @@ impl DisplayBuilder
config_picker_fn(gl_configs).ok_or(Error::NoConfigPicked)?;
let window_attrs = cfg_select! {
- wgl_backend => { self.window_attributes }
+ windows => { self.window_attributes }
_ => {
finalize_window_creation_attrs(self.window_attributes, &picked_gl_config)
}
@@ -185,7 +186,7 @@ fn create_display(
) -> Result<Display, GlutinError>
{
let preference = cfg_select! {
- all(wgl_backend, egl_backend) => {
+ windows => {
match _api_preference {
ApiPreference::PreferEgl => {
DisplayApiPreference::EglThenWgl(_raw_window_handle)
@@ -195,7 +196,7 @@ fn create_display(
}
}
}
- all(egl_backend, glx_backend) => {
+ target_os = "linux" => {
match _api_preference {
ApiPreference::PreferEgl => DisplayApiPreference::EglThenGlx(Box::new(
crate::windowing::window::platform::x11::register_xlib_error_hook,
@@ -205,14 +206,7 @@ fn create_display(
)),
}
}
- wgl_backend => { DisplayApiPreference::Wgl(_raw_window_handle) }
- cgl_backend => { DisplayApiPreference::Cgl }
- glx_backend => {
- DisplayApiPreference::Glx(Box::new(
- crate::windowing::window::platform::x11::register_xlib_error_hook,
- ))
- }
- egl_backend => { DisplayApiPreference::Egl }
+ target_os = "macos" => { DisplayApiPreference::Cgl }
};
let handle = display_handle.as_raw();
@@ -226,7 +220,7 @@ fn create_display(
///
/// [`Window`]: winit::window::Window
/// [`Config`]: glutin::config::Config
-#[cfg(not(wgl_backend))]
+#[cfg(not(windows))]
fn finalize_window_creation_attrs(
mut attributes: WindowCreationAttributes,
gl_config: &Config,
@@ -237,7 +231,7 @@ fn finalize_window_creation_attrs(
attributes = attributes.with_transparent(false);
}
- #[cfg(x11_platform)]
+ #[cfg(target_os = "linux")]
if let Some(x11_visual) = glutin::platform::x11::X11GlConfigExt::x11_visual(gl_config)
{
return attributes.with_x11_visual(x11_visual.visual_id() as _);
diff --git a/engine/src/windowing.rs b/engine/src/windowing.rs
index bf29453..3163869 100644
--- a/engine/src/windowing.rs
+++ b/engine/src/windowing.rs
@@ -499,20 +499,21 @@ fn create_event_loop() -> Result<EventLoop<()>, EventLoopError>
{
let mut event_loop_builder = EventLoop::builder();
- #[cfg(any(x11_platform, wayland_platform))]
- winit::platform::x11::EventLoopBuilderExtX11::with_any_thread(
- &mut event_loop_builder,
- true,
- );
-
- #[cfg(windows)]
- winit::platform::windows::EventLoopBuilderExtWindows::with_any_thread(
- &mut event_loop_builder,
- true,
- );
-
- #[cfg(not(any(x11_platform, wayland_platform, windows)))]
- compile_error!("Unsupported platform");
+ cfg_select! {
+ target_os = "linux" => {
+ winit::platform::x11::EventLoopBuilderExtX11::with_any_thread(
+ &mut event_loop_builder,
+ true,
+ );
+ }
+ windows => {
+ winit::platform::windows::EventLoopBuilderExtWindows::with_any_thread(
+ &mut event_loop_builder,
+ true,
+ );
+ }
+ _ => { compile_error!("Unsupported platform") }
+ }
event_loop_builder.build()
}
diff --git a/engine/src/windowing/window/platform.rs b/engine/src/windowing/window/platform.rs
index f3908a2..1f38f3b 100644
--- a/engine/src/windowing/window/platform.rs
+++ b/engine/src/windowing/window/platform.rs
@@ -1,4 +1,4 @@
-#[cfg(x11_platform)]
+#[cfg(target_os = "linux")]
pub mod x11
{
use std::ffi::c_void;