Skip to content

Latest commit

 

History

History
59 lines (37 loc) · 1.67 KB

README.md

File metadata and controls

59 lines (37 loc) · 1.67 KB

Zemax Diffraction DLL Example in Rust! 🦀

This can be modified or extended to include the other kinds of DLLs supported by Zemax.

The entry points for the raytrace and the parameter names are defined in the ./src/lib.rs file. The pointers coming from Zemax are cast to the struct defined in ./src/data_structures.rs.

Compilation

On Windows

The code can be compiled to a DLL using the following command:

cargo build --release

and the resulting DLL will be in the ./target/release/ folder, ready to be copied in the Zemax DLL folder.

On Linux or macOS

You need to have the following pre-requisites:

  • The mingw-w64 toolchain installed, which can be obtained from the package manager of your distribution on Linux or from homebrew on macOS, here a few examples:

    # On Ubuntu
    sudo apt install mingw-w64
    # On macOS
    brew install mingw-w64
  • The x86_64-pc-windows-gnu target installed in your Rust toolchain, which can be done using the following command:

    rustup target add x86_64-pc-windows-gnu

Then, you can compile the DLL using the following command:

cargo build --release --target=x86_64-pc-windows-gnu

and the resulting DLL will be in the ./target/x86_64-pc-windows-gnu/release/ folder, ready to be copied in the Zemax DLL folder.

Docs Generation

Simply run:

cargo doc --document-private-items --no-deps --target=x86_64-pc-windows-gnu

Add the additional --open flag to open the documentation in your default web browser.

Credits

Credits to Zemax for the examples in C and C++ that inspired this.