summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml6
-rw-r--r--examples/bmp.rs61
-rw-r--r--examples/res/gator.bmpbin0 -> 750054 bytes
-rw-r--r--examples/res/gator.ffbin0 -> 2000016 bytes
-rw-r--r--examples/res/ghost.icobin0 -> 67646 bytes
-rw-r--r--examples/res/sample.bmpbin1000138 -> 0 bytes
-rw-r--r--examples/res/square.icobin270398 -> 0 bytes
-rw-r--r--examples/square.rs37
-rw-r--r--src/texture.rs3
9 files changed, 52 insertions, 55 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 935d493..c07a785 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -18,6 +18,9 @@ texture_packer = "0.24"
profiling = "1"
tracy-client = "0.14"
+[lib]
+crate-type = ["cdylib", "lib"]
+
[features]
profile-with-tracy = ["profiling/profile-with-tracy"]
@@ -25,7 +28,4 @@ profile-with-tracy = ["profiling/profile-with-tracy"]
name = "black"
[[example]]
-name = "square"
-
-[[example]]
name = "bmp"
diff --git a/examples/bmp.rs b/examples/bmp.rs
index af425ff..f029efc 100644
--- a/examples/bmp.rs
+++ b/examples/bmp.rs
@@ -8,7 +8,7 @@ use winit::event_loop::EventLoop;
fn main() {
// configure the render window
let config = RenderWindowConfig {
- title: "Bumper Sticker",
+ title: "A Bumper Sticker and an Icon for Hire",
instance_capacity: 2,
default_width: NonZeroU32::new(1280).unwrap(),
default_height: NonZeroU32::new(720).unwrap(),
@@ -17,33 +17,64 @@ fn main() {
..Default::default()
};
- let texture = include_bytes!("res/sample.bmp");
-
let event_loop = EventLoop::new();
let mut renderer = Renderer::new(&config, &event_loop).unwrap();
- let texture = renderer
+ // 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: [0.75; 2],
+ 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(texture, ImageFormat::Bmp)
+ .load_from_memory(icon, ImageFormat::Ico)
.unwrap();
- let width = renderer.textures().texture_width(texture).unwrap();
- let height = renderer.textures().texture_height(texture).unwrap();
- let x = renderer.textures().texture_x(texture).unwrap();
- let y = renderer.textures().texture_y(texture).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();
+ // TODO we can make a helper function that makes a square to fit a texture
renderer.instances_mut().push_instance(Instance {
- position: [-0.5, 0.0],
+ position: [0.5, 0.5],
size: [0.75; 2],
- texture_size: [width, height],
- texture_coordinates: [x, y],
+ 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.5, 0.0],
+ position: [0.0, -0.5],
size: [0.75; 2],
- texture_size: [width, height],
- texture_coordinates: [x, y],
+ texture_size: [gator_width, gator_height],
+ texture_coordinates: [gator_x, gator_y],
..Default::default()
});
diff --git a/examples/res/gator.bmp b/examples/res/gator.bmp
new file mode 100644
index 0000000..e752b56
--- /dev/null
+++ b/examples/res/gator.bmp
Binary files differ
diff --git a/examples/res/gator.ff b/examples/res/gator.ff
new file mode 100644
index 0000000..b4d867a
--- /dev/null
+++ b/examples/res/gator.ff
Binary files differ
diff --git a/examples/res/ghost.ico b/examples/res/ghost.ico
new file mode 100644
index 0000000..102de00
--- /dev/null
+++ b/examples/res/ghost.ico
Binary files differ
diff --git a/examples/res/sample.bmp b/examples/res/sample.bmp
deleted file mode 100644
index b31b58e..0000000
--- a/examples/res/sample.bmp
+++ /dev/null
Binary files differ
diff --git a/examples/res/square.ico b/examples/res/square.ico
deleted file mode 100644
index 43d5a8c..0000000
--- a/examples/res/square.ico
+++ /dev/null
Binary files differ
diff --git a/examples/square.rs b/examples/square.rs
deleted file mode 100644
index ea8f9e9..0000000
--- a/examples/square.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
-
-use alligator_render::{ImageFormat, Instance, RenderWindowConfig, Renderer};
-use winit::event_loop::EventLoop;
-
-fn main() {
- // configure the render window
- let config = RenderWindowConfig {
- title: "Pokemon: Black and White (New Edition)",
- instance_capacity: 1,
- //vsync: false,
- //mode: alligator_render::config::WindowMode::BorderlessFullscreen,
- ..Default::default()
- };
-
- let texture = include_bytes!("res/square.ico");
-
- let event_loop = EventLoop::new();
- let mut renderer = Renderer::new(&config, &event_loop).unwrap();
-
- let texture = renderer
- .textures_mut()
- .load_from_memory(texture, ImageFormat::Ico)
- .unwrap();
- let width = renderer.textures().texture_width(texture).unwrap();
- let height = renderer.textures().texture_height(texture).unwrap();
- let x = renderer.textures().texture_x(texture).unwrap();
- let y = renderer.textures().texture_y(texture).unwrap();
-
- renderer.instances_mut().push_instance(Instance {
- texture_size: [width, height],
- texture_coordinates: [x, y],
- ..Default::default()
- });
-
- renderer.run(event_loop);
-}
diff --git a/src/texture.rs b/src/texture.rs
index da69c77..ac2dd63 100644
--- a/src/texture.rs
+++ b/src/texture.rs
@@ -157,6 +157,9 @@ impl TextureAtlas {
packer: TexturePacker::new_skyline(TexturePackerConfig {
max_width: width,
max_height: height,
+ allow_rotation: false,
+ trim: false,
+ texture_padding: 0,
..Default::default()
}),
diffuse_texture,