[−][src]Module vxdraw::strtex
Methods and types to control streaming textures
A streaming texture is a texture from which you can spawn sprites. The streaming
part of
the name refers to the texture. The individual pixels of the texture can be read and written
during runtime.
To display this texture we create sprites, which are rectangular views of the texture.
See strtex::Strtex for all operations supported on streaming textures.
Example - Binary counter using a streaming texture
Here is a binary counter using a streaming texture. The counter increments from left to right.
use vxdraw::{prelude::*, strtex::{LayerOptions, Sprite}, void_logger, Color, Deg, Matrix4 ShowWindow, VxDraw}; fn main() { #[cfg(feature = "doctest-headless")] let mut vx = VxDraw::new(void_logger(), ShowWindow::Headless1k); #[cfg(not(feature = "doctest-headless"))] let mut vx = VxDraw::new(void_logger(), ShowWindow::Enable); // Create a new layer/streaming texture, each streaming texture is on its own layer let clock = vx.strtex().add_layer(&LayerOptions::new().width(8)); // Create a new sprite view into this streaming texture let handle = vx.strtex().add(&clock, Sprite::new()); for cnt in 0..=255 { // Set all pixels accoring to the current count (cnt) for idx in 0..8 { let bit_set = cnt >> idx & 1 == 1; vx.strtex().set_pixel(&clock, idx, 0, if bit_set { Color::Rgba(0, (256 / 8 * idx) as u8, 0, 255) } else { Color::Rgba(0, 0, 0, 128) } ); } // Draw the frame vx.draw_frame(); // Sleep here so we can see some animation #[cfg(not(feature = "doctest-headless"))] std::thread::sleep(std::time::Duration::new(0, 16_000_000)); } }
Structs
Handle | A view into a sprite |
Layer | Handle to a texture (layer) |
LayerOptions | Options for creating a layer of a single streaming texture with sprites |
Sprite | Sprite creation builder |
Strtex | Accessor object to all streaming textures |
Enums
Filter | Specify filter options |
FragmentShader | Enum describing which fragment shader to use |
VertexShader | Enum describing which vertex shader to use |
WrapMode | Specify texture wrapping mode |