Window Name setable through app.run(...)
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
int main(){
|
int main(){
|
||||||
try{
|
try{
|
||||||
vapp::Vulkan app;
|
vapp::Vulkan app;
|
||||||
app.run(1200, 900);
|
app.run("Vulkan", 1200, 900);
|
||||||
}
|
}
|
||||||
catch(const std::exception& e){
|
catch(const std::exception& e){
|
||||||
std::cerr << e.what() << std::endl;
|
std::cerr << e.what() << std::endl;
|
||||||
|
|||||||
@@ -558,6 +558,11 @@ void Vulkan::createGraphicsPipeline(){
|
|||||||
pipelineInfo.renderPass = renderPass;
|
pipelineInfo.renderPass = renderPass;
|
||||||
pipelineInfo.subpass = 0;
|
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){
|
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");
|
throw std::runtime_error("Func; createGraphicsPipeline\nError: Failed to create graphics pipeline!\n");
|
||||||
}
|
}
|
||||||
@@ -769,11 +774,11 @@ void Vulkan::drawFrame(){
|
|||||||
vkQueuePresentKHR(presentQueue, &presentInfo);
|
vkQueuePresentKHR(presentQueue, &presentInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vulkan::initWindow(){
|
void Vulkan::initWindow(const char* windowName){
|
||||||
glfwInit();
|
glfwInit();
|
||||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); // tell glfw to not use opengl
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); // tell glfw to not use opengl
|
||||||
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); // disable window resize
|
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(){
|
void Vulkan::initVulkan(){
|
||||||
@@ -838,11 +843,11 @@ void Vulkan::cleanup(){
|
|||||||
glfwTerminate();
|
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->_width = width;
|
||||||
this->_height = height;
|
this->_height = height;
|
||||||
|
|
||||||
initWindow();
|
initWindow(windowName);
|
||||||
initVulkan();
|
initVulkan();
|
||||||
mainLoop();
|
mainLoop();
|
||||||
cleanup();
|
cleanup();
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
namespace vapp{
|
namespace vapp{
|
||||||
|
|
||||||
|
// Change here for other presentMode
|
||||||
const VkPresentModeKHR WISHED_PRESENT_MODE = VK_PRESENT_MODE_MAILBOX_KHR;
|
const VkPresentModeKHR WISHED_PRESENT_MODE = VK_PRESENT_MODE_MAILBOX_KHR;
|
||||||
|
|
||||||
typedef struct _QueueFamilyIndices{
|
typedef struct _QueueFamilyIndices{
|
||||||
@@ -43,6 +44,7 @@ static std::vector<char> readFile(const std::string &filename);
|
|||||||
|
|
||||||
class Vulkan{
|
class Vulkan{
|
||||||
private:
|
private:
|
||||||
|
#pragma region Fields
|
||||||
GLFWwindow *window;
|
GLFWwindow *window;
|
||||||
uint32_t _width, _height;
|
uint32_t _width, _height;
|
||||||
|
|
||||||
@@ -76,6 +78,7 @@ private:
|
|||||||
VkFence inFlightFence;
|
VkFence inFlightFence;
|
||||||
|
|
||||||
std::vector<VkFramebuffer> swapChainFramebuffers;
|
std::vector<VkFramebuffer> swapChainFramebuffers;
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
bool checkValidationLayerSupport();
|
bool checkValidationLayerSupport();
|
||||||
std::vector<const char*> getRequiredExtensions();
|
std::vector<const char*> getRequiredExtensions();
|
||||||
@@ -103,7 +106,7 @@ private:
|
|||||||
void recordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t imageIndex);
|
void recordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t imageIndex);
|
||||||
void createSyncObjects();
|
void createSyncObjects();
|
||||||
void drawFrame();
|
void drawFrame();
|
||||||
void initWindow();
|
void initWindow(const char* windowName);
|
||||||
void initVulkan();
|
void initVulkan();
|
||||||
void mainLoop();
|
void mainLoop();
|
||||||
void cleanup();
|
void cleanup();
|
||||||
@@ -115,7 +118,7 @@ public:
|
|||||||
const bool enableValidationLayers = false;
|
const bool enableValidationLayers = false;
|
||||||
#endif
|
#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
|
} // vapp
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user