From 9b93436efd4d66fc4606796a5c12ca7dfe3600ff Mon Sep 17 00:00:00 2001 From: Mars Date: Tue, 8 Oct 2024 23:56:24 -0400 Subject: [PATCH] weh --- flake.nix | 78 +++++++++++++++++++++++++--------------------------- src/main.cpp | 3 ++ 2 files changed, 40 insertions(+), 41 deletions(-) diff --git a/flake.nix b/flake.nix index 8cd7599..c4abe6e 100644 --- a/flake.nix +++ b/flake.nix @@ -24,19 +24,14 @@ }; }; - stdenv = - if pkgs.hostPlatform.isLinux - then pkgs.stdenvAdapters.useMoldLinker pkgs.llvmPackages_18.libcxxStdenv - else pkgs.llvmPackages_18.libcxxStdenv; + stdenv = with pkgs; + if hostPlatform.isLinux + then stdenvAdapters.useMoldLinker llvmPackages_18.libcxxStdenv + else llvmPackages_18.libcxxStdenv; - sources = import ./_sources/generated.nix { - inherit (pkgs) fetchFromGitHub fetchgit fetchurl dockerTools; - }; + sources = import ./_sources/generated.nix {inherit (pkgs) fetchFromGitHub fetchgit fetchurl dockerTools;}; - mkPkg = name: - pkgs.${name}.overrideAttrs { - inherit (sources.${name}) pname version src; - }; + mkPkg = name: pkgs.${name}.overrideAttrs {inherit (sources.${name}) pname version src;}; fmt = mkPkg "fmt"; @@ -51,52 +46,53 @@ vulkan-loader vulkan-tools ]; - in - with pkgs; rec { - packages = rec { - graphics-test = stdenv.mkDerivation { - name = "graphics-test"; - version = "0.1.0"; - src = self; + in rec { + packages = rec { + graphics-test = stdenv.mkDerivation { + name = "graphics-test"; + version = "0.1.0"; + src = self; - nativeBuildInputs = [ - meson - ninja - pkg-config - ]; + nativeBuildInputs = with pkgs; [ + meson + ninja + pkg-config + ]; - buildInputs = deps; + buildInputs = deps; - configurePhase = '' - meson setup build - ''; + configurePhase = '' + meson setup build + ''; - buildPhase = '' - meson compile -C build - ''; + buildPhase = '' + meson compile -C build + ''; - installPhase = '' - mkdir -p $out/bin - mv build/graphics-test $out/bin/graphics-test - ''; - }; - - default = graphics-test; + installPhase = '' + mkdir -p $out/bin + mv build/graphics-test $out/bin/graphics-test + ''; }; - formatter = treefmt-nix.lib.mkWrapper pkgs { + default = graphics-test; + }; + + formatter = with pkgs; + treefmt-nix.lib.mkWrapper pkgs { projectRootFile = "flake.nix"; programs = { alejandra.enable = true; clang-format = { enable = true; - package = pkgs.llvmPackages_18.clang-tools; + package = llvmPackages_18.clang-tools; }; }; }; - devShell = mkShell.override {inherit stdenv;} { + devShell = with pkgs; + mkShell.override {inherit stdenv;} { packages = [ alejandra @@ -134,6 +130,6 @@ name = "C++"; }; - } + } ); } diff --git a/src/main.cpp b/src/main.cpp index ada3ed1..5e71303 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -38,6 +38,7 @@ constexpr bool enableValidationLayers = true; class VulkanApp { public: fn run() -> void { + // Create a window initWindow(); initVulkan(); mainLoop(); @@ -854,11 +855,13 @@ class VulkanApp { }; fn main() -> i32 { + // Allows for loading functions dynamically at runtime vk::DynamicLoader dynamicLoader; auto vkGetInstanceProcAddr = dynamicLoader.getProcAddress("vkGetInstanceProcAddr"); VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr); + // Create app object VulkanApp app; try {