-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28730 from jeongseok-meta/vulkanscenegraph
Add VulkanSceneGraph and vsgXchange
- Loading branch information
Showing
11 changed files
with
316 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@echo on | ||
|
||
cmake %SRC_DIR% ^ | ||
%CMAKE_ARGS% ^ | ||
-B build ^ | ||
-DBUILD_SHARED_LIBS=ON | ||
|
||
cmake --build build --parallel --config Release | ||
if errorlevel 1 exit 1 | ||
|
||
cmake --install build --config Release | ||
if errorlevel 1 exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
set -exo pipefail | ||
|
||
cmake $SRC_DIR \ | ||
${CMAKE_ARGS} \ | ||
-G Ninja \ | ||
-B build \ | ||
-DBUILD_SHARED_LIBS=ON \ | ||
-DCMAKE_BUILD_TYPE=Release | ||
|
||
cmake --build build --parallel | ||
|
||
cmake --install build --strip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{% set name = "VulkanSceneGraph" %} | ||
{% set version = "1.1.8" %} | ||
|
||
package: | ||
name: {{ name|lower }} | ||
version: {{ version }} | ||
|
||
source: | ||
- url: /~https://github.com/vsg-dev/VulkanSceneGraph/archive/v{{ version }}.tar.gz | ||
sha256: 94a3cebdfddf4759d17bbf0cc9f3278851eb899bdc660eb4681960e4cdd2ad6a | ||
patches: | ||
- patches/ignore-vulkan-version.patch | ||
|
||
build: | ||
number: 0 | ||
run_exports: | ||
- {{ pin_subpackage('vulkanscenegraph', max_pin='x.x') }} | ||
|
||
requirements: | ||
build: | ||
- {{ compiler('cxx') }} | ||
- {{ stdlib('c') }} | ||
- cmake | ||
- ninja # [not win] | ||
- pkgconfig # [linux] | ||
host: | ||
- glslang | ||
- libvulkan-headers | ||
- libvulkan-loader | ||
- libxcb # [linux] | ||
- xorg-xproto # [linux] | ||
run: | ||
- libvulkan-headers | ||
- libvulkan-loader | ||
- libxcb # [linux] | ||
- xorg-xproto # [linux] | ||
|
||
test: | ||
commands: | ||
- test -f $PREFIX/include/vsg/all.h # [not win] | ||
- test -f $PREFIX/lib/libvsg${SHLIB_EXT} # [not win] | ||
- test -f $PREFIX/lib/cmake/vsg/vsgConfig.cmake # [not win] | ||
- if not exist %PREFIX%\\Library\\include\\vsg\\all.h exit 1 # [win] | ||
- if not exist %PREFIX%\\Library\\lib\\vsg.lib exit 1 # [win] | ||
- if not exist %PREFIX%\\Library\\bin\\vsg-14.dll exit 1 # [win] | ||
- if not exist %PREFIX%\\Library\\lib\\cmake\\vsg\\vsgConfig.cmake exit 1 # [win] | ||
downstreams: | ||
- vsgxchange | ||
|
||
about: | ||
home: https://vsg-dev.github.io/vsg-dev.io/ | ||
summary: Vulkan & C++17 based Scene Graph Project | ||
description: | | ||
VulkanSceneGraph (VSG), is a modern, cross platform, high performance scene | ||
graph library built upon Vulkan graphics/compute API. The software is | ||
written in C++17, and follows the CppCoreGuidelines and FOSS Best Practices. | ||
license: MIT | ||
license_file: LICENSE.md | ||
dev_url: /~https://github.com/vsg-dev/VulkanSceneGraph | ||
|
||
extra: | ||
recipe-maintainers: | ||
- jeongseok-meta |
13 changes: 13 additions & 0 deletions
13
recipes/VulkanSceneGraph/patches/ignore-vulkan-version.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index a75f15d8..6a7a0c91 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -7,7 +7,7 @@ project(vsg | ||
) | ||
set(VSG_SOVERSION 14) | ||
SET(VSG_RELEASE_CANDIDATE 0) | ||
-set(Vulkan_MIN_VERSION 1.1.70.0) | ||
+set(Vulkan_MIN_VERSION ) | ||
|
||
set(VSG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "Root source directory of VulkanSceneGraph.") | ||
set(VSG_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE INTERNAL "Root binary directory of VulkanSceneGraph.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@echo on | ||
|
||
cmake %SRC_DIR% ^ | ||
%CMAKE_ARGS% ^ | ||
-B build ^ | ||
-DBUILD_SHARED_LIBS=ON | ||
|
||
cmake --build build --parallel --config Release | ||
if errorlevel 1 exit 1 | ||
|
||
cmake --install build --config Release | ||
if errorlevel 1 exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
set -exo pipefail | ||
|
||
cmake $SRC_DIR \ | ||
${CMAKE_ARGS} \ | ||
-G Ninja \ | ||
-B build \ | ||
-DBUILD_SHARED_LIBS=ON \ | ||
-DCMAKE_BUILD_TYPE=Release | ||
|
||
cmake --build build --parallel | ||
|
||
cmake --install build --strip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{% set name = "vsgXchange" %} | ||
{% set version = "1.1.4" %} | ||
|
||
package: | ||
name: {{ name|lower }} | ||
version: {{ version }} | ||
|
||
source: | ||
- url: /~https://github.com/vsg-dev/vsgXchange/archive/v{{ version }}.tar.gz | ||
sha256: 0b79369ddcb3676b6998a6660fcf938314ae34eea9fbababf8471e0b94502597 | ||
|
||
build: | ||
number: 0 | ||
run_exports: | ||
- {{ pin_subpackage('vsgxchange', max_pin='x.x') }} | ||
|
||
requirements: | ||
build: | ||
- {{ compiler('cxx') }} | ||
- {{ stdlib('c') }} | ||
- cmake | ||
- ninja # [not win] | ||
- pkgconfig # [linux] | ||
host: | ||
- freetype | ||
- libcurl | ||
- libvulkan-headers | ||
- libvulkan-loader | ||
- vulkanscenegraph | ||
run: | ||
- libvulkan-loader | ||
- vulkanscenegraph | ||
|
||
test: | ||
commands: | ||
- test -f $PREFIX/include/vsgXchange/all.h # [not win] | ||
- test -f $PREFIX/lib/libvsgXchange${SHLIB_EXT} # [not win] | ||
- test -f $PREFIX/lib/cmake/vsgXchange/vsgXchangeConfig.cmake # [not win] | ||
- if not exist %PREFIX%\\Library\\include\\vsgXchange\\all.h exit 1 # [win] | ||
- if not exist %PREFIX%\\Library\\lib\\vsgXchange.lib exit 1 # [win] | ||
- if not exist %PREFIX%\\Library\\bin\\vsgXchange.dll exit 1 # [win] | ||
- if not exist %PREFIX%\\Library\\bin\\vsgconv.exe exit 1 # [win] | ||
- if not exist %PREFIX%\\Library\\lib\\cmake\\vsgXchange\\vsgXchangeConfig.cmake exit 1 # [win] | ||
requires: | ||
- {{ compiler("c") }} | ||
- {{ compiler("cxx") }} | ||
- cmake | ||
- ninja # [not win] | ||
- pkgconfig # [linux] | ||
files: | ||
- tests/ | ||
|
||
about: | ||
home: https://vsg-dev.github.io/vsg-dev.io/ | ||
summary: Utility library for converting data+materials to/from VulkanSceneGraph | ||
license: MIT | ||
license_file: LICENSE.md | ||
dev_url: /~https://github.com/vsg-dev/vsgXchange | ||
|
||
extra: | ||
recipe-maintainers: | ||
- jeongseok-meta |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@echo on | ||
|
||
cmake tests ^ | ||
%CMAKE_ARGS% ^ | ||
-B tests/build ^ | ||
-DBUILD_SHARED_LIBS=ON | ||
if errorlevel 1 exit 1 | ||
|
||
cmake --build tests/build --parallel --config Release | ||
if errorlevel 1 exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
set -exo pipefail | ||
|
||
cmake tests \ | ||
${CMAKE_ARGS} \ | ||
-G Ninja \ | ||
-B tests/build \ | ||
-DBUILD_SHARED_LIBS=ON \ | ||
-DCMAKE_BUILD_TYPE=Release | ||
|
||
cmake --build tests/build --parallel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
cmake_minimum_required(VERSION 3.7) | ||
|
||
project(vsghelloworld) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
|
||
find_package(vsg CONFIG REQUIRED) | ||
find_package(vsgXchange CONFIG REQUIRED) | ||
|
||
add_executable(vsghelloworld main.cpp) | ||
target_link_libraries(vsghelloworld PRIVATE vsg::vsg vsgXchange::vsgXchange) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#include <vsg/all.h> | ||
#include <vsgXchange/all.h> | ||
|
||
#include <iostream> | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
// set up defaults and read command line arguments to override them | ||
vsg::CommandLine arguments(&argc, argv); | ||
|
||
// set up vsg::Options to pass in filepaths, ReaderWriters and other IO related options to use when reading and writing files. | ||
auto options = vsg::Options::create(vsgXchange::all::create()); | ||
options->fileCache = vsg::getEnv("VSG_FILE_CACHE"); | ||
options->paths = vsg::getEnvPaths("VSG_FILE_PATH"); | ||
arguments.read(options); | ||
|
||
vsg::Path filename = "models/openstreetmap.vsgt"; | ||
if (argc > 1) filename = arguments[1]; | ||
|
||
if (arguments.errors()) return arguments.writeErrorMessages(std::cerr); | ||
|
||
// load the scene graph | ||
vsg::ref_ptr<vsg::Node> vsg_scene = vsg::read_cast<vsg::Node>(filename, options); | ||
if (!vsg_scene) return 0; | ||
|
||
// create the viewer and assign window(s) to it | ||
auto windowTraits = vsg::WindowTraits::create(); | ||
windowTraits->windowTitle = "Hello World"; | ||
auto viewer = vsg::Viewer::create(); | ||
auto window = vsg::Window::create(windowTraits); | ||
if (!window) | ||
{ | ||
std::cout << "Could not create window." << std::endl; | ||
return 1; | ||
} | ||
|
||
viewer->addWindow(window); | ||
|
||
// compute the bounds of the scene graph to help position camera | ||
vsg::ComputeBounds computeBounds; | ||
vsg_scene->accept(computeBounds); | ||
vsg::dvec3 centre = (computeBounds.bounds.min + computeBounds.bounds.max) * 0.5; | ||
double radius = vsg::length(computeBounds.bounds.max - computeBounds.bounds.min) * 0.6; | ||
double nearFarRatio = 0.001; | ||
|
||
// set up the camera | ||
auto lookAt = vsg::LookAt::create(centre + vsg::dvec3(0.0, -radius * 3.5, 0.0), centre, vsg::dvec3(0.0, 0.0, 1.0)); | ||
|
||
vsg::ref_ptr<vsg::ProjectionMatrix> perspective; | ||
auto ellipsoidModel = vsg_scene->getRefObject<vsg::EllipsoidModel>("EllipsoidModel"); | ||
if (ellipsoidModel) | ||
{ | ||
double horizonMountainHeight = 0.0; | ||
perspective = vsg::EllipsoidPerspective::create(lookAt, ellipsoidModel, 30.0, static_cast<double>(window->extent2D().width) / static_cast<double>(window->extent2D().height), nearFarRatio, horizonMountainHeight); | ||
} | ||
else | ||
{ | ||
perspective = vsg::Perspective::create(30.0, static_cast<double>(window->extent2D().width) / static_cast<double>(window->extent2D().height), nearFarRatio * radius, radius * 4.5); | ||
} | ||
|
||
auto camera = vsg::Camera::create(perspective, lookAt, vsg::ViewportState::create(window->extent2D())); | ||
|
||
// add close handler to respond to the close window button and pressing escape | ||
viewer->addEventHandler(vsg::CloseHandler::create(viewer)); | ||
|
||
// add trackball to control the Camera | ||
viewer->addEventHandler(vsg::Trackball::create(camera, ellipsoidModel)); | ||
|
||
// add the CommandGraph to render the scene | ||
auto commandGraph = vsg::createCommandGraphForView(window, camera, vsg_scene); | ||
viewer->assignRecordAndSubmitTaskAndPresentation({commandGraph}); | ||
|
||
// compile all Vulkan objects and transfer image, vertex and primitive data to GPU | ||
viewer->compile(); | ||
|
||
// rendering main loop | ||
while (viewer->advanceToNextFrame()) | ||
{ | ||
// pass any events into EventHandlers assigned to the Viewer | ||
viewer->handleEvents(); | ||
|
||
viewer->update(); | ||
|
||
viewer->recordAndSubmit(); | ||
|
||
viewer->present(); | ||
} | ||
|
||
// clean up done automatically thanks to ref_ptr<> | ||
return 0; | ||
} |