aaaaaaaaaa
This commit is contained in:
parent
69ab5b3b0a
commit
2dceef6f79
8 changed files with 665 additions and 763 deletions
1242
Cargo.lock
generated
1242
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -5,9 +5,9 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
bytemuck = "1.16.0"
|
||||
eframe = {version = "0.27", features = ["wgpu"]}
|
||||
egui-file-dialog = "0.5.0"
|
||||
egui_extras = { version = "0.27.2", features = ["image"] }
|
||||
eframe = {version = "0.28", features = ["wgpu"]}
|
||||
egui-file-dialog = "0.6.0"
|
||||
egui_extras = { version = "0.28", features = ["image"] }
|
||||
env_logger = "0.11.3"
|
||||
image = "0.25.1"
|
||||
nalgebra = "0.32.5"
|
||||
|
|
89
flake.lock
89
flake.lock
|
@ -1,17 +1,12 @@
|
|||
{
|
||||
"nodes": {
|
||||
"crane": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1715274763,
|
||||
"narHash": "sha256-3Iv1PGHJn9sV3HO4FlOVaaztOxa9uGLfOmUWrH7v7+A=",
|
||||
"lastModified": 1725409566,
|
||||
"narHash": "sha256-PrtLmqhM6UtJP7v7IGyzjBFhbG4eOAHT6LPYOFmYfbk=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "27025ab71bdca30e7ed0a16c88fd74c5970fc7f5",
|
||||
"rev": "7e4586bad4e3f8f97a9271def747cf58c4b68f3c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -28,11 +23,11 @@
|
|||
"rust-analyzer-src": "rust-analyzer-src"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1715927173,
|
||||
"narHash": "sha256-2S8hVck6nlyiBifzymDvePl5HWgqvVgxkBZCRax1qD8=",
|
||||
"lastModified": 1726468443,
|
||||
"narHash": "sha256-O1VcbVBrqIf58U05yFXl9+J7XM2qh0I+7vqMbNwZPq0=",
|
||||
"owner": "nix-community",
|
||||
"repo": "fenix",
|
||||
"rev": "a2d19ef9305841f26c8ab908b1c09a84ca307e18",
|
||||
"rev": "effac20e9560aab202e82b6d833f685163a9c138",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -59,31 +54,13 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"inputs": {
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1689068808,
|
||||
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1715867414,
|
||||
"narHash": "sha256-cu4UEffKkBByyGR6CFs9XP6iSNsKTkq1r66DA5BkYnE=",
|
||||
"lastModified": 1726436956,
|
||||
"narHash": "sha256-a3rP7uafX/qBFX0y4CGS8vvTPvxsLl9eZQ85DkIn3DI=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "bf446f08bff6814b569265bef8374cfdd3d8f0e0",
|
||||
"rev": "039b72d0c738c934e2e36d7fc5520d1b425287a6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -98,18 +75,17 @@
|
|||
"crane": "crane",
|
||||
"fenix": "fenix",
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"wgsl_analyzer": "wgsl_analyzer"
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"rust-analyzer-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1715839492,
|
||||
"narHash": "sha256-EyjtjocGLtB7tqyqwBfadP4y5BBtT5EkoG3kq/zym5U=",
|
||||
"lastModified": 1726443025,
|
||||
"narHash": "sha256-nCmG4NJpwI0IoIlYlwtDwVA49yuspA2E6OhfCOmiArQ=",
|
||||
"owner": "rust-lang",
|
||||
"repo": "rust-analyzer",
|
||||
"rev": "83ba42043166948db91fcfcfe30e0b7eac10b3d5",
|
||||
"rev": "94b526fc86eaa0e90fb4d54a5ba6313aa1e9b269",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -133,45 +109,6 @@
|
|||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"wgsl_analyzer": {
|
||||
"inputs": {
|
||||
"crane": [
|
||||
"crane"
|
||||
],
|
||||
"flake-utils": "flake-utils_2",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1702151450,
|
||||
"narHash": "sha256-bhosTihbW89vkqp1ua0C1HGLJJdCNfRde98z4+IjkOc=",
|
||||
"owner": "wgsl-analyzer",
|
||||
"repo": "wgsl-analyzer",
|
||||
"rev": "8851962fc191aa5ea85a25b0ebd10cb9f70627b3",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "wgsl-analyzer",
|
||||
"repo": "wgsl-analyzer",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
|
52
flake.nix
52
flake.nix
|
@ -14,12 +14,6 @@
|
|||
};
|
||||
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
wgsl_analyzer = {
|
||||
url = "github:wgsl-analyzer/wgsl-analyzer";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
inputs.crane.follows = "crane";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = {
|
||||
|
@ -28,40 +22,44 @@
|
|||
crane,
|
||||
fenix,
|
||||
flake-utils,
|
||||
wgsl_analyzer,
|
||||
...
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
|
||||
craneLib = crane.lib.${system};
|
||||
craneLib = (crane.mkLib pkgs).overrideToolchain rs-toolchain;
|
||||
rs-toolchain = with fenix.packages.${system};
|
||||
combine [
|
||||
complete.toolchain
|
||||
targets.wasm32-unknown-unknown.latest.rust-std
|
||||
# targets.x86_64-pc-windows-gnu.latest.rust-std
|
||||
# rust-analyzer
|
||||
];
|
||||
my-crate = craneLib.buildPackage {
|
||||
img-proc = craneLib.buildPackage {
|
||||
src = craneLib.cleanCargoSource (craneLib.path ./.);
|
||||
|
||||
strictDeps = true;
|
||||
doCheck = false;
|
||||
|
||||
buildInputs =
|
||||
[
|
||||
# Add additional build inputs here
|
||||
]
|
||||
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
|
||||
# Additional darwin specific inputs can be set here
|
||||
pkgs.libiconv
|
||||
CARGO_BUILD_TARGET = "x86_64-pc-windows-gnu";
|
||||
|
||||
# fixes issues related to libring
|
||||
TARGET_CC = "${pkgs.pkgsCross.mingwW64.stdenv.cc}/bin/${pkgs.pkgsCross.mingwW64.stdenv.cc.targetPrefix}cc";
|
||||
|
||||
#fixes issues related to openssl
|
||||
OPENSSL_DIR = "${pkgs.openssl.dev}";
|
||||
OPENSSL_LIB_DIR = "${pkgs.openssl.out}/lib";
|
||||
OPENSSL_INCLUDE_DIR = "${pkgs.openssl.dev}/include/";
|
||||
|
||||
depsBuildBuild = with pkgs; [
|
||||
pkgsCross.mingwW64.stdenv.cc
|
||||
pkgsCross.mingwW64.windows.pthreads
|
||||
];
|
||||
|
||||
# Additional environment variables can be set directly
|
||||
# MY_CUSTOM_VAR = "some value";
|
||||
};
|
||||
in {
|
||||
packages.default = my-crate;
|
||||
packages.default = img-proc;
|
||||
|
||||
apps.default = flake-utils.lib.mkApp {
|
||||
drv = my-crate;
|
||||
drv = img-proc;
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShell rec {
|
||||
|
@ -70,7 +68,6 @@
|
|||
rs-toolchain
|
||||
udev
|
||||
alsa-lib
|
||||
vulkan-loader
|
||||
libxkbcommon
|
||||
wayland
|
||||
xorg.libX11
|
||||
|
@ -81,7 +78,14 @@
|
|||
clang
|
||||
trunk
|
||||
binaryen
|
||||
wgsl_analyzer.outputs.packages."x86_64-linux".default
|
||||
|
||||
libGL
|
||||
vulkan-headers
|
||||
vulkan-loader
|
||||
vulkan-tools
|
||||
vulkan-tools-lunarg
|
||||
vulkan-extension-layer
|
||||
vulkan-validation-layers
|
||||
];
|
||||
|
||||
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use eframe::egui;
|
||||
use nalgebra::{Matrix, SMatrix};
|
||||
use nalgebra::SMatrix;
|
||||
|
||||
pub fn mat_editor<const R: usize, const C: usize>(
|
||||
ui: &mut egui::Ui,
|
||||
|
|
|
@ -4,8 +4,8 @@ use std::{
|
|||
};
|
||||
|
||||
use eframe::egui::{self, TextureOptions};
|
||||
use image::{DynamicImage, Pixel, Rgb, Rgb32FImage};
|
||||
use nalgebra::{ComplexField, Const, Matrix, OMatrix, SMatrix, Vector3, Vector4};
|
||||
use image::{DynamicImage, Rgb, Rgb32FImage};
|
||||
use nalgebra::{Const, OMatrix, SMatrix, Vector3, Vector4};
|
||||
use rayon::prelude::*;
|
||||
|
||||
use image::EncodableLayout;
|
||||
|
|
31
src/lib.rs
31
src/lib.rs
|
@ -1,14 +1,10 @@
|
|||
use std::{num::NonZeroU64, path::PathBuf, sync::Arc, thread};
|
||||
use std::{path::PathBuf, sync::Arc};
|
||||
|
||||
use eframe::{
|
||||
egui::{self, ImageSource},
|
||||
egui_wgpu,
|
||||
wgpu::{self, util::DeviceExt},
|
||||
};
|
||||
use eframe::egui::{self, Vec2};
|
||||
use egui_file_dialog::FileDialog;
|
||||
use image::Rgb32FImage;
|
||||
use img_processor::Processor;
|
||||
use nalgebra::{Matrix3, SMatrix};
|
||||
use nalgebra::SMatrix;
|
||||
use oneshot::TryRecvError;
|
||||
|
||||
mod components;
|
||||
|
@ -20,30 +16,34 @@ pub struct App {
|
|||
file_dialog: FileDialog,
|
||||
new_file: Option<PathBuf>,
|
||||
cur_img: Option<Arc<Rgb32FImage>>,
|
||||
preview_img: Option<Arc<Rgb32FImage>>,
|
||||
space_available: (u32, u32),
|
||||
proc: Processor,
|
||||
cur_rx: Option<oneshot::Receiver<(egui::TextureHandle, (f32, f32))>>,
|
||||
cur_res: Option<egui::TextureHandle>,
|
||||
cur_size: Option<(f32, f32)>,
|
||||
}
|
||||
impl App {
|
||||
pub fn new<'a>(cc: &'a eframe::CreationContext<'a>) -> Option<Self> {
|
||||
pub fn new<'a>(_cc: &'a eframe::CreationContext<'a>) -> Option<Self> {
|
||||
Some(Self {
|
||||
color_matrix: SMatrix::identity(),
|
||||
pos_matrix: SMatrix::identity(),
|
||||
file_dialog: FileDialog::new(),
|
||||
new_file: None,
|
||||
cur_img: None,
|
||||
preview_img: None,
|
||||
proc: Processor::init(),
|
||||
cur_rx: None,
|
||||
cur_res: None,
|
||||
cur_size: None,
|
||||
space_available: (1, 1),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl eframe::App for App {
|
||||
fn update(&mut self, ctx: &eframe::egui::Context, frame: &mut eframe::Frame) {
|
||||
let mut mats_changed = false;
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
// let mut mats_changed = false;
|
||||
egui::SidePanel::right("sidebar").show(ctx, |ui| {
|
||||
if ui.button("Select Image").clicked() {
|
||||
self.file_dialog.select_file()
|
||||
|
@ -79,10 +79,10 @@ impl eframe::App for App {
|
|||
let pos_mat_edited =
|
||||
components::mat_editor(ui, &mut self.pos_matrix, "pos_matrix", true).changed();
|
||||
|
||||
if dbg!(self.cur_img.is_some())
|
||||
&& dbg!((color_mat_edited || pos_mat_edited))
|
||||
&& dbg!(self.cur_res.is_some())
|
||||
&& dbg!(self.cur_rx.is_none())
|
||||
if self.cur_img.is_some()
|
||||
&& (color_mat_edited || pos_mat_edited)
|
||||
&& self.cur_res.is_some()
|
||||
&& self.cur_rx.is_none()
|
||||
{
|
||||
self.cur_rx = Some(self.proc.exec(
|
||||
self.cur_img.clone().unwrap(),
|
||||
|
@ -95,7 +95,8 @@ impl eframe::App for App {
|
|||
}
|
||||
});
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui.heading("My egui Application");
|
||||
let Vec2 { x, y } = ui.available_size();
|
||||
self.space_available = (x as u32, y as u32);
|
||||
|
||||
if let Some(r) = &self.cur_rx {
|
||||
match r.try_recv() {
|
||||
|
|
|
@ -8,6 +8,6 @@ fn main() -> Result<(), eframe::Error> {
|
|||
renderer: eframe::Renderer::Wgpu,
|
||||
..Default::default()
|
||||
},
|
||||
Box::new(|cc| Box::new(App::new(cc).unwrap())),
|
||||
Box::new(|cc| Ok(Box::new(App::new(cc).unwrap()))),
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue