summaryrefslogtreecommitdiff
path: root/alligator_render/examples/bmp.rs
diff options
context:
space:
mode:
authorMicha White <botahamec@outlook.com>2023-02-13 00:24:07 -0500
committerMicha White <botahamec@outlook.com>2023-02-13 00:24:07 -0500
commit861b467b95be55db3a42182b77dba944869bf49f (patch)
treef58057d5ab9ad53601332981a31553b0ad05fe1b /alligator_render/examples/bmp.rs
parentc31d51487082c6cf243ecd10da71a15a78d41add (diff)
Rename the subdirectories
Diffstat (limited to 'alligator_render/examples/bmp.rs')
-rw-r--r--alligator_render/examples/bmp.rs94
1 files changed, 0 insertions, 94 deletions
diff --git a/alligator_render/examples/bmp.rs b/alligator_render/examples/bmp.rs
deleted file mode 100644
index 9d864d0..0000000
--- a/alligator_render/examples/bmp.rs
+++ /dev/null
@@ -1,94 +0,0 @@
-#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
-
-use std::{num::NonZeroU32, sync::Arc};
-
-use alligator_render::{Instance, RenderWindowConfig, Renderer};
-use alligator_resources::texture::{ImageFormat, TextureManager, TextureManagerConfig};
-
-#[profiling::function]
-fn update(renderer: &mut Renderer) {
- let camera = renderer.camera_mut();
- camera.set_rotation(camera.rotation() + 0.01);
-}
-
-fn main() {
- // configure the render window
- let render_config = RenderWindowConfig {
- title: "Bumper Stickers",
- instance_capacity: 2,
- default_width: NonZeroU32::new(1280).unwrap(),
- default_height: NonZeroU32::new(720).unwrap(),
- //mode: alligator_render::config::WindowMode::BorderlessFullscreen,
- //vsync: false,
- ..Default::default()
- };
-
- let texture_config = TextureManagerConfig {
- initial_capacity: 3,
- max_size: 3_000_000,
- };
-
- let texture_manager = Arc::new(TextureManager::new(&texture_config));
- let mut renderer = Renderer::new(&render_config, texture_manager.clone()).unwrap();
-
- // render the alligator
- let gator = include_bytes!("res/gator.ff");
- let gator_id = texture_manager
- .load_from_memory(gator, ImageFormat::Farbfeld)
- .unwrap();
- renderer.textures_mut().load_texture(gator_id).unwrap();
- let gator_width = renderer.textures_mut().texture_width(gator_id).unwrap();
- let gator_height = renderer.textures_mut().texture_height(gator_id).unwrap();
- let gator_x = renderer.textures_mut().texture_x(gator_id).unwrap();
- let gator_y = renderer.textures_mut().texture_y(gator_id).unwrap();
-
- renderer.instances_mut().push_instance(Instance {
- position: [-0.5, 0.5],
- size: [1.5; 2],
- z_index: 1.0,
- texture_size: [gator_width, gator_height],
- texture_coordinates: [gator_x, gator_y],
- ..Default::default()
- });
-
- // render the ghost
- let icon = include_bytes!("res/ghost.ico");
- let icon_id = texture_manager
- .load_from_memory(icon, ImageFormat::Ico)
- .unwrap();
- renderer.textures_mut().load_texture(icon_id).unwrap();
- let icon_width = renderer.textures_mut().texture_width(icon_id).unwrap();
- let icon_height = renderer.textures_mut().texture_height(icon_id).unwrap();
- let icon_x = renderer.textures_mut().texture_x(icon_id).unwrap();
- let icon_y = renderer.textures_mut().texture_y(icon_id).unwrap();
-
- renderer.instances_mut().push_instance(Instance {
- position: [0.5, 0.5],
- size: [0.75; 2],
- rotation: 0.5,
- z_index: 1.0,
- texture_size: [icon_width, icon_height],
- texture_coordinates: [icon_x, icon_y],
- ..Default::default()
- });
-
- // render the bitmap alligator
- let gator = include_bytes!("res/gator.bmp");
- let gator_id = texture_manager
- .load_from_memory(gator, ImageFormat::Bmp)
- .unwrap();
- let gator_width = renderer.textures_mut().texture_width(gator_id).unwrap();
- let gator_height = renderer.textures_mut().texture_height(gator_id).unwrap();
- let gator_x = renderer.textures_mut().texture_x(gator_id).unwrap();
- let gator_y = renderer.textures_mut().texture_y(gator_id).unwrap();
-
- renderer.instances_mut().push_instance(Instance {
- position: [0.0, -0.5],
- size: [1.5; 2],
- texture_size: [gator_width, gator_height],
- texture_coordinates: [gator_x, gator_y],
- ..Default::default()
- });
-
- renderer.run(update);
-}