Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find package for vsg projects #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 38 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,33 +34,48 @@ if (VULKAN_SDK)
endif()

set(VSG_MIN_VERSION 1.1.0)

FetchContent_Declare(vsg
GIT_REPOSITORY https://github.com/vsg-dev/VulkanSceneGraph.git
GIT_TAG master
GIT_PROGRESS TRUE
FIND_PACKAGE_ARGS ${VSG_MIN_VERSION}
)

FetchContent_MakeAvailable(vsg)
# find_package(vsg) includes vsgMacros
if (vsg_SOURCE_DIR)
SET(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${vsg_SOURCE_DIR}/cmake")
include("vsgMacros")
find_package(vsg ${VSG_MIN_VERSION})
if (NOT vsg_FOUND)
FetchContent_Declare(vsg
GIT_REPOSITORY https://github.com/vsg-dev/VulkanSceneGraph.git
GIT_TAG master
GIT_PROGRESS TRUE
FIND_PACKAGE_ARGS ${VSG_MIN_VERSION}
)

FetchContent_MakeAvailable(vsg)
# find_package(vsg) includes vsgMacros
if (vsg_SOURCE_DIR)
SET(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${vsg_SOURCE_DIR}/cmake")
include("vsgMacros")
endif()
endif()

#find_package(vsgXchange)
set(VSGXCHANGE_MIN_VERSION 1.0.5)
find_package(vsgXchange ${VSGXCHANGE_MIN_VERSION})
if (NOT vsgXchange_FOUND)
FetchContent_Declare(vsgXchange
GIT_REPOSITORY https://github.com/vsg-dev/vsgXchange.git
GIT_TAG master
GIT_PROGRESS TRUE
FIND_PACKAGE_ARGS ${VSGXCHANGE_MIN_VERSION}
)

FetchContent_MakeAvailable(vsgXchange)
endif()

set(VSGIMGUI_MIN_VERSION 0.1.0)

FetchContent_Declare(vsgImGui
GIT_REPOSITORY https://github.com/vsg-dev/vsgImGui.git
GIT_TAG v0.1.0
GIT_PROGRESS TRUE
FIND_PACKAGE_ARGS ${VSGIMGUI_MIN_VERSION}
)

FetchContent_MakeAvailable(vsgImGui)
find_package(vsgImGui ${VSGIMGUI_MIN_VERSION})
if (NOT vsgImGui_FOUND)
FetchContent_Declare(vsgImGui
GIT_REPOSITORY https://github.com/vsg-dev/vsgImGui.git
GIT_TAG v0.1.0
GIT_PROGRESS TRUE
FIND_PACKAGE_ARGS ${VSGIMGUI_MIN_VERSION}
)

FetchContent_MakeAvailable(vsgImGui)
endif()

# Wrangle Cesium's dependencies into shape i.e., install them!
option(GSL_INSTALL "Generate and install GSL target" ON)
Expand Down
20 changes: 17 additions & 3 deletions src/applications/worldviewer/worldviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ int main(int argc, char** argv)
}
}
bool useHeadlight = arguments.read({"--headlight"});
auto shadowMaps = arguments.value(0, "--shadow-maps");
auto shadowMaps = arguments.value<uint32_t>(0, "--shadow-maps");
auto maxShadowDistance = arguments.value<double>(10000.0, "--sd");

if (arguments.errors())
{
return arguments.writeErrorMessages(std::cerr);
Expand Down Expand Up @@ -261,6 +263,7 @@ int main(int argc, char** argv)
commandGraph->addChild(renderGraph);

auto view = vsg::View::create(camera);
view->viewDependentState->maxShadowDistance = maxShadowDistance;
if (useHeadlight)
{
view->addChild(vsg::createHeadlight());
Expand All @@ -270,14 +273,25 @@ int main(int argc, char** argv)
// Attach the ImGui graphical interface
renderGraph->addChild(ui->getImGui());
viewer->assignRecordAndSubmitTaskAndPresentation({commandGraph});
// Compile everything we can at this point.
viewer->compile();

// Perform any late initialization of TilesetNode objects. Most importantly, this tracks VSG
// cameras so that they can be used by cesium-native to determine visible tiles.
worldNode->initialize(viewer);

// Compile everything we can at this point.
//
// best practice is to tell the viewer what resources to allocate in the viewer.compile() call via ResourceHints
//
// auto resourceHints = vsg::ResourceHints::create();
// resourceHints->numShadowMapsRange = {shadowMaps, 64};
// resourceHints->maxSlot = 4;
// viewer->compile(resourceHints);
viewer->compile();

auto lastAct = gsl::finally([worldNode]() {
vsgCs::shutdown();
worldNode->shutdown();});

// rendering main loop
while (viewer->advanceToNextFrame() && (numFrames < 0 || (numFrames--) > 0))
{
Expand Down
2 changes: 0 additions & 2 deletions src/vsgCs/WorldNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ bool WorldNode::initialize(const vsg::ref_ptr<vsg::Viewer>& viewer)
genv->overlayPipelineLayout, pbr::WORLD_DESCRIPTOR_SET,
descriptorBuilder->descriptorSets[pbr::WORLD_DESCRIPTOR_SET]);
stateGroup->add(bindDescriptorSet);
// Overkill; better to just compile the stateGroup
viewer->compile();
return result;
}

Expand Down