forked from pupbrained/vulkan-test
blegh
This commit is contained in:
parent
7632347218
commit
154a81721d
|
@ -1,10 +1,6 @@
|
|||
# This file was generated by nvfetcher, please do not modify it manually.
|
||||
{ fetchgit, fetchurl, fetchFromGitHub, dockerTools }:
|
||||
{
|
||||
fetchgit,
|
||||
fetchurl,
|
||||
fetchFromGitHub,
|
||||
dockerTools,
|
||||
}: {
|
||||
fmt = {
|
||||
pname = "fmt";
|
||||
version = "11.0.2";
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1728698577,
|
||||
"narHash": "sha256-hdbJjMr9myxGcByVlR9zAbQsWfZwl6NKzZodmyTzACc=",
|
||||
"lastModified": 1729022018,
|
||||
"narHash": "sha256-fsZYL4ggDUvVvIcnBk16dSsSsLlg3H4cMzs26FZuqCs=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "d4c28e77c38d73b23346656c102a94d90af3cf60",
|
||||
"rev": "f490aba9999744d0ecb5e5594760a606de441ad6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
@ -40,10 +40,16 @@
|
|||
|
||||
fmt = mkPkg "fmt";
|
||||
|
||||
imgui = pkgs.imgui.override {
|
||||
IMGUI_BUILD_GLFW_BINDING = true;
|
||||
IMGUI_BUILD_VULKAN_BINDING = true;
|
||||
};
|
||||
|
||||
deps = with pkgs; [
|
||||
fmt
|
||||
glfw
|
||||
glm
|
||||
imgui
|
||||
shaderc
|
||||
vulkan-extension-layer
|
||||
vulkan-memory-allocator
|
||||
|
@ -106,7 +112,7 @@
|
|||
meson
|
||||
nil
|
||||
ninja
|
||||
nvfetcher
|
||||
#nvfetcher
|
||||
pkg-config
|
||||
unzip
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ deps = [
|
|||
dependency('glfw3', include_type: 'system'),
|
||||
dependency('glm', include_type: 'system'),
|
||||
dependency('vulkan', include_type: 'system'),
|
||||
cpp.find_library('imgui'),
|
||||
]
|
||||
|
||||
executable(
|
||||
|
|
54
src/main.cpp
54
src/main.cpp
|
@ -35,6 +35,11 @@ VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE
|
|||
// Vertex class
|
||||
#include "util/vertex.h"
|
||||
|
||||
// ImGui
|
||||
#include <imgui.h>
|
||||
#include <imgui_impl_glfw.h>
|
||||
#include <imgui_impl_vulkan.h>
|
||||
|
||||
// Use {} instead of ()
|
||||
#define VKFW_NO_STRUCT_CONSTRUCTORS
|
||||
// GLFW C++ wrapper
|
||||
|
@ -77,6 +82,12 @@ class VulkanApp {
|
|||
initVulkan();
|
||||
// Render loop
|
||||
mainLoop();
|
||||
|
||||
cleanupSwapChain();
|
||||
|
||||
ImGui_ImplVulkan_Shutdown();
|
||||
ImGui_ImplGlfw_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -239,6 +250,39 @@ class VulkanApp {
|
|||
createDescriptorSets();
|
||||
createCommandBuffers();
|
||||
createSyncObjects();
|
||||
initImGui();
|
||||
}
|
||||
|
||||
void initImGui() {
|
||||
// Create ImGui context
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
|
||||
// Setup Dear ImGui style
|
||||
ImGui::StyleColorsDark();
|
||||
|
||||
// Initialize ImGui for GLFW and Vulkan
|
||||
ImGui_ImplGlfw_InitForVulkan(mWindow.get(), true);
|
||||
|
||||
ImGui_ImplVulkan_InitInfo initInfo = {};
|
||||
initInfo.Instance = mInstance.get();
|
||||
initInfo.PhysicalDevice = mPhysicalDevice;
|
||||
initInfo.Device = mDevice.get();
|
||||
initInfo.QueueFamily = findQueueFamilies(mPhysicalDevice).graphics_family.value();
|
||||
initInfo.Queue = mGraphicsQueue;
|
||||
initInfo.PipelineCache = VK_NULL_HANDLE;
|
||||
initInfo.DescriptorPool = mDescriptorPool.get();
|
||||
initInfo.RenderPass = mRenderPass.get();
|
||||
initInfo.MSAASamples = static_cast<VkSampleCountFlagBits>(mMsaaSamples);
|
||||
initInfo.Allocator = nullptr;
|
||||
initInfo.MinImageCount = MAX_FRAMES_IN_FLIGHT;
|
||||
initInfo.ImageCount = static_cast<uint32_t>(mSwapChainImages.size());
|
||||
initInfo.CheckVkResultFn = nullptr;
|
||||
|
||||
ImGui_ImplVulkan_Init(&initInfo);
|
||||
|
||||
// Upload Fonts
|
||||
ImGui_ImplVulkan_CreateFontsTexture();
|
||||
}
|
||||
|
||||
// Main loop
|
||||
|
@ -1565,6 +1609,16 @@ class VulkanApp {
|
|||
// Draw the indexed vertices
|
||||
commandBuffer.drawIndexed(static_cast<u32>(mIndices.size()), 1, 0, 0, 0);
|
||||
|
||||
ImGui_ImplVulkan_NewFrame();
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
// Your ImGui code here
|
||||
ImGui::ShowDemoWindow();
|
||||
|
||||
ImGui::Render();
|
||||
ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), commandBuffer);
|
||||
|
||||
// End the render pass
|
||||
commandBuffer.endRenderPass();
|
||||
|
||||
|
|
Loading…
Reference in a new issue