oxide_renderer/texture/fallback.rs
1//! Fallback textures for materials without textures
2
3use wgpu::{Device, Queue};
4
5use super::Texture;
6
7/// A 1x1 white texture used as a fallback when no texture is provided.
8#[derive(Debug)]
9pub struct FallbackTexture {
10 pub texture: Texture,
11}
12
13impl FallbackTexture {
14 /// Creates a new 1x1 white pixel texture.
15 pub fn new(device: &Device, queue: &Queue) -> Self {
16 // 1x1 RGBA white pixel
17 let bytes: [u8; 4] = [255, 255, 255, 255];
18
19 let texture = Texture::from_bytes(
20 device,
21 queue,
22 &bytes,
23 (1, 1),
24 Some("Fallback White Texture"),
25 );
26
27 Self { texture }
28 }
29}