MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / SampleApp

Method SampleApp

Source/Falcor/Core/SampleApp.cpp:52–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50namespace Falcor
51{
52SampleApp::SampleApp(const SampleAppConfig& config)
53{
54 logInfo("Falcor {}", getLongVersionString());
55
56 OSServices::start();
57 Threading::start();
58
59 mShowUI = config.showUI;
60 mVsyncOn = config.windowDesc.enableVSync;
61 mClock.setTimeScale(config.timeScale);
62 if (config.pauseTime)
63 mClock.pause();
64
65 // Create GPU device
66 mpDevice = make_ref<Device>(config.deviceDesc);
67
68 if (!config.headless)
69 {
70 auto windowDesc = config.windowDesc;
71 // Vulkan does not allow creating a swapchain on a minimized window.
72 if (config.deviceDesc.type == Device::Type::Vulkan && windowDesc.mode == Window::WindowMode::Minimized)
73 windowDesc.mode = Window::WindowMode::Normal;
74
75 // Create the window
76 mpWindow = Window::create(windowDesc, this);
77 mpWindow->setWindowIcon(getRuntimeDirectory() / "data/framework/nvidia.ico");
78
79 // Create swapchain
80 Swapchain::Desc desc;
81 desc.format = config.colorFormat;
82 desc.width = mpWindow->getClientAreaSize().x;
83 desc.height = mpWindow->getClientAreaSize().y;
84 desc.imageCount = 3;
85 desc.enableVSync = mVsyncOn;
86 mpSwapchain = make_ref<Swapchain>(mpDevice, desc, mpWindow->getApiHandle());
87
88 // Show the progress bar (unless window is minimized)
89 if (windowDesc.mode != Window::WindowMode::Minimized)
90 mProgressBar.show("Initializing Falcor");
91
92 // When not running headless, we want to show message boxes on error by default.
93 setErrorDiagnosticFlags(getErrorDiagnosticFlags() | ErrorDiagnosticFlags::ShowMessageBoxOnError);
94 }
95
96 // Create target frame buffer
97 uint2 fboSize = mpWindow ? mpWindow->getClientAreaSize() : uint2(config.windowDesc.width, config.windowDesc.height);
98 mpTargetFBO = Fbo::create2D(mpDevice, fboSize.x, fboSize.y, config.colorFormat, config.depthFormat);
99
100 // Setup asset search paths.
101 AssetResolver& resolver = AssetResolver::getDefaultResolver();
102 resolver.addSearchPath(getProjectDirectory() / "media");
103 for (auto& path : Settings::getGlobalSettings().getSearchDirectories("media"))
104 resolver.addSearchPath(path);
105
106 mpDevice->getProgramManager()->setGenerateDebugInfoEnabled(config.generateShaderDebugInfo);
107 if (config.shaderPreciseFloat)
108 {
109 mpDevice->getProgramManager()->setForcedCompilerFlags(

Callers

nothing calls this directly

Calls 12

logInfoFunction · 0.85
setErrorDiagnosticFlagsFunction · 0.85
getErrorDiagnosticFlagsFunction · 0.85
setWindowIconMethod · 0.80
addSearchPathMethod · 0.80
loadAllPluginsMethod · 0.80
createFunction · 0.50
pauseMethod · 0.45
showMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected