{"record":{"id":"1476e1a3885b8aab","repo":"bevyengine/bevy","slug":"cannot-add-texture-to-uninitialized-atlas-texture-1476e1","errorCode":null,"errorMessage":"cannot add texture to uninitialized atlas texture","messagePattern":"cannot add texture to uninitialized atlas texture","errorType":"exception","errorClass":"TextureAtlasBuilderError","httpStatus":null,"severity":"error","filePath":"crates/bevy_image/src/texture_atlas_builder.rs","lineNumber":25,"sourceCode":"};\nuse thiserror::Error;\nuse tracing::{debug, error, warn};\nuse wgpu_types::{Extent3d, TextureDimension, TextureFormat};\n\nuse crate::{Image, TextureAccessError, TextureFormatPixelInfo};\nuse crate::{TextureAtlasLayout, TextureAtlasSources};\n\n/// Errors returned by [`TextureAtlasBuilder`].\n#[derive(Debug, Error)]\npub enum TextureAtlasBuilderError {\n    /// The atlas texture wasn't large enough to fit the texture\n    #[error(\"could not pack textures into an atlas within the given bounds\")]\n    NotEnoughSpace,\n    /// Attempted to add a texture with a different format\n    #[error(\"added a texture with the wrong format in an atlas\")]\n    WrongFormat,\n    /// Attempted to add a texture to an uninitialized atlas\n    #[error(\"cannot add texture to uninitialized atlas texture\")]\n    UninitializedAtlas,\n    /// Attempted to add an uninitialized texture to an atlas\n    #[error(\"cannot add uninitialized texture to atlas\")]\n    UninitializedSourceTexture,\n    /// A texture access error occurred\n    #[error(\"texture access error: {0}\")]\n    TextureAccess(#[from] TextureAccessError),\n}\n\n#[derive(Debug)]\n#[must_use]\n/// A builder which is used to create a texture atlas from many individual\n/// sprites.\npub struct TextureAtlasBuilder<'a> {\n    /// Collection of texture's asset id (optional) and image data to be packed into an atlas\n    textures_to_place: Vec<(Option<AssetId<Image>>, &'a Image)>,\n    /// The initial atlas size in pixels.\n    initial_size: UVec2,","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_image/src/texture_atlas_builder.rs#L7-L43","documentation":"TextureAtlasBuilderError::UninitializedAtlas — add_texture was called before the builder created the atlas texture, so there is no destination to copy into. Initialize/allocate the atlas (the builder creates it on first properly prepared add) before adding textures.","triggerScenarios":"Thrown at crates/bevy_image/src/texture_atlas_builder.rs:25 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add at least one texture before operations that require an initialized atlas","Set the atlas texture format and size on the builder up front"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}