From 498b7594b7d34b5580ad959e820507541db11a07 Mon Sep 17 00:00:00 2001 From: Ano-sys Date: Thu, 3 Apr 2025 18:56:00 +0200 Subject: [PATCH] Window Name setable through app.run(...) --- main.cpp | 2 +- vulkan/vulkan_app.cpp | 13 +++++++++---- vulkan/vulkan_app.hpp | 7 +++++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/main.cpp b/main.cpp index 1e4086e..da7cfce 100644 --- a/main.cpp +++ b/main.cpp @@ -8,7 +8,7 @@ int main(){ try{ vapp::Vulkan app; - app.run(1200, 900); + app.run("Vulkan", 1200, 900); } catch(const std::exception& e){ std::cerr << e.what() << std::endl; diff --git a/vulkan/vulkan_app.cpp b/vulkan/vulkan_app.cpp index a555063..63e3bd5 100644 --- a/vulkan/vulkan_app.cpp +++ b/vulkan/vulkan_app.cpp @@ -558,6 +558,11 @@ void Vulkan::createGraphicsPipeline(){ pipelineInfo.renderPass = renderPass; pipelineInfo.subpass = 0; + /* Performance optimization entrypoint + pipelineInfo.basePipelineIndex = -1; + pipelineInfo.basePipelineHandle = VK_NULL_HANDLE; + */ + if(vkCreateGraphicsPipelines(device, VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &graphicsPipeline) != VK_SUCCESS){ throw std::runtime_error("Func; createGraphicsPipeline\nError: Failed to create graphics pipeline!\n"); } @@ -769,11 +774,11 @@ void Vulkan::drawFrame(){ vkQueuePresentKHR(presentQueue, &presentInfo); } -void Vulkan::initWindow(){ +void Vulkan::initWindow(const char* windowName){ glfwInit(); glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); // tell glfw to not use opengl glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); // disable window resize - this->window = glfwCreateWindow(static_cast(_width), static_cast(_height), "Vulkan", nullptr, nullptr); + this->window = glfwCreateWindow(static_cast(_width), static_cast(_height), windowName, nullptr, nullptr); } void Vulkan::initVulkan(){ @@ -838,11 +843,11 @@ void Vulkan::cleanup(){ glfwTerminate(); } -void Vulkan::run(const uint32_t width, const uint32_t height){ +void Vulkan::run(const char* windowName, const uint32_t width, const uint32_t height){ this->_width = width; this->_height = height; - initWindow(); + initWindow(windowName); initVulkan(); mainLoop(); cleanup(); diff --git a/vulkan/vulkan_app.hpp b/vulkan/vulkan_app.hpp index 39f6e6c..96171da 100644 --- a/vulkan/vulkan_app.hpp +++ b/vulkan/vulkan_app.hpp @@ -22,6 +22,7 @@ namespace vapp{ +// Change here for other presentMode const VkPresentModeKHR WISHED_PRESENT_MODE = VK_PRESENT_MODE_MAILBOX_KHR; typedef struct _QueueFamilyIndices{ @@ -43,6 +44,7 @@ static std::vector readFile(const std::string &filename); class Vulkan{ private: +#pragma region Fields GLFWwindow *window; uint32_t _width, _height; @@ -76,6 +78,7 @@ private: VkFence inFlightFence; std::vector swapChainFramebuffers; +#pragma endregion bool checkValidationLayerSupport(); std::vector getRequiredExtensions(); @@ -103,7 +106,7 @@ private: void recordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t imageIndex); void createSyncObjects(); void drawFrame(); - void initWindow(); + void initWindow(const char* windowName); void initVulkan(); void mainLoop(); void cleanup(); @@ -115,7 +118,7 @@ public: const bool enableValidationLayers = false; #endif - void run(const uint32_t width = 800, const uint32_t height = 600); + void run(const char* windowName, const uint32_t width = 800, const uint32_t height = 600); }; } // vapp