setup (draw a circle /m)

This commit is contained in:
Schrottkatze 2025-05-14 13:28:18 +02:00
commit 08069c9224
Signed by: schrottkatze
SSH key fingerprint: SHA256:FPOYVeBy3QP20FEM42uWF1Wa/Qhlk+L3S2+Wuau/Auo
9 changed files with 5452 additions and 0 deletions

22
.cargo/config.toml Normal file
View file

@ -0,0 +1,22 @@
# for Linux
[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = [
"-C", "link-arg=-fuse-ld=lld",
# (Nightly) Make the current crate share its generic instantiations
"-Zshare-generics=y",
]
# for Windows
[target.x86_64-pc-windows-msvc]
linker = "rust-lld.exe"
[unstable]
codegen-backend = true
[profile.dev]
codegen-backend = "cranelift"
[profile.dev.package."*"]
codegen-backend = "llvm"

1
.envrc Normal file
View file

@ -0,0 +1 @@
use flake --log-format multiline-with-logs

9
.gitignore vendored Normal file
View file

@ -0,0 +1,9 @@
/target
/.direnv
# Added by cargo
#
# already existing elements were commented out
#/target

5198
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

17
Cargo.toml Normal file
View file

@ -0,0 +1,17 @@
[package]
name = "mgd2-tram-championships"
version = "0.1.0"
edition = "2024"
[dependencies]
bevy = "0.16.0"
env_logger = "0.11.8"
log = "0.4.27"
# Enable a small amount of optimization in the dev profile.
[profile.dev]
opt-level = 1
# Enable a large amount of optimization in the dev profile for dependencies.
[profile.dev.package."*"]
opt-level = 3

100
flake.lock generated Normal file
View file

@ -0,0 +1,100 @@
{
"nodes": {
"fenix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1747204728,
"narHash": "sha256-7/Vo6GFBzCZt0kB1e9RdRCJkpkgKulNnzLv+7thOR7o=",
"owner": "nix-community",
"repo": "fenix",
"rev": "9318ae6e7c219ea317a67fd133bf82de07b4594e",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1747060738,
"narHash": "sha256-ByfPRQuqj+nhtVV0koinEpmJw0KLzNbgcgi9EF+NVow=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "eaeed9530c76ce5f1d2d8232e08bec5e26f18ec1",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"fenix": "fenix",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1746889290,
"narHash": "sha256-h3LQYZgyv2l3U7r+mcsrEOGRldaK0zJFwAAva4hV/6g=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "2bafe9d96c6734aacfd49e115f6cf61e7adc68bc",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

66
flake.nix Normal file
View file

@ -0,0 +1,66 @@
{
description = "Build a cargo project without extra checks";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
fenix,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
rs-toolchain =
with fenix.packages.${system};
combine [
complete.toolchain
];
in
{
devShells.default = pkgs.mkShell rec {
buildInputs = with pkgs; [
cargo-watch
pkg-config
rs-toolchain
udev
alsa-lib
glfw
freetype
vulkan-headers
vulkan-loader
vulkan-validation-layers
vulkan-tools # vulkaninfo
shaderc # GLSL to SPIRV compiler - glslc
renderdoc # Graphics debugger
tracy # Graphics profiler
vulkan-tools-lunarg
xorg.libX11
xorg.libXcursor
xorg.libXi
xorg.libXrandr # To use the x11 feature
libxkbcommon
wayland
clang
llvmPackages.bintools
];
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
};
}
);
}

3
rust-toolchain.toml Normal file
View file

@ -0,0 +1,3 @@
[toolchain]
channel = "nightly"

36
src/main.rs Normal file
View file

@ -0,0 +1,36 @@
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, yeet)
.run();
}
fn yeet(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
commands.spawn((
Mesh3d(meshes.add(Cuboid::new(1.0, 1.0, 1.0))),
MeshMaterial3d(materials.add(Color::srgb_u8(255, 255, 255))),
Transform::from_xyz(0.0, 0.5, 0.0),
));
commands.spawn((
Mesh3d(meshes.add(Plane3d::new(Vec3::Y, vec2(4., 4.)))),
MeshMaterial3d(materials.add(Color::srgb_u8(255, 255, 255))),
Transform::from_xyz(0., 0., 0.),
));
commands.spawn((
PointLight {
shadows_enabled: true,
..default()
},
Transform::from_xyz(4.0, 8.0, 4.0),
));
commands.spawn((
Camera3d::default(),
Transform::from_xyz(-4.5, 3.5, 4.5).looking_at(Vec3::ZERO, Vec3::Y),
));
}