#[repr(C)]pub struct Color {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}Fields§
§r: f32§g: f32§b: f32§a: f32Implementations§
Source§impl Color
impl Color
pub const ALICEBLUE: Color
pub const ANTIQUEWHITE: Color
pub const AQUA: Color
pub const AQUAMARINE: Color
pub const AZURE: Color
pub const BEIGE: Color
pub const BISQUE: Color
pub const BLACK: Color
pub const BLANCHEDALMOND: Color
pub const BLUE: Color
pub const BLUEVIOLET: Color
pub const BROWN: Color
pub const BURLYWOOD: Color
pub const CADETBLUE: Color
pub const CHARTREUSE: Color
pub const CHOCOLATE: Color
pub const CORAL: Color
pub const CORNFLOWERBLUE: Color
pub const CORNSILK: Color
pub const CRIMSON: Color
pub const CYAN: Color
pub const DARKBLUE: Color
pub const DARKCYAN: Color
pub const DARKGOLDENROD: Color
pub const DARKGRAY: Color
pub const DARKGREEN: Color
pub const DARKKHAKI: Color
pub const DARKMAGENTA: Color
pub const DARKOLIVEGREEN: Color
pub const DARKORANGE: Color
pub const DARKORCHID: Color
pub const DARKRED: Color
pub const DARKSALMON: Color
pub const DARKSEAGREEN: Color
pub const DARKSLATEBLUE: Color
pub const DARKSLATEGRAY: Color
pub const DARKTURQUOISE: Color
pub const DARKVIOLET: Color
pub const DEEPPINK: Color
pub const DEEPSKYBLUE: Color
pub const DIMGRAY: Color
pub const DODGERBLUE: Color
pub const FIREBRICK: Color
pub const FLORALWHITE: Color
pub const FORESTGREEN: Color
pub const FUCHSIA: Color
pub const GAINSBORO: Color
pub const GHOSTWHITE: Color
pub const GOLD: Color
pub const GOLDENROD: Color
pub const GRAY: Color
pub const GREEN: Color
pub const GREENYELLOW: Color
pub const HONEYDEW: Color
pub const HOTPINK: Color
pub const INDIANRED: Color
pub const INDIGO: Color
pub const IVORY: Color
pub const KHAKI: Color
pub const LAVENDER: Color
pub const LAVENDERBLUSH: Color
pub const LAWNGREEN: Color
pub const LEMONCHIFFON: Color
pub const LIGHTBLUE: Color
pub const LIGHTCORAL: Color
pub const LIGHTCYAN: Color
pub const LIGHTGOLDENRODYELLOW: Color
pub const LIGHTGRAY: Color
pub const LIGHTGREEN: Color
pub const LIGHTPINK: Color
pub const LIGHTSALMON: Color
pub const LIGHTSEAGREEN: Color
pub const LIGHTSKYBLUE: Color
pub const LIGHTSLATEGRAY: Color
pub const LIGHTSTEELBLUE: Color
pub const LIGHTYELLOW: Color
pub const LIME: Color
pub const LIMEGREEN: Color
pub const LINEN: Color
pub const MAGENTA: Color
pub const MAROON: Color
pub const MEDIUMAQUAMARINE: Color
pub const MEDIUMBLUE: Color
pub const MEDIUMORCHID: Color
pub const MEDIUMPURPLE: Color
pub const MEDIUMSEAGREEN: Color
pub const MEDIUMSLATEBLUE: Color
pub const MEDIUMSPRINGGREEN: Color
pub const MEDIUMTURQUOISE: Color
pub const MEDIUMVIOLETRED: Color
pub const MIDNIGHTBLUE: Color
pub const MINTCREAM: Color
pub const MISTYROSE: Color
pub const MOCCASIN: Color
pub const NAVAJOWHITE: Color
pub const NAVY: Color
pub const OLDLACE: Color
pub const OLIVE: Color
pub const OLIVEDRAB: Color
pub const ORANGE: Color
pub const ORANGERED: Color
pub const ORCHID: Color
pub const PALEGOLDENROD: Color
pub const PALEGREEN: Color
pub const PALETURQUOISE: Color
pub const PALEVIOLETRED: Color
pub const PAPAYAWHIP: Color
pub const PEACHPUFF: Color
pub const PERU: Color
pub const PINK: Color
pub const PLUM: Color
pub const POWDERBLUE: Color
pub const PURPLE: Color
pub const RED: Color
pub const ROSYBROWN: Color
pub const ROYALBLUE: Color
pub const SADDLEBROWN: Color
pub const SALMON: Color
pub const SANDYBROWN: Color
pub const SEAGREEN: Color
pub const SEASHELL: Color
pub const SIENNA: Color
pub const SILVER: Color
pub const SKYBLUE: Color
pub const SLATEBLUE: Color
pub const SLATEGRAY: Color
pub const SNOW: Color
pub const SPRINGGREEN: Color
pub const STEELBLUE: Color
pub const TAN: Color
pub const TEAL: Color
pub const THISTLE: Color
pub const TOMATO: Color
pub const TURQUOISE: Color
pub const VIOLET: Color
pub const WHEAT: Color
pub const WHITE: Color
pub const WHITESMOKE: Color
pub const YELLOW: Color
pub const YELLOWGREEN: Color
pub const TRANSPARENT: Color
Sourcepub fn new<T: ToPrimitive>(r: T, g: T, b: T, a: T) -> Self
pub fn new<T: ToPrimitive>(r: T, g: T, b: T, a: T) -> Self
Creates a new color with the given red, green, blue, and alpha values. Values should be in the range [0.0, 1.0].
Examples found in repository?
examples/pipeline.rs (line 122)
61fn main() {
62 let mut runner = est_render::runner::new().expect("Failed to create runner");
63 let mut window = runner
64 .create_window("Engine Example", Point2::new(800, 600))
65 .build()
66 .expect("Failed to create window");
67
68 let mut gpu = est_render::gpu::new(Some(&mut window))
69 .build()
70 .expect("Failed to create GPU");
71
72 let mut msaa_texture = gpu
73 .create_texture()
74 .set_render_target(Point2::new(800, 600), None)
75 .set_sample_count(SampleCount::SampleCount4)
76 .build()
77 .expect("Failed to create MSAA texture");
78
79 let blank_texture = gpu
80 .create_texture()
81 .set_raw_image(
82 &[255u8; 4],
83 Point2::new(1, 1),
84 TextureFormat::Bgra8Unorm,
85 )
86 .set_usage(TextureUsage::Sampler)
87 .build()
88 .expect("Failed to create blank texture");
89
90 let shader = gpu
91 .create_graphics_shader()
92 .set_vertex_code(VERTEX_DRAWING_SHADER)
93 .set_fragment_code(FRAGMENT_DRAWING_SHADER)
94 .build()
95 .expect("Failed to create graphics shader");
96
97 let compute_shader = gpu
98 .create_compute_shader()
99 .set_source(COMPUTE_NOOP_SHADER)
100 .build()
101 .expect("Failed to create compute shader");
102
103 let pipeline = gpu
104 .create_render_pipeline()
105 .set_shader(Some(&shader))
106 .set_blend(Some(&BlendState::ALPHA_BLEND))
107 .set_attachment_texture(0, 0, Some(&blank_texture))
108 .set_attachment_sampler(0, 1, Some(&TextureSampler::DEFAULT))
109 .build()
110 .expect("Failed to create render pipeline");
111
112 let compute_pipeline = gpu
113 .create_compute_pipeline()
114 .set_shader(Some(&compute_shader))
115 .build()
116 .expect("Failed to create compute pipeline");
117
118 // Triangle vertices
119 let vertices = vec![
120 Vertex {
121 position: Vector3::new(-0.5, -0.5, 0.0),
122 color: Color::new(1.0, 0.0, 0.0, 1.0),
123 texcoord: Vector2::new(0.0, 1.0),
124 },
125 Vertex {
126 position: Vector3::new(0.5, -0.5, 0.0),
127 color: Color::new(0.0, 1.0, 0.0, 1.0),
128 texcoord: Vector2::new(1.0, 1.0),
129 },
130 Vertex {
131 position: Vector3::new(0.0, 0.5, 0.0),
132 color: Color::new(0.0, 0.0, 1.0, 1.0),
133 texcoord: Vector2::new(0.5, 0.0),
134 },
135 ];
136
137 let indexes = vec![0u16, 1u16, 2u16];
138
139 let vbo = gpu
140 .create_buffer()
141 .set_data_vec(vertices)
142 .set_usage(BufferUsage::VERTEX)
143 .build()
144 .expect("Failed to create vertex buffer");
145
146 let ibo = gpu
147 .create_buffer()
148 .set_data_vec(indexes)
149 .set_usage(BufferUsage::INDEX)
150 .build()
151 .expect("Failed to create index buffer");
152
153 while runner.pool_events(PollMode::WaitDraw) {
154 for event in runner.get_events() {
155 match event {
156 Event::KeyboardInput {
157 window_id,
158 key,
159 pressed,
160 } => {
161 if *window_id == window.id() && key == "Escape" && *pressed {
162 window.quit();
163 }
164 }
165 Event::WindowResized { window_id: _, size } => {
166 if size.x <= 0 || size.y <= 0 {
167 continue; // Skip invalid sizes
168 }
169
170 msaa_texture = gpu
171 .create_texture()
172 .set_render_target(Point2::new(size.x as u32, size.y as u32), None)
173 .set_sample_count(SampleCount::SampleCount4)
174 .build()
175 .expect("Failed to resize MSAA texture");
176 }
177 Event::RedrawRequested { window_id: _ } => {
178 if let Ok(mut cmd) = gpu.begin_command() {
179 if let Ok(mut cm) = cmd.begin_computepass() {
180 cm.set_pipeline(Some(&compute_pipeline));
181 cm.dispatch(1, 1, 1);
182 }
183
184 if let Ok(mut rp) = cmd.begin_renderpass() {
185 rp.set_clear_color(Color::BLACK);
186 rp.push_msaa_texture(&msaa_texture);
187
188 rp.set_pipeline(Some(&pipeline));
189 rp.set_gpu_buffer(Some(&vbo), Some(&ibo));
190 rp.draw_indexed(0..3, 0, 1);
191 }
192 }
193
194 window.request_redraw();
195 }
196 _ => {}
197 }
198 }
199 }
200}pub const fn new_const(r: f32, g: f32, b: f32, a: f32) -> Self
Sourcepub fn from_rgb<T: ToPrimitive>(r: T, g: T, b: T, a: T) -> Self
pub fn from_rgb<T: ToPrimitive>(r: T, g: T, b: T, a: T) -> Self
Creates a new color from RGBA values in the range [0, 255].
Sourcepub fn into_rgb(self) -> [u8; 4]
pub fn into_rgb(self) -> [u8; 4]
Converts the color to an array of RGBA values in the range [0, 255].
Sourcepub fn into_linear(self) -> Self
pub fn into_linear(self) -> Self
Converts the color from sRGB to linear RGB color space.
Trait Implementations§
Source§impl AddAssign<Color> for f32
impl AddAssign<Color> for f32
Source§fn add_assign(&mut self, other: Color)
fn add_assign(&mut self, other: Color)
Performs the
+= operation. Read moreSource§impl AddAssign<f32> for Color
impl AddAssign<f32> for Color
Source§fn add_assign(&mut self, other: f32)
fn add_assign(&mut self, other: f32)
Performs the
+= operation. Read moreSource§impl AddAssign for Color
impl AddAssign for Color
Source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
Performs the
+= operation. Read moreSource§impl DivAssign<Color> for f32
impl DivAssign<Color> for f32
Source§fn div_assign(&mut self, other: Color)
fn div_assign(&mut self, other: Color)
Performs the
/= operation. Read moreSource§impl DivAssign<f32> for Color
impl DivAssign<f32> for Color
Source§fn div_assign(&mut self, other: f32)
fn div_assign(&mut self, other: f32)
Performs the
/= operation. Read moreSource§impl DivAssign for Color
impl DivAssign for Color
Source§fn div_assign(&mut self, other: Self)
fn div_assign(&mut self, other: Self)
Performs the
/= operation. Read moreSource§impl MulAssign<Color> for f32
impl MulAssign<Color> for f32
Source§fn mul_assign(&mut self, other: Color)
fn mul_assign(&mut self, other: Color)
Performs the
*= operation. Read moreSource§impl MulAssign<f32> for Color
impl MulAssign<f32> for Color
Source§fn mul_assign(&mut self, other: f32)
fn mul_assign(&mut self, other: f32)
Performs the
*= operation. Read moreSource§impl MulAssign for Color
impl MulAssign for Color
Source§fn mul_assign(&mut self, other: Self)
fn mul_assign(&mut self, other: Self)
Performs the
*= operation. Read moreSource§impl SubAssign<Color> for f32
impl SubAssign<Color> for f32
Source§fn sub_assign(&mut self, other: Color)
fn sub_assign(&mut self, other: Color)
Performs the
-= operation. Read moreSource§impl SubAssign<f32> for Color
impl SubAssign<f32> for Color
Source§fn sub_assign(&mut self, other: f32)
fn sub_assign(&mut self, other: f32)
Performs the
-= operation. Read moreSource§impl SubAssign for Color
impl SubAssign for Color
Source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
Performs the
-= operation. Read moreimpl Copy for Color
impl Eq for Color
impl Pod for Color
Auto Trait Implementations§
impl Freeze for Color
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnwindSafe for Color
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
If this function returns true, then it must be valid to reinterpret
bits
as &Self.Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().