Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Commit

Permalink
WIP engine texture init
Browse files Browse the repository at this point in the history
  • Loading branch information
darthdeus committed May 13, 2024
1 parent ae7f0e7 commit 20ae2bc
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 7 deletions.
Binary file added comfy-quad/assets/1px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added comfy-quad/assets/_builtin-comfy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added comfy-quad/assets/error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added comfy-quad/assets/test-grid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 35 additions & 4 deletions comfy-quad/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ pub fn blood_canvas_reset() {}
pub type TextureMap = HashMap<TextureHandle, TextureHandle>;

pub fn load_texture_from_engine_bytes(
context: &GraphicsContext,
name: &str,
bytes: &[u8],
textures: &mut TextureMap,
address_mode: AddressMode,
) {
}
Expand Down Expand Up @@ -93,6 +93,7 @@ pub static BLOOD_CANVAS: OnceCell<AtomicRefCell<BloodCanvas>> = OnceCell::new();

#[derive(Clone)]
pub struct GraphicsContext {
pub texture_map: Arc<AtomicRefCell<TextureMap>>,
pub texture_creator: Arc<AtomicRefCell<QuadTextureCreator>>,
}

Expand All @@ -108,14 +109,44 @@ pub struct QuadRenderer {

impl QuadRenderer {
pub async fn new() -> Self {
trace!("Loading builtin engine textures");

let context = GraphicsContext {
texture_map: Arc::new(AtomicRefCell::new(TextureMap::new())),
texture_creator: Arc::new(AtomicRefCell::new(
QuadTextureCreator::new(),
)),
};

{
macro_rules! load_engine_tex {
($name: literal) => {{
load_texture_from_engine_bytes(
&context,
$name,
include_bytes!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/assets/",
$name,
".png"
)),
AddressMode::ClampToEdge,
);
}};
}

load_engine_tex!("error");
load_engine_tex!("1px");
load_engine_tex!("test-grid");
load_engine_tex!("_builtin-comfy");
}


let texture_creator =
Arc::new(AtomicRefCell::new(QuadTextureCreator::new()));

let (tx_texture, rx_texture) = channel::<LoadedImage>();

let context =
GraphicsContext { texture_creator: texture_creator.clone() };

QuadRenderer {
text: RefCell::new(TextRasterizer::new(context.clone())),
context,
Expand Down
3 changes: 0 additions & 3 deletions comfy/src/trail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,6 @@ impl Trail {
}

let tex = self.texture.unwrap_or(texture_id("1px"));
// let tex = texture_id("1px");

// let mut trail_length = 0.0;

let mut vertices = vec![];

Expand Down

0 comments on commit 20ae2bc

Please sign in to comment.