Window Name setable through app.run(...)

This commit is contained in:
Ano-sys
2025-04-03 18:56:00 +02:00
parent 847d39906d
commit 498b7594b7
3 changed files with 15 additions and 7 deletions
+1 -1
View File
@@ -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;
+9 -4
View File
@@ -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<int>(_width), static_cast<int>(_height), "Vulkan", nullptr, nullptr);
this->window = glfwCreateWindow(static_cast<int>(_width), static_cast<int>(_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();
+5 -2
View File
@@ -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<char> 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<VkFramebuffer> swapChainFramebuffers;
#pragma endregion
bool checkValidationLayerSupport();
std::vector<const char*> 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