Window resizing works

This commit is contained in:
Dynamitos
2023-11-18 11:04:30 +01:00
parent ec760e8deb
commit 6daaa61641
12 changed files with 92 additions and 50 deletions
+1
View File
@@ -95,6 +95,7 @@ public:
RenderTargetLayout(Array<PRenderTargetAttachment> inputAttachments, Array<PRenderTargetAttachment> colorAttachments, PRenderTargetAttachment depthAttachment);
Array<PRenderTargetAttachment> inputAttachments;
Array<PRenderTargetAttachment> colorAttachments;
Array<PRenderTargetAttachment> resolveAttachments;
PRenderTargetAttachment depthAttachment;
uint32 width;
uint32 height;
+3 -3
View File
@@ -387,9 +387,9 @@ void Graphics::pickPhysicalDevice()
if (Gfx::useMeshShading)
{
uint32 count = 0;
vkEnumerateDeviceExtensionProperties(physicalDevice, VK_EXT_MESH_SHADER_EXTENSION_NAME, &count, nullptr);
vkEnumerateDeviceExtensionProperties(physicalDevice, NULL, &count, nullptr);
Array<VkExtensionProperties> extensionProps(count);
vkEnumerateDeviceExtensionProperties(physicalDevice, VK_EXT_MESH_SHADER_EXTENSION_NAME, &count, extensionProps.data());
vkEnumerateDeviceExtensionProperties(physicalDevice, NULL, &count, extensionProps.data());
for (size_t i = 0; i < count; ++i)
{
if (std::strcmp(VK_EXT_MESH_SHADER_EXTENSION_NAME, extensionProps[i].extensionName) == 0)
@@ -515,7 +515,7 @@ void Graphics::createDevice(GraphicsInitializer initializer)
if (supportMeshShading())
{
descriptorIndexing.pNext = &enabledMeshShaderFeatures;
initializer.deviceExtensions.add("VK_EXT_mesh_shader");
initializer.deviceExtensions.add(VK_EXT_MESH_SHADER_EXTENSION_NAME);
}
VkDeviceCreateInfo deviceInfo = {
.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
+42 -6
View File
@@ -17,37 +17,37 @@ double Gfx::getCurrentFrameDelta()
void glfwKeyCallback(GLFWwindow* handle, int key, int, int action, int modifier)
{
Window* window = (Window*)glfwGetWindowUserPointer(handle);
window->keyCallback((KeyCode)key, (InputAction)action, (KeyModifier)modifier);
window->keyPress((KeyCode)key, (InputAction)action, (KeyModifier)modifier);
}
void glfwMouseMoveCallback(GLFWwindow* handle, double xpos, double ypos)
{
Window* window = (Window*)glfwGetWindowUserPointer(handle);
window->mouseMoveCallback(xpos, ypos);
window->mouseMove(xpos, ypos);
}
void glfwMouseButtonCallback(GLFWwindow* handle, int button, int action, int modifier)
{
Window* window = (Window*)glfwGetWindowUserPointer(handle);
window->mouseButtonCallback((MouseButton)button, (InputAction)action, (KeyModifier)modifier);
window->mouseButton((MouseButton)button, (InputAction)action, (KeyModifier)modifier);
}
void glfwScrollCallback(GLFWwindow* handle, double xoffset, double yoffset)
{
Window* window = (Window*)glfwGetWindowUserPointer(handle);
window->scrollCallback(xoffset, yoffset);
window->scroll(xoffset, yoffset);
}
void glfwFileCallback(GLFWwindow* handle, int count, const char** paths)
{
Window* window = (Window*)glfwGetWindowUserPointer(handle);
window->fileCallback(count, paths);
window->fileDrop(count, paths);
}
void glfwCloseCallback(GLFWwindow* handle)
{
Window* window = (Window*)glfwGetWindowUserPointer(handle);
window->closeCallback();
window->close();
}
void glfwResizeCallback(GLFWwindow* handle, int width, int height)
{
@@ -171,6 +171,41 @@ void Window::setCloseCallback(std::function<void()> callback)
closeCallback = callback;
}
void Seele::Vulkan::Window::setResizeCallback(std::function<void(uint32, uint32)> callback)
{
resizeCallback = callback;
}
void Window::keyPress(KeyCode code, InputAction action, KeyModifier modifier)
{
keyCallback(code, action, modifier);
}
void Window::mouseMove(double x, double y)
{
mouseMoveCallback(x, y);
}
void Window::mouseButton(MouseButton button, InputAction action, KeyModifier modifier)
{
mouseButtonCallback(button, action, modifier);
}
void Window::scroll(double x, double y)
{
scrollCallback(x, y);
}
void Window::fileDrop(int num, const char** files)
{
fileCallback(num, files);
}
void Window::close()
{
closeCallback();
}
void Window::resize(int width, int height)
{
querySurface();
@@ -181,6 +216,7 @@ void Window::resize(int width, int height)
framebufferWidth = extent.width;
framebufferHeight = extent.height;
createSwapChain();
resizeCallback(width, height);
}
void Window::querySurface()
+16 -7
View File
@@ -23,14 +23,15 @@ public:
virtual void setScrollCallback(std::function<void(double, double)> callback) override;
virtual void setFileCallback(std::function<void(int, const char**)> callback) override;
virtual void setCloseCallback(std::function<void()> callback);
virtual void setResizeCallback(std::function<void(uint32, uint32)> callback) override;
void keyPress(KeyCode code, InputAction action, KeyModifier modifier);
void mouseMove(double x, double y);
void mouseButton(MouseButton button, InputAction action, KeyModifier modifier);
void scroll(double x, double y);
void fileDrop(int num, const char** files);
void close();
void resize(int width, int height);
std::function<void(KeyCode, InputAction, KeyModifier)> keyCallback;
std::function<void(double, double)> mouseMoveCallback;
std::function<void(MouseButton, InputAction, KeyModifier)> mouseButtonCallback;
std::function<void(double, double)> scrollCallback;
std::function<void(int, const char**)> fileCallback;
std::function<void()> closeCallback;
protected:
void querySurface();
void chooseSwapSurfaceFormat();
@@ -57,6 +58,14 @@ protected:
StaticArray<OSemaphore, Gfx::numFramesBuffered> renderingDoneSemaphores;
uint32 currentImageIndex = 0;
uint32 currentSemaphoreIndex = 0;
std::function<void(KeyCode, InputAction, KeyModifier)> keyCallback;
std::function<void(double, double)> mouseMoveCallback;
std::function<void(MouseButton, InputAction, KeyModifier)> mouseButtonCallback;
std::function<void(double, double)> scrollCallback;
std::function<void(int, const char**)> fileCallback;
std::function<void()> closeCallback;
std::function<void(uint32, uint32)> resizeCallback;
};
DEFINE_REF(Window)
+2 -1
View File
@@ -21,6 +21,7 @@ public:
virtual void setScrollCallback(std::function<void(double, double)> callback) = 0;
virtual void setFileCallback(std::function<void(int, const char**)> callback) = 0;
virtual void setCloseCallback(std::function<void()> callback) = 0;
virtual void setResizeCallback(std::function<void(uint32, uint32)> callback) = 0;
constexpr SeFormat getSwapchainFormat() const
{
return framebufferFormat;
@@ -46,7 +47,7 @@ protected:
};
DEFINE_REF(Window)
class Viewport
class Viewport
{
public:
Viewport(PWindow owner, const ViewportCreateInfo& createInfo);