summaryrefslogtreecommitdiff
path: root/examples/square.rs
diff options
context:
space:
mode:
authorMicha White <botahamec@outlook.com>2022-10-02 13:49:47 -0400
committerMicha White <botahamec@outlook.com>2022-10-02 13:49:47 -0400
commit511d3873f5f567c97eecd69d186bb4f93f927d58 (patch)
treeb99779ade2b150d51d800b7275a0c310a7591439 /examples/square.rs
parent39e36dd10cd7a335897e66e0f613d0191e7f9eba (diff)
Hacked in textures
Diffstat (limited to 'examples/square.rs')
-rw-r--r--examples/square.rs19
1 files changed, 17 insertions, 2 deletions
diff --git a/examples/square.rs b/examples/square.rs
index d03a4a9..f95bd00 100644
--- a/examples/square.rs
+++ b/examples/square.rs
@@ -1,6 +1,6 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
-use alligator_render::{Instance, RenderWindowConfig, Renderer};
+use alligator_render::{ImageFormat, Instance, RenderWindowConfig, Renderer};
use winit::event_loop::EventLoop;
fn main() {
@@ -11,9 +11,24 @@ fn main() {
..Default::default()
};
+ let texture = include_bytes!("res/square.ico");
+
let event_loop = EventLoop::new();
let mut renderer = Renderer::new(&config, &event_loop).unwrap();
- renderer.push_instance(Instance::default());
+
+ let texture = renderer
+ .texture_from_mem(texture, ImageFormat::Ico)
+ .unwrap();
+ let width = renderer.texture_width(texture).unwrap();
+ let height = renderer.texture_height(texture).unwrap();
+ let x = renderer.texture_x(texture).unwrap();
+ let y = renderer.texture_y(texture).unwrap();
+
+ renderer.push_instance(Instance {
+ texture_size: [width, height],
+ texture_coordinates: [x, y],
+ ..Default::default()
+ });
renderer.run(event_loop);
}