Skip to content

Commit

Permalink
Add all files
Browse files Browse the repository at this point in the history
  • Loading branch information
nolankramer committed Nov 3, 2024
0 parents commit 4469447
Show file tree
Hide file tree
Showing 22 changed files with 1,879 additions and 0 deletions.
111 changes: 111 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: InlineOnly
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true
BreakConstructorInitializers: AfterColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 0
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
IndentPPDirectives: AfterHash
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
ReflowComments: false
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 8
UseTab: Never
...

80 changes: 80 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@

cmake_uninstall.cmake

lib/
bin/

# Autogenerated files
*.pc
*.conf
*.backup
CMakeCache.txt
CMakeFiles
CMakeScripts
Makefile
cmake_install.cmake
install_manifest.txt
CMakeDoxyfile.in
CMakeDoxygenDefaults.cmake
Doxyfile.docs
vsgQtConfig.cmake
vsgQtConfigVersion.cmake
*_autogen/
*vsgQtConfig.cmake.in
include/vsgQt6/Export.h
Doxyfile.docs-vsgQt6

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

# Visual Studio files
*.sln
*.vcxproj
*.vcxproj.filters
*.vcxproj.user
.vs/
x64/
src/vsgGIS/vsgGIS.dir/
*.pdb
*.tlog
*.log

# Xcode
DerivedData/
*.build
*.xcodeproj

# Gradle
.gradle/
.idea/
.externalNativeBuild/
*.iml
build/
local.properties

76 changes: 76 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
cmake_minimum_required(VERSION 3.7)

project(vsgQt6
VERSION 0.0.1
DESCRIPTION "Qt6 integration with VulkanSceneGraph"
LANGUAGES CXX
)
set(VSGQT6_SOVERSION 3)
set(VSGQT6_RELEASE_CANDIDATE 0)

set( "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "Root source directory of vsgQt6")
set(VSGQT6_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE INTERNAL "Root binary directory of vsgQt6")

# set the use of C++17 globally as all examples require it
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(QT_PACKAGE_NAME Qt6 CACHE STRING "Set Qt package name, i.e. Qt5 or Qt6.")

# Cmake includes
include(cmake/CPM.cmake)

add_subdirectory(ext)

find_package(vsg 1.1.2)

vsg_setup_dir_vars()
vsg_setup_build_vars()

find_package(vsgXchange) # only used by examples

# if Qt5 then we need 5.10 or later
find_package(${QT_PACKAGE_NAME} COMPONENTS Widgets REQUIRED)

vsg_add_target_clang_format(
FILES
include/*/*.h
src/*/*.cpp
)
vsg_add_target_clobber()
vsg_add_target_cppcheck(
FILES
include/*/*.h
src/*/*.cpp
)
vsg_add_target_docs(
FILES
src
include/*/*.h
src/*/*.cpp
)
vsg_add_target_uninstall()

# only provide custom targets if not building as a submodule/FetchContent
if (${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR})

vsg_add_option_maintainer(
PREFIX v
RCLEVEL ${VSGQT6_RELEASE_CANDIDATE}
)

endif()

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

if(WIN32)
add_definitions(-DNOMINMAX)
set(MODE WIN32)
endif()

add_subdirectory(src/vsgQt6)
add_subdirectory(examples)

vsg_add_feature_summary()
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Nolan Kramer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# vsgQt6
Open Source ([MIT Licensed](LICENSE.md)), cross platform C++ library providing integration of VulkanSceneGraph with Qt windowing. Supports Windows, Linux and macOS.

vsgQt6 provides full Vulkan support through the VulkanSceneGraph's built in VkSurface support rather than the limited Vulkan support that Qt-5.10 or later provide. Using the VulkanSceneGraph for providing Vulkan support avoids the restriction that Qt's VulkanWindow has with not being able to share VkDevice between windows, and provides compatibility with Qt versions prior to it adding Vulkan support. Sharing vsg::Device/VkDevice between widgets is crucial for providing multiple 3D viewport widgets without blowing up GPU memory usage.

vsgQt6 provides native Qt integration through the use of a QQuickWidget or QQuickWindow. It does this in the follow manner:
1. Set the QQuickWindow graphics API to Vulkan with `QQuickWindow::setGraphicsApi`
2. Create a Qt graphics device **from our vkDevice** with `QQuickGraphicsDevice::fromDeviceObjects`
3. Set the QQuickWindow graphics device with the above created graphics device
4. Subclass `QQuickWidget` and have it create a `QSGTexture` that in-turn delivers a `QRhiTexture`. The underlying texture buffer can be accessed with `QRhiTexture::nativeTexture()`
5. VSG renders into the above buffer
6. The `QQuickWidget` renders a scene with a single `QSGSimpleTextureNode`, which ultimately renders the `QSGTexture` that is "shared" with VSG
7. There are various events that can be used to integrate the render loop, such as `QQuickItem::updatePaintNode` or `QQuickWindow::beforeRendering`

## Checking out vsgQt6

~~~ sh
git clone https://github.com/vsg-dev/vsgQt6.git
~~~

## Dependencies:

* [VulkanSDK](https://www.lunarg.com/vulkan-sdk/) version 1.1.70 or later
* [VulkanSceneGraph](https://github.com/vsg-dev/VulkanSceneGraph) master, 1.0.8 or later.
* [CMake](https://cmake.org/) version 3.7 or later
* [Qt](https://www.qt.io/) version 5 or later
* C++17 capable compiler

## Building vsgQt6

~~~ sh
cd vsgQt6
cmake .
make -j 8
~~~

## Examples

* [vsgqtviewer](examples/vsgqtviewer/main.cpp) - example of single QApplication/QMainWindow usage with single vsgQt6::Viewer.
* [vsgqtmultiviewer](examples/vsgqtmultiviewer/main.cpp) - example of QWindow usage with multiple vsgQt6::Viewer in the same QWindow.
* [vsgqtwindows](examples/vsgqtwindows/main.cpp) - example of multiple vsgQt6::Viewer per QWindow.
24 changes: 24 additions & 0 deletions cmake/CPM.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SPDX-License-Identifier: MIT
#
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors

set(CPM_DOWNLOAD_VERSION 0.38.7)
set(CPM_HASH_SUM "83e5eb71b2bbb8b1f2ad38f1950287a057624e385c238f6087f94cdfc44af9c5")

if(CPM_SOURCE_CACHE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif()

# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)

file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
)

include(${CPM_DOWNLOAD_LOCATION})
3 changes: 3 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_subdirectory(vsgqtmultiviewer)
add_subdirectory(vsgqtviewer)
add_subdirectory(vsgqtwindows)
19 changes: 19 additions & 0 deletions examples/vsgqtmultiviewer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
set(SOURCES
main.cpp
)

set(HEADERS
)

add_executable(vsgqtmultiviewer ${MODE} ${SOURCES} ${HEADERS} ${FORMS})

target_link_libraries(vsgqtmultiviewer vsgQt6)

if (vsgXchange_FOUND)
target_compile_definitions(vsgqtmultiviewer PRIVATE vsgXchange_FOUND)
target_link_libraries(vsgqtmultiviewer vsgXchange::vsgXchange)
endif()


install(TARGETS vsgqtmultiviewer DESTINATION bin)

Loading

0 comments on commit 4469447

Please sign in to comment.