Disabled usage of the POLYGON_MODE_LINE gpu feature in the examples (#14402)

Fixes #14353
Fixes #14371

---------

Signed-off-by: Sarthak Singh <sarthak.singh99@gmail.com>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: BD103 <59022059+BD103@users.noreply.github.com>
This commit is contained in:
Sarthak Singh 2024-07-30 05:10:39 +05:30 committed by François
parent 587cffdcde
commit 0886e6a302
No known key found for this signature in database
3 changed files with 36 additions and 9 deletions

View file

@ -753,7 +753,8 @@ doc-scrape-examples = true
name = "Lines" name = "Lines"
description = "Create a custom material to draw 3d lines" description = "Create a custom material to draw 3d lines"
category = "3D Rendering" category = "3D Rendering"
wasm = true # WASM does not support the `POLYGON_MODE_LINE` feature.
wasm = false
[[example]] [[example]]
name = "ssao" name = "ssao"

View file

@ -1,16 +1,26 @@
//! Shows how to render simple primitive shapes with a single color. //! Shows how to render simple primitive shapes with a single color.
//!
//! You can toggle wireframes with the space bar except on wasm. Wasm does not support
//! `POLYGON_MODE_LINE` on the gpu.
#[cfg(not(target_arch = "wasm32"))]
use bevy::sprite::{Wireframe2dConfig, Wireframe2dPlugin};
use bevy::{ use bevy::{
prelude::*, prelude::*,
sprite::{MaterialMesh2dBundle, Mesh2dHandle, Wireframe2dConfig, Wireframe2dPlugin}, sprite::{MaterialMesh2dBundle, Mesh2dHandle},
}; };
fn main() { fn main() {
App::new() let mut app = App::new();
.add_plugins((DefaultPlugins, Wireframe2dPlugin)) app.add_plugins((
.add_systems(Startup, setup) DefaultPlugins,
.add_systems(Update, toggle_wireframe) #[cfg(not(target_arch = "wasm32"))]
.run(); Wireframe2dPlugin,
))
.add_systems(Startup, setup);
#[cfg(not(target_arch = "wasm32"))]
app.add_systems(Update, toggle_wireframe);
app.run();
} }
const X_EXTENT: f32 = 900.; const X_EXTENT: f32 = 900.;
@ -57,6 +67,7 @@ fn setup(
}); });
} }
#[cfg(not(target_arch = "wasm32"))]
commands.spawn( commands.spawn(
TextBundle::from_section("Press space to toggle wireframes", TextStyle::default()) TextBundle::from_section("Press space to toggle wireframes", TextStyle::default())
.with_style(Style { .with_style(Style {
@ -68,6 +79,7 @@ fn setup(
); );
} }
#[cfg(not(target_arch = "wasm32"))]
fn toggle_wireframe( fn toggle_wireframe(
mut wireframe_config: ResMut<Wireframe2dConfig>, mut wireframe_config: ResMut<Wireframe2dConfig>,
keyboard: Res<ButtonInput<KeyCode>>, keyboard: Res<ButtonInput<KeyCode>>,

View file

@ -1,11 +1,15 @@
//! This example demonstrates the built-in 3d shapes in Bevy. //! This example demonstrates the built-in 3d shapes in Bevy.
//! The scene includes a patterned texture and a rotation for visualizing the normals and UVs. //! The scene includes a patterned texture and a rotation for visualizing the normals and UVs.
//!
//! You can toggle wireframes with the space bar except on wasm. Wasm does not support
//! `POLYGON_MODE_LINE` on the gpu.
use std::f32::consts::PI; use std::f32::consts::PI;
#[cfg(not(target_arch = "wasm32"))]
use bevy::pbr::wireframe::{WireframeConfig, WireframePlugin};
use bevy::{ use bevy::{
color::palettes::basic::SILVER, color::palettes::basic::SILVER,
pbr::wireframe::{WireframeConfig, WireframePlugin},
prelude::*, prelude::*,
render::{ render::{
render_asset::RenderAssetUsages, render_asset::RenderAssetUsages,
@ -17,10 +21,18 @@ fn main() {
App::new() App::new()
.add_plugins(( .add_plugins((
DefaultPlugins.set(ImagePlugin::default_nearest()), DefaultPlugins.set(ImagePlugin::default_nearest()),
#[cfg(not(target_arch = "wasm32"))]
WireframePlugin, WireframePlugin,
)) ))
.add_systems(Startup, setup) .add_systems(Startup, setup)
.add_systems(Update, (rotate, toggle_wireframe)) .add_systems(
Update,
(
rotate,
#[cfg(not(target_arch = "wasm32"))]
toggle_wireframe,
),
)
.run(); .run();
} }
@ -128,6 +140,7 @@ fn setup(
..default() ..default()
}); });
#[cfg(not(target_arch = "wasm32"))]
commands.spawn( commands.spawn(
TextBundle::from_section("Press space to toggle wireframes", TextStyle::default()) TextBundle::from_section("Press space to toggle wireframes", TextStyle::default())
.with_style(Style { .with_style(Style {
@ -174,6 +187,7 @@ fn uv_debug_texture() -> Image {
) )
} }
#[cfg(not(target_arch = "wasm32"))]
fn toggle_wireframe( fn toggle_wireframe(
mut wireframe_config: ResMut<WireframeConfig>, mut wireframe_config: ResMut<WireframeConfig>,
keyboard: Res<ButtonInput<KeyCode>>, keyboard: Res<ButtonInput<KeyCode>>,