Skip to content

Commit

Permalink
Bumped nsi-sys to 0.8, fixed features.
Browse files Browse the repository at this point in the history
  • Loading branch information
virtualritz committed Nov 12, 2023
1 parent 102799a commit 38661d4
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 38 deletions.
2 changes: 1 addition & 1 deletion crates/nsi-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ enum_dispatch = "0.3"
lazy_static = "1.4"
log = "0.4"
ndspy-sys = { version = "0.2", optional = true }
nsi-sys = "0.7"
nsi-sys = "0.8"
null-terminated-str = "0.1"
num_enum = "0.7"
rclite = "0.2"
Expand Down
7 changes: 2 additions & 5 deletions crates/nsi-core/build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#![cfg(any(target_os = "windows", target_os = "macos", target_os = "linux"))]

#[cfg(feature = "download_lib3delight")]
use reqwest;

fn main() -> Result<(), Box<dyn std::error::Error>> {
#[cfg(feature = "download_lib3delight")]
#[allow(unused_variables)]
Expand Down Expand Up @@ -39,9 +36,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.bytes()
.ok()?;
File::create(lib_path.clone())
.expect(&format!("Could not create {}", lib_path.display()))
.unwrap_or_else(|_| panic!("Could not create {}", lib_path.display()))
.write_all(&lib_data)
.expect(&format!(
.unwrap_or_else(|_| panic!(
"Could not write to {}",
lib_path.display()
));
Expand Down
6 changes: 3 additions & 3 deletions crates/nsi-core/src/output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,9 @@ pub trait FnQuery<'a> = dyn FnMut(Query) -> Error + 'a;
/// [`OutputDriver`](crate::OUTPUT_DRIVER) node.
pub struct OpenCallback<'a>(Box<Box<Box<dyn FnOpen<'a>>>>);

// Why do we need a triple Box here? No idea and neither had anyone from the
// Rust community. But omitting a single Box wrapper layer leads to an instant
// crash.
// Why do we need a triple Box here? Why does a Box<Box<T>> not suffice?
// No idea and neither had anyone from the Rust community. But omitting a
// single Box wrapper layer leads to an instant segfault.
impl<'a> OpenCallback<'a> {
pub fn new<F>(fn_open: F) -> Self
where
Expand Down
16 changes: 7 additions & 9 deletions crates/nsi-core/src/output/pixel_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,20 @@ impl LayerDepth {
/// A typical format for a pixel containing two such layers, an *RGBA* **color**
/// & **alpha** output layer and a world space **normal**, will look like this:
///
/// [`name`](Layer::name()) | [`depth`](Layer::depth())
/// | [`offset`](Layer::offset())
/// ------------------------|-------------------------------------------------------|----------------------------
/// `Ci` |
/// [`ColorAndAlpha`](LayerDepth::ColorAndAlpha)(`rgba`) | `0` `N_world`
/// | [`Vector`](LayerDepth::Vector)(`xyz`) | `4`
/// | [`name`](Layer::name()) | [`depth`](Layer::depth()) | [`offset`](Layer::offset())
/// |-------------------------|-----------------------------------------------------|----------------------------
/// | `Ci` |[`ColorAndAlpha`](LayerDepth::ColorAndAlpha)(`rgba`) | `0`
/// | `N_world` | [`Vector`](LayerDepth::Vector)(`xyz`) | `4`
///
/// ## RAW Layout
///
/// The resp. callbacks deliver pixels as a flat [`f32`] buffer.
/// For the above example the actual layout of a single pixel in the
/// buffer is:
///
/// Value | `r`ed | `g`reen | `b`lue | `a`lpha | `x` | `y` | `z`
/// -------|---------|---------|---------|---------|-----|-----|----
/// Offset | `0` | `1` | `2` | `3` | `4` | `5` | `6`
/// | Value | `r`ed | `g`reen | `b`lue | `a`lpha | `x` | `y` | `z`
/// |--------|---------|---------|---------|---------|-----|-----|----
/// | Offset | `0` | `1` | `2` | `3` | `4` | `5` | `6`
///
/// The `offset` is the offset into the pixel buffer to obtain the 1st element.
/// For example, the **y** coordinate of the the normal will be stored in
Expand Down
24 changes: 4 additions & 20 deletions crates/nsi-sys/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
//! Auto-generated Rust bindings for *Illumination Research*s *Nodal
//! Auto-generated Rust bindings for *Illumination Research*'s *Nodal
//! Scene Interface* – ɴsɪ.
//!
//! You should not need to use this crate directly except for two
//! reasons. You are likely either:
//!
//! * a masochist who wants to use the C-API directly from Rust.
//!
//! * Not happy with my high level Rust binding (see below) – consider
//! opening an issue [here](https://github.com/virtualritz/nsi/issues)
//! instead.
//!
//! * writing a renderer that exposes an ɴsɪ C-API.
//!
//! # High Level Bindings
Expand Down Expand Up @@ -47,25 +50,6 @@
//!
//! # Features
//!
//! * `download_lib3delight` – Fetches the dynamic library version of *3Delight
//! 2.1.2* for *Linux*, *macOS* or *Windows*.
//!
//! This can be used as a fallback, to build against, if you do not have the
//! renderer installed on your system. But it is an old version of 3Delight
//! and foremost a CI feature.
//!
//! It is instead suggested that you [download a *3Delight*
//! package](https://www.3delight.com/download) for your platform & install
//! it. This will set the `DELIGHT` environment variable that the build
//! script is looking for to find a locally installed library to link
//! against. Free version renders with up to 12 cores.
//!
//! This will also install *3Delight Display* which you can render to,
//! progressively – useful for debugging.
//!
//! * `link_lib3delight` – Links against the dynamic library version of
//! 3Delight. Requires the `DELIGHT` environment variable to be set.
//!
//! * `omit_functions` – Omit generating bindings for the API's functions. This
//! is for the case where you want to expose your own C-API hooks from your
//! renderer.
Expand Down

0 comments on commit 38661d4

Please sign in to comment.