Prepped for NixOS with clang.

This commit is contained in:
kidrigger 2025-02-02 01:09:45 +01:00
parent 14f4ac39be
commit 596f0c601f
7 changed files with 86 additions and 30 deletions

1
.envrc Normal file
View File

@ -0,0 +1 @@
use nix

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
.cache/
build/
.vs/
.direnv/

View File

@ -18,6 +18,22 @@
"rhs": "Linux"
}
},
{
"name": "nixos",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": true,
"CMAKE_MAKE_PROGRAM": "ninja",
"CMAKE_C_COMPILER": "$env{CC}",
"CMAKE_CXX_COMPILER": "$env{CXX}"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
}
},
{
"name": "windows-debug",
"generator": "Ninja",

8
run.sh
View File

@ -1,12 +1,12 @@
#!/usr/bin/env bash
if [ -d "out" ]; then
pushd ./build/ > /dev/null || exit
if [ -d "build" ]; then
pushd ./build/samples/04_scenes/ > /dev/null || exit
if echo "$@" | grep -e "debug" -q
then
lldb aster-exe
lldb ./scene_render
else
./aster-exe
./scene_render
fi
popd > /dev/null || exit
else

View File

@ -58,7 +58,7 @@ Init(const Context *context, const Device *device, const Window *window, vk::For
CreateContext();
ImGuiIO &io = GetIO();
(void)io;
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
// io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
// io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Viewports bad
StyleColorsDark();
@ -108,16 +108,16 @@ StartBuild()
ImGui_ImplGlfw_NewFrame();
NewFrame();
static ImGuiDockNodeFlags dockspaceFlags = ImGuiDockNodeFlags_None | ImGuiDockNodeFlags_PassthruCentralNode;
// static ImGuiDockNodeFlags dockspaceFlags = ImGuiDockNodeFlags_None | ImGuiDockNodeFlags_PassthruCentralNode;
// We are using the ImGuiWindowFlags_NoDocking flag to make the parent window not dockable into,
// because it would be confusing to have two docking targets within each others.
ImGuiWindowFlags windowFlags = ImGuiWindowFlags_NoDocking;
ImGuiWindowFlags windowFlags = ImGuiWindowFlags_None; // ImGuiWindowFlags_NoDocking;
const ImGuiViewport *viewport = GetMainViewport();
SetNextWindowPos(viewport->WorkPos);
SetNextWindowSize(viewport->WorkSize);
SetNextWindowViewport(viewport->ID);
// SetNextWindowViewport(viewport->ID);
PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
windowFlags |=
@ -130,18 +130,18 @@ StartBuild()
// all active windows docked into it will lose their parent and become undocked.
// We cannot preserve the docking relationship between an active window and an inactive docking, otherwise
// any change of dockspace/settings would lead to windows being stuck in limbo and never being visible.
PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
Begin("DockSpace Demo", nullptr, windowFlags);
PopStyleVar();
// PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
// Begin("DockSpace Demo", nullptr, windowFlags);
// PopStyleVar();
PopStyleVar(2);
// PopStyleVar(2);
// DockSpace
if (GetIO().ConfigFlags & ImGuiConfigFlags_DockingEnable)
{
const ImGuiID dockspaceId = GetID("MyDockSpace");
DockSpace(dockspaceId, ImVec2(0.0f, 0.0f), dockspaceFlags);
}
// if (GetIO().ConfigFlags & ImGuiConfigFlags_DockingEnable)
// {
// const ImGuiID dockspaceId = GetID("MyDockSpace");
// DockSpace(dockspaceId, ImVec2(0.0f, 0.0f), dockspaceFlags);
// }
}
void
@ -151,13 +151,13 @@ EndBuild()
Render();
EndFrame();
if (GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
GLFWwindow *backupCurrentContext = glfwGetCurrentContext();
UpdatePlatformWindows();
RenderPlatformWindowsDefault();
glfwMakeContextCurrent(backupCurrentContext);
}
// if (GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
// {
// GLFWwindow *backupCurrentContext = glfwGetCurrentContext();
// UpdatePlatformWindows();
// RenderPlatformWindowsDefault();
// glfwMakeContextCurrent(backupCurrentContext);
// }
}
void

View File

@ -753,8 +753,8 @@ AssetLoader::ProcessNode(tinygltf::Model *model, eastl::vector<vec4> *vertexPosi
entities->push_back(entity);
m_Registry->emplace<CMesh>(entity, CMesh{
.m_VertexPositionPtr = vertexOffset * sizeof vec4,
.m_VertexDataPtr = vertexOffset * sizeof VertexData,
.m_VertexPositionPtr = vertexOffset * sizeof(vec4),
.m_VertexDataPtr = vertexOffset * sizeof(VertexData),
.m_FirstIndex = indexOffset,
.m_IndexCount = indexCount,
});
@ -764,7 +764,7 @@ AssetLoader::ProcessNode(tinygltf::Model *model, eastl::vector<vec4> *vertexPosi
m_Registry->emplace<CParent<CDynamicTransform>>(entity, nodeRoot);
if (prim.material >= 0)
{
m_Registry->emplace<CMaterial>(entity, sizeof Material * loadMaterial(prim.material));
m_Registry->emplace<CMaterial>(entity, sizeof(Material) * loadMaterial(prim.material));
m_Registry->emplace<CRequiresPostLoadProcess<CMaterial>>(entity);
}

38
shell.nix Normal file
View File

@ -0,0 +1,38 @@
{ pkgs ? import <nixpkgs> {} }:
let eabase = pkgs.callPackage ../eabase-nix/eabase.nix {}; in
let eastl = pkgs.callPackage ../eastl-nix/eastl.nix { inherit eabase; }; in
let tinygltf = pkgs.callPackage ../tinygltf-nix/tinygltf.nix {}; in
let debugbreak = pkgs.callPackage ../scottt-debugbreak-nix/debugbreak.nix {}; in
pkgs.clangStdenv.mkDerivation {
name = "aster-env";
nativeBuildInputs = with pkgs; [
cmake
ninja
(imgui.override {IMGUI_BUILD_VULKAN_BINDING = true; IMGUI_BUILD_GLFW_BINDING=true; })
];
buildInputs = with pkgs; [
glm
glfw3
eastl
fmt
eabase
eastl
entt
tinygltf
debugbreak
stb
# vulkan
vulkan-headers
vulkan-loader
vulkan-validation-layers
vulkan-memory-allocator
directx-shader-compiler
glslang
shaderc
];
}