summaryrefslogtreecommitdiff
path: root/alligator_render/examples
diff options
context:
space:
mode:
Diffstat (limited to 'alligator_render/examples')
-rw-r--r--alligator_render/examples/black.rs21
-rw-r--r--alligator_render/examples/bmp.rs88
-rw-r--r--alligator_render/examples/res/gator.bmpbin0 -> 750054 bytes
-rw-r--r--alligator_render/examples/res/gator.ffbin0 -> 2000016 bytes
-rw-r--r--alligator_render/examples/res/ghost.icobin0 -> 67646 bytes
5 files changed, 109 insertions, 0 deletions
diff --git a/alligator_render/examples/black.rs b/alligator_render/examples/black.rs
new file mode 100644
index 0000000..c66b080
--- /dev/null
+++ b/alligator_render/examples/black.rs
@@ -0,0 +1,21 @@
+#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
+
+use alligator_render::{RenderWindowConfig, Renderer};
+
+fn update(_renderer: &mut Renderer) {}
+
+fn main() {
+ let start = std::time::Instant::now();
+ // configure the render window
+ let config = RenderWindowConfig {
+ //vsync: false,
+ //mode: alligator_render::config::WindowMode::BorderlessFullscreen,
+ title: "Black Screen.exe",
+ ..Default::default()
+ };
+
+ let renderer = Renderer::new(&config).unwrap();
+ println!("Startup time: {:?}", start.elapsed());
+
+ renderer.run(&update);
+}
diff --git a/alligator_render/examples/bmp.rs b/alligator_render/examples/bmp.rs
new file mode 100644
index 0000000..af71863
--- /dev/null
+++ b/alligator_render/examples/bmp.rs
@@ -0,0 +1,88 @@
+#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
+
+use std::num::NonZeroU32;
+
+use alligator_render::{ImageFormat, Instance, RenderWindowConfig, Renderer};
+
+#[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 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 mut renderer = Renderer::new(&config).unwrap();
+
+ // render the alligator
+ let gator = include_bytes!("res/gator.ff");
+ let gator_id = renderer
+ .textures_mut()
+ .load_from_memory(gator, ImageFormat::Farbfeld)
+ .unwrap();
+ let gator_width = renderer.textures().texture_width(gator_id).unwrap();
+ let gator_height = renderer.textures().texture_height(gator_id).unwrap();
+ let gator_x = renderer.textures().texture_x(gator_id).unwrap();
+ let gator_y = renderer.textures().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 = renderer
+ .textures_mut()
+ .load_from_memory(icon, ImageFormat::Ico)
+ .unwrap();
+ let icon_width = renderer.textures().texture_width(icon_id).unwrap();
+ let icon_height = renderer.textures().texture_height(icon_id).unwrap();
+ let icon_x = renderer.textures().texture_x(icon_id).unwrap();
+ let icon_y = renderer.textures().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 = renderer
+ .textures_mut()
+ .load_from_memory(gator, ImageFormat::Bmp)
+ .unwrap();
+ let gator_width = renderer.textures().texture_width(gator_id).unwrap();
+ let gator_height = renderer.textures().texture_height(gator_id).unwrap();
+ let gator_x = renderer.textures().texture_x(gator_id).unwrap();
+ let gator_y = renderer.textures().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);
+}
diff --git a/alligator_render/examples/res/gator.bmp b/alligator_render/examples/res/gator.bmp
new file mode 100644
index 0000000..e752b56
--- /dev/null
+++ b/alligator_render/examples/res/gator.bmp
Binary files differ
diff --git a/alligator_render/examples/res/gator.ff b/alligator_render/examples/res/gator.ff
new file mode 100644
index 0000000..aac1bcb
--- /dev/null
+++ b/alligator_render/examples/res/gator.ff
Binary files differ
diff --git a/alligator_render/examples/res/ghost.ico b/alligator_render/examples/res/ghost.ico
new file mode 100644
index 0000000..102de00
--- /dev/null
+++ b/alligator_render/examples/res/ghost.ico
Binary files differ