Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ workspace = true

[features]
default = ["wayland", "x11"]
wayland = ["processing_render/wayland"]
x11 = ["processing_render/x11"]
wayland = ["processing_render/wayland", "processing_glfw/wayland"]
x11 = ["processing_render/x11", "processing_glfw/x11"]
webcam = ["dep:processing_webcam"]
cuda = ["dep:processing_cuda", "processing_cuda/cuda"]

Expand Down Expand Up @@ -87,9 +87,13 @@ processing_audio = { workspace = true }
processing_input = { workspace = true }
processing_webcam = { workspace = true, optional = true }
processing_cuda = { workspace = true, optional = true }
bytemuck = "1"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
processing_glfw = { workspace = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen-futures = "0.4"
js-sys = "0.3"
Expand Down Expand Up @@ -133,6 +137,10 @@ path = "examples/background_image.rs"
name = "update_pixels"
path = "examples/update_pixels.rs"

[[example]]
name = "create_graphics"
path = "examples/create_graphics.rs"

[[example]]
name = "transforms"
path = "examples/transforms.rs"
Expand Down
2 changes: 1 addition & 1 deletion crates/processing_ffi/src/color.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bevy::color::LinearRgba;
use processing::prelude::color::{ColorMode, ColorSpace};
use processing::engine::color::{ColorMode, ColorSpace};

/// A color with 4 float components and its color space.
#[repr(C)]
Expand Down
2 changes: 1 addition & 1 deletion crates/processing_ffi/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
panic,
};

pub(crate) use processing::prelude::error::ProcessingError;
pub(crate) use processing::engine::error::ProcessingError;

thread_local! {
static LAST_ERROR: RefCell<Option<CString>> = const { RefCell::new(None) };
Expand Down
30 changes: 15 additions & 15 deletions crates/processing_ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use bevy::{
prelude::Entity,
render::render_resource::{Extent3d, TextureFormat},
};
use processing::prelude::{error::ProcessingError, shader_value::ShaderValue, *};
use processing::engine::{error::ProcessingError, shader_value::ShaderValue, *};

use crate::color::Color;

Expand Down Expand Up @@ -333,12 +333,12 @@ pub extern "C" fn processing_color_mode(
error::clear_error();
let graphics_entity = Entity::from_bits(graphics_id);
error::check(|| {
let space = processing::prelude::color::ColorSpace::from_u8(space).ok_or_else(|| {
processing::prelude::error::ProcessingError::InvalidArgument(format!(
let space = processing::engine::color::ColorSpace::from_u8(space).ok_or_else(|| {
processing::engine::error::ProcessingError::InvalidArgument(format!(
"unknown color space: {space}"
))
})?;
let mode = processing::prelude::color::ColorMode::new(space, max1, max2, max3, max_alpha);
let mode = processing::engine::color::ColorMode::new(space, max1, max2, max3, max_alpha);
graphics_set_color_mode(graphics_entity, mode)
});
}
Expand Down Expand Up @@ -396,7 +396,7 @@ pub extern "C" fn processing_set_stroke_cap(graphics_id: u64, cap: u8) {
error::check(|| {
graphics_record_command(
graphics_entity,
DrawCommand::StrokeCap(processing::prelude::StrokeCapMode::from(cap)),
DrawCommand::StrokeCap(processing::engine::StrokeCapMode::from(cap)),
)
});
}
Expand All @@ -409,7 +409,7 @@ pub extern "C" fn processing_set_stroke_join(graphics_id: u64, join: u8) {
error::check(|| {
graphics_record_command(
graphics_entity,
DrawCommand::StrokeJoin(processing::prelude::StrokeJoinMode::from(join)),
DrawCommand::StrokeJoin(processing::engine::StrokeJoinMode::from(join)),
)
});
}
Expand All @@ -422,7 +422,7 @@ pub extern "C" fn processing_rect_mode(graphics_id: u64, mode: u8) {
error::check(|| {
graphics_record_command(
graphics_entity,
DrawCommand::RectMode(processing::prelude::ShapeMode::from(mode)),
DrawCommand::RectMode(processing::engine::ShapeMode::from(mode)),
)
});
}
Expand All @@ -435,7 +435,7 @@ pub extern "C" fn processing_ellipse_mode(graphics_id: u64, mode: u8) {
error::check(|| {
graphics_record_command(
graphics_entity,
DrawCommand::EllipseMode(processing::prelude::ShapeMode::from(mode)),
DrawCommand::EllipseMode(processing::engine::ShapeMode::from(mode)),
)
});
}
Expand Down Expand Up @@ -631,7 +631,7 @@ pub extern "C" fn processing_set_blend_mode(graphics_id: u64, mode: u8) {
error::clear_error();
let graphics_entity = Entity::from_bits(graphics_id);
error::check(|| {
let blend_state = processing::prelude::BlendMode::try_from(mode)?.to_blend_state();
let blend_state = processing::engine::BlendMode::try_from(mode)?.to_blend_state();
graphics_record_command(graphics_entity, DrawCommand::BlendMode(blend_state))
});
}
Expand Down Expand Up @@ -828,7 +828,7 @@ pub extern "C" fn processing_arc(
h,
start,
stop,
mode: processing::prelude::ArcMode::from(mode),
mode: processing::engine::ArcMode::from(mode),
},
)
});
Expand Down Expand Up @@ -1022,7 +1022,7 @@ pub extern "C" fn processing_begin_shape(graphics_id: u64, kind: u8) {
graphics_record_command(
graphics_entity,
DrawCommand::BeginShape {
kind: processing::prelude::ShapeKind::from(kind),
kind: processing::engine::ShapeKind::from(kind),
},
)
});
Expand Down Expand Up @@ -1827,7 +1827,7 @@ pub extern "C" fn processing_image_mode(graphics_id: u64, mode: u8) {
error::check(|| {
graphics_record_command(
graphics_entity,
DrawCommand::ImageMode(processing::prelude::ShapeMode::from(mode)),
DrawCommand::ImageMode(processing::engine::ShapeMode::from(mode)),
)
});
}
Expand Down Expand Up @@ -4009,8 +4009,8 @@ pub extern "C" fn processing_graphics_tonemapping(graphics_id: u64, mode: u8) {
error::clear_error();
error::check(|| {
let tonemapping =
processing::prelude::graphics::tonemapping_from_u8(mode).ok_or_else(|| {
processing::prelude::error::ProcessingError::InvalidArgument(format!(
processing::engine::graphics::tonemapping_from_u8(mode).ok_or_else(|| {
processing::engine::error::ProcessingError::InvalidArgument(format!(
"unknown tonemapping: {mode}"
))
})?;
Expand Down Expand Up @@ -4348,7 +4348,7 @@ pub extern "C" fn processing_mouse_wheel() -> f32 {
error::check(input_mouse_wheel).unwrap_or(0.0)
}

fn key_code_from_u32(val: u32) -> processing::prelude::error::Result<KeyCode> {
fn key_code_from_u32(val: u32) -> processing::engine::error::Result<KeyCode> {
match val {
PROCESSING_KEY_SPACE => Ok(KeyCode::Space),
PROCESSING_KEY_QUOTE => Ok(KeyCode::Quote),
Expand Down
8 changes: 4 additions & 4 deletions crates/processing_node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use napi::bindgen_prelude::{
};
use napi::{Env, Error, Result};
use napi_derive::napi;
use processing::prelude::color::{ColorMode, ColorSpace};
use processing::prelude::error::ProcessingError;
use processing::prelude::{shader_value::ShaderValue, *};
use processing::engine::color::{ColorMode, ColorSpace};
use processing::engine::error::ProcessingError;
use processing::engine::{shader_value::ShaderValue, *};
use processing_glfw::GlfwContext;

fn check<T, E: std::fmt::Display>(result: std::result::Result<T, E>) -> Result<T> {
Expand Down Expand Up @@ -3123,7 +3123,7 @@ pub fn js_mouse_wheel() -> Result<f64> {
check(input_mouse_wheel()).map(f64::from)
}

fn key_code_from_u32(val: u32) -> processing::prelude::error::Result<KeyCode> {
fn key_code_from_u32(val: u32) -> processing::engine::error::Result<KeyCode> {
match val {
PROCESSING_KEY_SPACE => Ok(KeyCode::Space),
PROCESSING_KEY_QUOTE => Ok(KeyCode::Quote),
Expand Down
2 changes: 1 addition & 1 deletion crates/processing_pyo3/src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use pyo3::{exceptions::PyTypeError, prelude::*, types::PyTuple};

use crate::math::{PyVec3, PyVec4, PyVecIter, hash_f32};

pub use processing::prelude::color::{ColorMode, ColorSpace};
pub use processing::engine::color::{ColorMode, ColorSpace};

fn int_maxes(space: &ColorSpace) -> [f32; 4] {
match space {
Expand Down
4 changes: 2 additions & 2 deletions crates/processing_pyo3/src/compute.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bevy::prelude::Entity;
use processing::prelude::*;
use processing::engine::*;
use pyo3::{
exceptions::{PyIndexError, PyRuntimeError, PyTypeError, PyValueError},
prelude::*,
Expand Down Expand Up @@ -184,7 +184,7 @@ impl Buffer {

#[pyo3(signature = (op = "sum"))]
pub fn reduce(&self, op: &str) -> PyResult<f32> {
use processing::prelude::constants as c;
use processing::engine::constants as c;
use processing_render::particles::reduce::{
REDUCE_OP_MAX, REDUCE_OP_MIN, REDUCE_OP_SUM, reduce as reduce_buffer,
};
Expand Down
4 changes: 2 additions & 2 deletions crates/processing_pyo3/src/constants.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use processing::prelude::BlendMode;
use processing::prelude::constants as c;
use processing::engine::BlendMode;
use processing::engine::constants as c;
use pyo3::prelude::*;
use pyo3::types::PyModule;

Expand Down
2 changes: 1 addition & 1 deletion crates/processing_pyo3/src/cuda.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use processing::prelude::image::pixel_size;
use processing::engine::image::pixel_size;
use processing_cuda::{cuda_buffer, cuda_write_back, typestr_for_format};
use pyo3::{exceptions::PyRuntimeError, prelude::*, types::PyDict};

Expand Down
2 changes: 1 addition & 1 deletion crates/processing_pyo3/src/filter.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bevy::prelude::Entity;
use processing::prelude::*;
use processing::engine::*;
use pyo3::{
exceptions::{PyRuntimeError, PyTypeError, PyValueError},
prelude::*,
Expand Down
2 changes: 1 addition & 1 deletion crates/processing_pyo3/src/gltf.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bevy::prelude::Entity;
use processing::prelude::*;
use processing::engine::*;
use pyo3::{exceptions::PyRuntimeError, prelude::*};

use crate::graphics::{Geometry, Light};
Expand Down
11 changes: 6 additions & 5 deletions crates/processing_pyo3/src/graphics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use bevy::{
prelude::{Entity, Transform},
render::render_resource::{Extent3d, TextureFormat},
};
use processing::prelude::*;
use processing::engine::*;
use pyo3::{
exceptions::{PyRuntimeError, PyValueError},
prelude::*,
Expand Down Expand Up @@ -1594,7 +1594,7 @@ impl Graphics {
}

pub fn text_style(&self, style: &str) -> PyResult<()> {
use processing::prelude::TextStyle;
use processing::engine::TextStyle;
let style = TextStyle::parse(style)
.ok_or_else(|| PyValueError::new_err(format!("unknown text style: {style:?}")))?;
graphics_text_style(self.entity, style as u8)
Expand Down Expand Up @@ -1723,7 +1723,7 @@ impl Graphics {

#[pyo3(signature = (h, v=None))]
pub fn text_align(&self, h: &str, v: Option<&str>) -> PyResult<()> {
use processing::prelude::{TextAlignH, TextAlignV};
use processing::engine::{TextAlignH, TextAlignV};
let h = TextAlignH::parse(h).ok_or_else(|| {
PyValueError::new_err(format!("unknown horizontal text align: {h:?}"))
})?;
Expand All @@ -1743,7 +1743,7 @@ impl Graphics {
}

pub fn text_wrap(&self, mode: &str) -> PyResult<()> {
use processing::prelude::TextWrapMode;
use processing::engine::TextWrapMode;
let mode = TextWrapMode::parse(mode)
.ok_or_else(|| PyValueError::new_err(format!("unknown text wrap mode: {mode:?}")))?;
graphics_record_command(self.entity, DrawCommand::TextWrap(mode))
Expand Down Expand Up @@ -2333,7 +2333,7 @@ impl Graphics {
graphics_no_bloom(self.entity).map_err(|e| PyRuntimeError::new_err(format!("{e}")))
}

#[pyo3(signature = (mode=processing::prelude::constants::PBR_NEUTRAL))]
#[pyo3(signature = (mode=processing::engine::constants::PBR_NEUTRAL))]
pub fn tonemapping(&self, mode: &str) -> PyResult<()> {
let tonemapping = processing_render::graphics::parse_tonemapping(mode)
.ok_or_else(|| PyValueError::new_err(format!("unknown tonemapping {mode:?}")))?;
Expand Down Expand Up @@ -2774,6 +2774,7 @@ impl Graphics {
transform.look_at(target.into_vec3(), Vec3::Y);
}
graphics_immediate_light(self.entity, kind, transform)
.map(|_| ())
.map_err(|e| PyRuntimeError::new_err(format!("{e}")))
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/processing_pyo3/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use std::collections::HashMap;

use bevy::prelude::Entity;
use processing::prelude::*;
use processing::engine::*;
use processing_render::geometry::AttributeFormat;
use pyo3::buffer::PyBuffer;
use pyo3::exceptions::{PyRuntimeError, PyValueError};
Expand Down
Loading
Loading