You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
2.3 KiB
72 lines
2.3 KiB
#include "VulkanWindow.h"
|
|
// #include <vulkan/vulkan_android.h>
|
|
|
|
VulkanWindow::VulkanWindow()
|
|
{
|
|
setSurfaceType(QWindow::VulkanSurface);
|
|
}
|
|
|
|
VulkanWindow::~VulkanWindow() {
|
|
// cleanup();
|
|
}
|
|
|
|
void VulkanWindow::createVulkanSurface(VkInstance instance, VkSurfaceKHR& surface) {
|
|
|
|
QVulkanInstance* vkInstance = new QVulkanInstance();
|
|
vkInstance->setVkInstance(instance);
|
|
vkInstance->create();
|
|
setVulkanInstance(vkInstance);
|
|
VkSurfaceKHR newSurface = QVulkanInstance::surfaceForWindow(this);
|
|
|
|
surface = newSurface;
|
|
qDebug() << "######" << surface << "######";
|
|
qDebug() << "######" << newSurface << "######";
|
|
if (!surface) {
|
|
qDebug() << "############## Failed to retrieve surface using Qt. ##############";
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
|
|
// #if defined(Q_OS_ANDROID)
|
|
// VkAndroidSurfaceCreateInfoKHR surfaceCreateInfo = {};
|
|
// surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR;
|
|
// surfaceCreateInfo.pNext = nullptr;
|
|
// surfaceCreateInfo.flags = 0;
|
|
|
|
// ANativeWindow* nativeWindow = reinterpret_cast<ANativeWindow*>(winId());
|
|
|
|
// if (!nativeWindow) {
|
|
// qCritical() << "Failed to retrieve ANativeWindow using JNI.";
|
|
// exit(EXIT_FAILURE);
|
|
// }
|
|
|
|
// surfaceCreateInfo.window = nativeWindow;
|
|
|
|
// if (vkCreateAndroidSurfaceKHR(instance, &surfaceCreateInfo, nullptr, &surface) != VK_SUCCESS) {
|
|
// qCritical() << "Failed to create Vulkan surface on Android.";
|
|
// exit(EXIT_FAILURE);
|
|
// }
|
|
// #elif defined(Q_OS_LINUX)
|
|
|
|
// VkXcbSurfaceCreateInfoKHR surfaceCreateInfo = {};
|
|
// surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
|
|
// surfaceCreateInfo.connection = QX11Info::connection();
|
|
// surfaceCreateInfo.window = static_cast<unsigned int>(winId());
|
|
|
|
// if (vkCreateXcbSurfaceKHR(instance, &surfaceCreateInfo, nullptr, &surface) != VK_SUCCESS) {
|
|
// qCritical() << "Failed to create Vulkan surface on Linux.";
|
|
// exit(EXIT_FAILURE);
|
|
// }
|
|
// #endif
|
|
qDebug() << "Vulkan surface created successfully.";
|
|
}
|
|
|
|
void VulkanWindow::getWindowSize(int &width, int &height)
|
|
{
|
|
width = this->width();
|
|
height = this->height();
|
|
}
|
|
|
|
void VulkanWindow::cleanup() {
|
|
|
|
}
|
|
|