diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b56f79..1380cd9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,8 +22,9 @@ find_package(vsg 1.0.0) vsg_setup_dir_vars() vsg_setup_build_vars() - find_package(vsgXchange) # only used by exanples + +# if Qt5 then we need 5.10 or later find_package(${QT_PACKAGE_NAME} COMPONENTS Widgets REQUIRED) vsg_add_target_clang_format( @@ -60,14 +61,8 @@ set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) if(WIN32) - add_definitions(-DVK_USE_PLATFORM_WIN32_KHR -DNOMINMAX) + add_definitions(-DNOMINMAX) set(MODE WIN32) -elseif(APPLE) - add_definitions(-DVK_USE_PLATFORM_MACOS_MVK) -elseif(UNIX) - add_definitions(-DVK_USE_PLATFORM_XCB_KHR) -else() - add_definitions(-DVK_USE_PLATFORM_XLIB_KHR) endif() add_subdirectory(src/vsgQt) diff --git a/README.md b/README.md index 9b654ef..466ae2a 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Qt, and hence vsgQt, is suited for interactive, event driven applications. For r * [VulkanSDK](https://www.lunarg.com/vulkan-sdk/) version 1.2.162 or later * [VulkanSceneGraph](https://github.com/vsg-dev/VulkanSceneGraph) master recommended. * [CMake](https://cmake.org/) version 3.7 or later -* [Qt](https://www.qt.io/) version 5 or later +* [Qt](https://www.qt.io/) version 5.10 or later * C++17 capable compiler ## Building vsgQt diff --git a/src/vsgQt/ViewerWindow.cpp b/src/vsgQt/ViewerWindow.cpp index 1c05716..1d0c734 100644 --- a/src/vsgQt/ViewerWindow.cpp +++ b/src/vsgQt/ViewerWindow.cpp @@ -16,33 +16,29 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #include #include #include +#include #include -#include - #include - -#if QT_HAS_VULKAN_SUPPORT -# include -#endif +#include #include - using namespace vsgQt; const char* instanceExtensionSurfaceName() { -#if defined(VK_USE_PLATFORM_WIN32_KHR) - return VK_KHR_WIN32_SURFACE_EXTENSION_NAME; -#elif defined(VK_USE_PLATFORM_XLIB_KHR) - return VK_KHR_XLIB_SURFACE_EXTENSION_NAME; -#elif defined(VK_USE_PLATFORM_XCB_KHR) - return VK_KHR_XCB_SURFACE_EXTENSION_NAME; -#elif defined(VK_USE_PLATFORM_MACOS_MVK) - return VK_MVK_MACOS_SURFACE_EXTENSION_NAME; -#endif + auto platformName = qGuiApp->platformName(); + std::cout<<"qGuiApp->platformName() "<getSurface()->release(); - } - else -#endif - { - windowAdapter->releaseWindow(); - } + windowAdapter->getSurface()->release(); } windowAdapter = {}; @@ -137,33 +124,20 @@ bool ViewerWindow::event(QEvent* e) void ViewerWindow::intializeUsingAdapterWindow(uint32_t width, uint32_t height) { -#if QT_HAS_VULKAN_SUPPORT _initialized = true; traits->width = width; traits->height = height; traits->fullscreen = false; - // create instance - vsg::Names instanceExtensions; - vsg::Names requestedLayers; + traits->validate(); + + vsg::Names& instanceExtensions = traits->instanceExtensionNames; - instanceExtensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); instanceExtensions.push_back("VK_KHR_surface"); instanceExtensions.push_back(instanceExtensionSurfaceName()); - if (traits->debugLayer || traits->apiDumpLayer) - { - instanceExtensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); - requestedLayers.push_back("VK_LAYER_KHRONOS_validation"); - if (traits->apiDumpLayer) - requestedLayers.push_back("VK_LAYER_LUNARG_api_dump"); - } - - vsg::Names validatedNames = - vsg::validateInstancelayerNames(requestedLayers); - - instance = vsg::Instance::create(instanceExtensions, validatedNames); + instance = vsg::Instance::create(instanceExtensions, traits->requestedLayers, traits->vulkanVersion); // create Qt wrapper of vkInstance auto vulkanInstance = new QVulkanInstance; @@ -184,51 +158,16 @@ void ViewerWindow::intializeUsingAdapterWindow(uint32_t width, uint32_t height) { delete vulkanInstance; } -#else - vsg::info("ViewerWindow::intializeUsingAdapterWindow(", width, ", ", height, ") not supported, requires Qt 5.10 or later."); -#endif -} - -void ViewerWindow::intializeUsingVSGWindow(uint32_t width, uint32_t height) -{ - _initialized = true; - -#if defined(VK_USE_PLATFORM_WIN32_KHR) - traits->nativeWindow = reinterpret_cast(winId()); -#elif defined(VK_USE_PLATFORM_XLIB_KHR) - traits->nativeWindow = static_cast<::Window>(winId()); -#elif defined(VK_USE_PLATFORM_XCB_KHR) - traits->nativeWindow = static_cast(winId()); -#elif defined(VK_USE_PLATFORM_MACOS_MVK) - traits->nativeWindow = reinterpret_cast(winId()); // or NSWindow* ? -#endif - - traits->width = width; - traits->height = height; - - windowAdapter = vsg::Window::create(traits); } void ViewerWindow::exposeEvent(QExposeEvent* /*e*/) { if (!_initialized && isExposed()) { -#if QT_HAS_VULKAN_SUPPORT - if (surfaceType() == QSurface::VulkanSurface) - { - vsg::info("Using QSurface"); - intializeUsingAdapterWindow(convert_coord(width()), convert_coord(height())); - } - else -#endif - { - vsg::info("Using vsg::Surface"); - intializeUsingVSGWindow(convert_coord(width()), convert_coord(height())); - } + intializeUsingAdapterWindow(convert_coord(width()), convert_coord(height())); if (initializeCallback) initializeCallback(*this, convert_coord(width()), convert_coord(height())); - requestUpdate(); }