Releases: tversteeg/chuot
v0.3.1
A small bugfix release that fixes a camera issue when rendering text with the main camera.
Bug Fixes
Camera
- Calculate proper camera position for text by @tversteeg
Deps
- Update rust crate bytemuck, rust crate fastrand, rust crate glam, rust crate kira, rust crate smol_str and rust crate proc-macro2 by @tversteeg
Documentation
Math
- Fix return comment for
chuot::lerp
by @tversteeg
v0.3.0
I have been working on this big release for a couple of months. There are a lot of big and small breaking changes, the quickest way to migrate is to take a look at the new examples: https://tversteeg.nl/chuot/examples/
A big change is that there's now two camera systems: one main camera and one for the UI.
These can be applied manually by calling SpriteContext::use_ui_camera
or SpriteContext::use_main_camera
and of course this also works for text.
The camera's can be changed by calling different methods on Context::main_camera
and Context::ui_camera
, such as CameraContext::shake
.
All colors in methods are now implemented as impl Into<chuot::RGBA8>
.
The paths of chuot::context::{Axis,Button,MouseButton,KeyCode}
have been moved to the root and renamed: chuot::{GamepadAxis,GamepadButton,MouseButton,KeyCode}
.
A way to change the pivot point of sprites has been added with SpriteContext::pivot
, SpriteContext::pivot_pixels
, SpriteContext::pivot_center
and SpriteContext::pivot_top_left
.
Changing the pivot point in assets has been split into pivot_x
and pivot_y
, where the accepted values for both are Start
, Center
, End
, Fraction(f32)
and Pixels(f32)
.
An optional Game::init
method has been added which is called once after the window is spawned, for example various procedural assets can be created and uploaded, like in the Sprite New Texture example.
It's now possible to get a glyph of a font as a sprite with ctx.font(..).glyph(..)
, other font properties are also exposed in the same FontContext
.
A simple chuot::lerp
function has been added for linear interpolation between floats.
Internally, a lot has been refactored, and the context objects have been converted to generic types so rendering with different properties such as rotation and scaling can be optimized.
Refactor
Context
- [breaking] Use dynamic typestate builder to improve performance and allow extensions by @tversteeg in #115
- [breaking] Implement typestate without using traits that need to be loaded by @tversteeg in #115
- [breaking] Make better use of generics to reduce code duplication by @tversteeg
Graphics
- [breaking] Use rgb crate for all colors, exposed as
chuot::RGBA8
by @tversteeg in #110
Path
- [breaking] Change re-export path of
chuot::context::{Axis,Button,MouseButton,KeyCode}
tochuot::{GamepadAxis,GamepadButton,MouseButton,KeyCode}
by @tversteeg in #112
Sprite
- [breaking] Remove pivot enum struct in favor of direct methods by @tversteeg
Features
Camera
- [breaking] Add a main game and a UI camera system by @tversteeg in #112
- Add
CameraContext::set_lerp{_x,_y}
by @tversteeg in #112 - Implement screen shake with
CameraContext::shake
by @tversteeg - Add
{Sprite,Text}Context::translate_previous{,_x,_y}
for smooth camera movement of moving objects by @tversteeg
Context
- [breaking] Move
Context::font_glyph
to ownFontContext::glyph
and addContext::font
by @tversteeg
Entrypoint
- Add optional
Game::init
which is called once after the window has been created by @tversteeg in #112
Font
- Add
Context::font_sprite
for getting a single glyph from a font as a sprite by @tversteeg - [breaking] Make
FontContext::glyph
numeric values instead of justchar
by @tversteeg
Math
- Add
chuot::lerp
by @tversteeg
Sprite
- [breaking] Rename offset to pivot and allow specifying at runtime by @tversteeg
- [breaking] Add argument to sprite creation with sprite pivot by @tversteeg
- Add
Pivot::Fraction
to the enum & add sprite stacking example by @tversteeg
Bug Fixes
Deps
- Update rust crate wgpu to v22 by @renovate[bot]
- Update rust crate glam to 0.29.0 by @renovate[bot]
- Update rust crate smol_str to 0.3.0 by @renovate[bot]
- Update rust crate gilrs to 0.11.0 by @renovate[bot]
- Update rust crate bytemuck, rust crate fastrand, rust crate kira, rust crate rgb, rust crate smol_str, rust crate winit, rust crate wgpu, rust crate wasm-bindgen-futures, rust crate web-sys, rust crate naga, rust crate quote & rust crate sprite_dicing by @tversteeg
- Update rust crate hashbrown to 0.15.0 by @renovate[bot]
- Update rust crate bytemuck, rust crate imgref, rust crate png, rust crate proc-macro2, rust crate wasm-bindgen-futures, rust crate web-sys by @tversteeg
- Update rust crate notify-debouncer-mini to 0.5.0 by @renovate[bot]
- Update rust crate pollster to 0.4.0 by @renovate[bot]
- Update rust crate wgpu to v23 by @renovate[bot]
Graphics
- Always render with viewport to fix flipping issue by @tversteeg
Input
- Handle button press and release within a single update tick by @tversteeg
Performance
Compile-time
- Improve compilation time by keeping pivot a generic type by @tversteeg
- Improve compilation speed by creating inner functions for generics by @tversteeg
Documentation
Examples
- Add random colors and better updates to falling-sand examples by @tversteeg
Styling
Clippy
- Apply new Rust 1.81, 1.82 and 1.83 clippy lints by @tversteeg
Fmt
- Use 2024 style edition for
cargo fmt
by @tversteeg
Miscellaneous Tasks
Credits
- Create CREDITS.md of inspiration and sources by @tversteeg
Deps
chuot-packer-v0.2.1
Bug Fixes
Deps
Performance
Compile-time
- Improve compilation speed by creating inner functions for generics by @tversteeg
Styling
Fmt
- Use 2024 style edition for
cargo fmt
by @tversteeg
chuot-v0.2.1
A small release with some optimizations and quality of life fixes.
One feature added is that it's now possible to scale a sprite with SpriteContext::scale
, SpriteContext::scale_x
and SpriteContext::scale_y
.
Negative values can be used to flip the sprite. For example, ctx.sprite(..).scale_x(-1.0).draw()
will draw the sprite horizontally flipped.
An example has also been added for this: https://tversteeg.nl/chuot/examples/sprite-scale/
Context::mouse_x
and Context::mouse_y
have also been added to make the API more consistent.
Features
Context
- Add
Context::mouse_x
andContext::mouse_y
Sprite
- Add
SpriteContext::scale{,_x,_y}
for scaling the sprite horizontally and vertically
Performance
Shader
- Optimize vertex shaders a tiny bit
Documentation
Examples
- Fix
render_interpolation
example where it points to a missing asset
Readme
- Change Matrix room to matrix.org
Styling
Fmt
- Enforce strict
cargo fmt
with nightly requirement
Miscellaneous Tasks
Release
- Cleanup changelog and improve release PR with labels
chuot-macros-v0.2.1
Styling
Fmt
- Enforce strict
cargo fmt
with nightly requirement
chuot-v0.2.0
A massive overhaul of the internal system, which started with the realization that one of the lifetimes used by the wgpu
crate could be static, thus allowing the whole engine to interface directly with the GPU instead of buffering everything in vectors.
This is great for performance and also makes the internal code a lot more readable and maintainable.
API wise, there's been some big breaking changes:
The PixelGame
trait has been renamed to Game
, and the GameConfig
trait has been renamed to Config
. Game::run
doesn't return a Result
anymore, but instead panics when something goes wrong.
Old:
use chuot::{Context, GameConfig, PixelGame};
struct MyGame;
impl PixelGame for MyGame {
fn update(&mut self, ctx: Context) {
// ..
}
fn render(&mut self, ctx: Context) {
// ..
}
}
// In main
MyGame.run(chuot::load_assets!(), GameConfig::default())?;
New:
use chuot::{Config, Context, Game};
struct MyGame;
impl Game for MyGame {
fn update(&mut self, ctx: Context) {
// ..
}
fn render(&mut self, ctx: Context) {
// ..
}
}
// In main
MyGame.run(chuot::load_assets!(), Config::default());
Some feature flags have been removed:
dialogue
, this is easy to implement with the new asset loading system.hot-reload-assets
, this is now always enabled when building for a desktop platform and when using a directory for the assets.in-game-profiler
, the crates this depends on are lagging behind with updates of thewinit
andwgpu
version, so it might be added again in the future, or not…
The read-image
feature flag has been renamed to read-texture
.
All public API functions using geometry types (sizes, vectors, etc.) now use either simple single Rust f32
parameters or tuples. Because all the tuples are implemented as generics, the user can in most cases supply their own geometry types, as long as they implement Into<(f32, ..)>
.
The glamour
re-export is removed.
Many API paths have changed.
The embedded profiler has been removed.
All logging has been disabled.
Asset loading has been completely overhauled, Loadable
now has a mutable reference to ContextInner
which allows it to directly change the state of the engine when loading assets.
Old:
use chuot::assets::{loader::toml::TomlLoader, AssetSource, Id, Loadable};
use serde::Deserialize;
/// We define a custom settings object that will be loaded from a '.toml' file.
#[derive(Deserialize)]
struct Settings {
property_a: String,
property_b: i32,
}
impl Loadable for Settings {
fn load_if_exists(id: &Id, assets: &AssetSource) -> Option<Self>
where
Self: Sized,
{
// Use the TOML loader to load our asset
assets.load_if_exists::<TomlLoader, _>(id)
}
}
New:
use chuot::{
assets::{loadable::Loadable, loader::ron::RonLoader, Id},
context::ContextInner,
};
use nanoserde::DeRon;
/// We define a custom settings object that will be loaded from a '.ron' file.
#[derive(DeRon)]
struct Settings {
property_a: String,
property_b: i32,
}
impl Loadable for Settings {
fn load_if_exists(id: &Id, ctx: &mut ContextInner) -> Option<Self> {
// Use the RON loader to load our asset
ctx.asset_source.load_if_exists::<RonLoader, Self>(id)
}
}
Loader
has an id: &Id
argument, mostly for printing useful panic messages.
The serde
crate with TOML files has been replaced with nanoserde
with RON files. This greatly improves compilation speed.
The PngLoader
now returns the size of the image and the raw bytes, instead of a reader.
The asset source can now also be manually constructed without using the macro, with the AssetSource
struct.
The particles example has been removed in favor of a simpler bunnymark example.
Special thanks to @suprohub for the fixes and ideas.
chuot-packer-v0.2.0
chuot-macros-v0.2.0
chuot-v0.1.2
A small update centered around a single feature, the ability to read pixel values of an image.
This must be enabled with the read-image
feature flag, the reason being that when this flag is disabled the images are immediately uploaded to the GPU, allowing the memory to be freed immediately.
When embedding images with the embed-assets
feature flag this means the whole image will never be inside memory, it will be diced in a build step and immediately uploaded to the GPU part by part, decreasing both the binary size and CPU memory usage.
When the read-image
flag is enabled, the DrawSpriteContext::read_pixels
function is available.
I've also moved some re-exported items to the context
module, this is not a breaking change because they are still accessible in the old location, they just don't show up in the documentation.
Besides that, I've updated the examples a bit, so they're easier to read.
Refactor
Exports
- Move re-exported exports only used by
Context
to thecontext
module
Features
Embedded
- Read all images to memory when
read-image
flag is set
Sprite
- Add
DrawSpriteContext::read_pixels
for reading pixels behind a feature flagread-image
Bug Fixes
Deps
- Update rust crate cargo-run-wasm to 0.4.0
Macros
- Add
read-image
feature flag which adds some fields to the texture mapping
Performance
Image
- Don't process PNG twice when
read-image
feature flag is enabled
Documentation
Assets
- Show example for loading a custom TOML asset
Examples
- Remove quit with escape button from each example, simplifying them
Testing
Ci
- Test building with
read-image
feature flag enabled
Miscellaneous Tasks
Funding
- Link liberapay
chuot-macros-v0.1.2
Bug Fixes
Macros
- Add
read-image
feature flag which adds some fields to the texture mapping