Added in check for web-colors.

This commit is contained in:
Bingus 2023-06-08 10:17:53 -07:00
parent 05e238e9ed
commit af099fa6d7
No known key found for this signature in database
GPG key ID: 5F84D2AA40A9F170

View file

@ -1,3 +1,4 @@
use crate::graphics::color;
use std::borrow::Cow;
use wgpu::util::DeviceExt;
use wgpu::vertex_attr_array;
@ -16,7 +17,7 @@ pub struct Pipeline {
#[repr(C)]
struct Vertex {
ndc: [f32; 2],
texel: [f32; 2],
uv: [f32; 2],
}
impl Pipeline {
@ -36,22 +37,22 @@ impl Pipeline {
//bottom left
Vertex {
ndc: [-1.0, -1.0],
texel: [0.0, 1.0],
uv: [0.0, 1.0],
},
//bottom right
Vertex {
ndc: [1.0, -1.0],
texel: [1.0, 1.0],
uv: [1.0, 1.0],
},
//top right
Vertex {
ndc: [1.0, 1.0],
texel: [1.0, 0.0],
uv: [1.0, 0.0],
},
//top left
Vertex {
ndc: [-1.0, 1.0],
texel: [0.0, 0.0],
uv: [0.0, 0.0],
},
]),
usage: wgpu::BufferUsages::VERTEX,
@ -123,7 +124,11 @@ impl Pipeline {
module: &shader,
entry_point: "fs_main",
targets: &[Some(wgpu::ColorTargetState {
format: wgpu::TextureFormat::Rgba8UnormSrgb,
format: if color::GAMMA_CORRECTION {
wgpu::TextureFormat::Rgba8UnormSrgb
} else {
wgpu::TextureFormat::Rgba8Unorm
},
blend: Some(wgpu::BlendState {
color: wgpu::BlendComponent {
src_factor: wgpu::BlendFactor::SrcAlpha,
@ -171,7 +176,11 @@ impl Pipeline {
mip_level_count: 1,
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: wgpu::TextureFormat::Rgba8UnormSrgb,
format: if color::GAMMA_CORRECTION {
wgpu::TextureFormat::Rgba8UnormSrgb
} else {
wgpu::TextureFormat::Rgba8Unorm
},
usage: wgpu::TextureUsages::RENDER_ATTACHMENT
| wgpu::TextureUsages::COPY_SRC,
view_formats: &[],