nadir-render 0.4.0

2D renderer for the Nadir engine: sprite batching, y-sort, tilemap chunks, bitmap text, a UI pass, camera and atlases.
Documentation
// Copyright 2026 Joseph Anthony Abbott III
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//! The texture asset without a GPU.

use std::fs;
use std::path::Path;

use nadir_assets::{AssetError, AssetServer, FinalizeCtx, LoadState, OnFailure};
use nadir_codec::qoi::{self, Channels, ColorSpace, Header};
use nadir_render::Texture;

#[test]
fn a_texture_needs_the_device_in_the_context() {
    let root = Path::new(env!("CARGO_TARGET_TMPDIR")).join("nadir-render-texture");
    fs::create_dir_all(&root).expect("create the test directory");
    let header = Header {
        width: 1,
        height: 1,
        channels: Channels::Rgba,
        color_space: ColorSpace::Srgb,
    };
    let bytes = qoi::encode(&header, &[1, 2, 3, 4]).expect("an image");
    fs::write(root.join("dot.qoi"), bytes).expect("write the file");

    let mut server = AssetServer::new(root, OnFailure::Placeholder);
    let dot = server.load::<Texture>("dot.qoi");
    server.finish_all_loads(&mut FinalizeCtx::new());
    assert_eq!(server.state(dot), Some(LoadState::Failed));
    assert_eq!(
        server.error(dot),
        Some(&AssetError::MissingContext("nadir_gfx::device::Device"))
    );
    // The placeholder needs the device too, so there is none.
    assert_eq!(server.get(dot), None);
}