diff options
| author | HampusM <hampus@hampusmat.com> | 2026-08-28 18:32:58 +0200 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-08-28 18:32:58 +0200 |
| commit | be94cec078e86e643f52f0f3041a98b36e43ec8b (patch) | |
| tree | 0e79657d85020e76b0dc3e0586f9dcdacbfcd14e /engine/src/ui | |
| parent | d04bc21ac58a0bd8bcf8fa2fbb87f7b1dd4b140e (diff) | |
Diffstat (limited to 'engine/src/ui')
| -rw-r--r-- | engine/src/ui/dear_imgui.rs | 39 |
1 files changed, 13 insertions, 26 deletions
diff --git a/engine/src/ui/dear_imgui.rs b/engine/src/ui/dear_imgui.rs index b9214d8..d3ca4dc 100644 --- a/engine/src/ui/dear_imgui.rs +++ b/engine/src/ui/dear_imgui.rs @@ -22,13 +22,7 @@ use ecs::time::Time; use ecs::{Component, Query, Sole}; use crate::asset::{Assets, Handle as AssetHandle, Label as AssetLabel}; -use crate::data_types::color::Rgba; use crate::data_types::dimens::Dimens; -use crate::image::{ - Image, - PixelBuffer as ImagePixelBuffer, - PixelBufferLenIncorrectForSize as ImagePixelBufferLenIncorrectForSize, -}; use crate::input::keyboard::{Key, Keyboard}; use crate::input::mouse::{Button as MouseButton, Buttons as MouseButtons, Mouse}; use crate::mesh::vertex_buffer::{ @@ -72,11 +66,12 @@ use crate::rendering::{ SrgbaTextureDataType, Surface, SurfaceId, + TextureCreation, TexturePixelDataFormat, TextureUpdate, PRE_RENDER_PHASE, }; -use crate::texture::{Properties as TextureProperties, Tex2D, Texture}; +use crate::texture::Properties as TextureProperties; use crate::util::MapVec; use crate::vector::Vec2; use crate::windowing::dpi::PhysicalSize; @@ -546,27 +541,19 @@ fn add_drawing_render_pass( "Performing texture operation: Create" ); - let image = - match Image::from_pixels(ImagePixelBuffer::<Rgba<u8>, _>::new( - pixels.as_slice(), - Dimens { width: *width, height: *height }, - )) { - Ok(image) => image, - Err(ImagePixelBufferLenIncorrectForSize) => { - tracing::error!("Not enough texture pixels for texture size"); - continue; - } - }; - let texture_object_id = RenderingObjectId::new_sequential(); - render_pass.commands.push(RenderingCommand::CreateTexture( - texture_object_id, - AssetOrValue::Value(Texture::Texture2D(Tex2D { - image, - properties: TextureProperties::default(), - })), - )); + render_pass.commands.push(RenderingCommand::CreateTexture { + obj_id: texture_object_id, + pixel_data_format: TexturePixelDataFormat::Srgba( + SrgbaTextureDataType::UnsignedByte, + ), + creation: TextureCreation::Texture2D { + size: Dimens { width: *width, height: *height }, + image: Some(pixels.clone().into_boxed_slice()), + }, + properties: TextureProperties::default(), + }); texture_lookup.insert(texture_lookup_id, texture_object_id); |
