Adding more Window validation
This commit is contained in:
1 parent
7271fe8a0b
commit
87390db80d
4 files changed
+50
-23
No files matched your search
@@ -4,6 +4,7 @@
|
||||
#include "Graphics.h"
|
||||
#include "Resources.h"
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <sstream>
|
||||
|
||||
using namespace Seele;
|
||||
using namespace Seele::Vulkan;
|
||||
@@ -61,6 +62,16 @@ Window::Window(PGraphics graphics, const WindowCreateInfo& createInfo)
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
|
||||
GLFWwindow* handle = glfwCreateWindow(createInfo.width / contentScaleX, createInfo.height / contentScaleY, createInfo.title, nullptr, nullptr);
|
||||
if (handle == nullptr) {
|
||||
const char* glfwError = nullptr;
|
||||
glfwGetError(&glfwError);
|
||||
std::string message = "Failed to create GLFW window";
|
||||
if (glfwError != nullptr) {
|
||||
message += ": ";
|
||||
message += glfwError;
|
||||
}
|
||||
throw std::runtime_error(message);
|
||||
}
|
||||
windowHandle = handle;
|
||||
glfwSetWindowUserPointer(handle, this);
|
||||
|
||||
@@ -73,7 +84,17 @@ Window::Window(PGraphics graphics, const WindowCreateInfo& createInfo)
|
||||
glfwSetFramebufferSizeCallback(handle, &glfwFramebufferResizeCallback);
|
||||
// glfwSetWindowSizeCallback(handle, &glfwResizeCallback);
|
||||
|
||||
glfwCreateWindowSurface(instance, handle, nullptr, &surface);
|
||||
VkResult surfaceResult = glfwCreateWindowSurface(instance, handle, nullptr, &surface);
|
||||
if (surfaceResult != VK_SUCCESS || surface == VK_NULL_HANDLE) {
|
||||
const char* glfwError = nullptr;
|
||||
glfwGetError(&glfwError);
|
||||
std::ostringstream oss;
|
||||
oss << "Failed to create Vulkan surface via GLFW (VkResult=" << surfaceResult << ")";
|
||||
if (glfwError != nullptr) {
|
||||
oss << ": " << glfwError;
|
||||
}
|
||||
throw std::runtime_error(oss.str());
|
||||
}
|
||||
|
||||
querySurface();
|
||||
chooseSwapSurfaceFormat();
|
||||
|
||||
Reference in new issue
Block a user