From 8c3249a7bc50960e7803f4c6c733256ef126cb39 Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 26 Aug 2026 18:27:01 +0200 Subject: refactor(engine): make UpdateTexture rendering command not take Image --- engine/src/rendering.rs | 61 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 7 deletions(-) (limited to 'engine/src/rendering.rs') diff --git a/engine/src/rendering.rs b/engine/src/rendering.rs index 572f045..7a46b29 100644 --- a/engine/src/rendering.rs +++ b/engine/src/rendering.rs @@ -19,7 +19,6 @@ use crate::ecs::system::initializable::Initializable; use crate::ecs::system::observer::Observe; use crate::ecs::system::Into; use crate::ecs::{declare_entity, pair, Component, Query, Sole}; -use crate::image::Image; use crate::mesh::Mesh; use crate::rendering::blending::Config as BlendingConfig; use crate::rendering::object::{Id as ObjectId, Store as ObjectStore}; @@ -219,12 +218,9 @@ pub enum Command UpdateTexture { obj_id: ObjectId, - image: Image, + pixels: Box<[u8]>, + pixel_data_format: TexturePixelDataFormat, update: TextureUpdate, - - /// Specifies texel index offsets in the x and y directions within the texture - /// pixels. - offset: Vec2, }, RemoveTexture(ObjectId), CreateMesh @@ -406,9 +402,22 @@ bitflags! { #[non_exhaustive] pub enum TextureUpdate { - Texture2D, + Texture2D + { + size: Dimens, + + /// Specifies texel index offsets in the x and y directions within the texture + /// pixels. + offset: Vec2, + }, CubeMap { + size: Dimens, + + /// Specifies texel index offsets in the x and y directions within the texture + /// pixels. + offset: Vec2, + face: CubeMapFace, }, } @@ -546,3 +555,41 @@ struct ActiveDrawProperties { pub draw_properties: DrawProperties, } + +#[derive(Debug, Clone, Copy)] +#[non_exhaustive] +pub enum RgbTextureDataType +{ + UnsignedByte, +} + +#[derive(Debug, Clone, Copy)] +#[non_exhaustive] +pub enum RgbaTextureDataType +{ + UnsignedByte, +} + +#[derive(Debug, Clone, Copy)] +#[non_exhaustive] +pub enum SrgbTextureDataType +{ + UnsignedByte, +} + +#[derive(Debug, Clone, Copy)] +#[non_exhaustive] +pub enum SrgbaTextureDataType +{ + UnsignedByte, +} + +#[derive(Debug, Clone, Copy)] +#[non_exhaustive] +pub enum TexturePixelDataFormat +{ + Rgb(RgbTextureDataType), + Rgba(RgbaTextureDataType), + Srgb(SrgbTextureDataType), + Srgba(SrgbaTextureDataType), +} -- cgit v1.2.3-18-g5258