diff options
| author | Anders Leino <aleino@nvidia.com> | 2024-12-18 14:39:17 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-18 12:39:17 +0000 |
| commit | 41c627fd420a644f0ae86e36f4752e820e2d683c (patch) | |
| tree | 03c7f119271eec616cf192b573b2487d5b1c2df3 /examples/platform-test/main.cpp | |
| parent | 45af2467289bd39baff0269bb7de8a538f617dec (diff) | |
Add slang example tests to CI (#5879)
* Examples: Don't proceed if 'initializeBase' fails
* Examples: Only access gWindow if it's been initialized
* Examples: Free memory from CommandLineToArgvW
* Add example run step to CI
Lots of examples are still unexpectedly failing, but is one small step towards addressing
issue #5520.
Diffstat (limited to 'examples/platform-test/main.cpp')
| -rw-r--r-- | examples/platform-test/main.cpp | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/examples/platform-test/main.cpp b/examples/platform-test/main.cpp index 373c15e09..159e26c55 100644 --- a/examples/platform-test/main.cpp +++ b/examples/platform-test/main.cpp @@ -71,18 +71,26 @@ struct PlatformTest : public WindowedAppBase Slang::Result initialize() { - initializeBase("platform-test", 1024, 768); - - gWindow->events.sizeChanged = [this]() { onSizeChanged(); }; - gWindow->events.focus = [this]() { onFocus(); }; - gWindow->events.lostFocus = [this]() { onLostFocus(); }; - gWindow->events.keyDown = [this](const platform::KeyEventArgs& e) { onKeyDown(e); }; - gWindow->events.keyUp = [this](const platform::KeyEventArgs& e) { onKeyUp(e); }; - gWindow->events.keyPress = [this](const platform::KeyEventArgs& e) { onKeyPress(e); }; - gWindow->events.mouseMove = [this](const platform::MouseEventArgs& e) { onMouseMove(e); }; - gWindow->events.mouseDown = [this](const platform::MouseEventArgs& e) { onMouseDown(e); }; - gWindow->events.mouseUp = [this](const platform::MouseEventArgs& e) { onMouseUp(e); }; - gWindow->events.mouseWheel = [this](const platform::MouseEventArgs& e) { onMouseWheel(e); }; + SLANG_RETURN_ON_FAIL(initializeBase("platform-test", 1024, 768)); + + // We may not have a window if we're running in test mode + SLANG_ASSERT(isTestMode() || gWindow); + if (gWindow) + { + gWindow->events.sizeChanged = [this]() { onSizeChanged(); }; + gWindow->events.focus = [this]() { onFocus(); }; + gWindow->events.lostFocus = [this]() { onLostFocus(); }; + gWindow->events.keyDown = [this](const platform::KeyEventArgs& e) { onKeyDown(e); }; + gWindow->events.keyUp = [this](const platform::KeyEventArgs& e) { onKeyUp(e); }; + gWindow->events.keyPress = [this](const platform::KeyEventArgs& e) { onKeyPress(e); }; + gWindow->events.mouseMove = [this](const platform::MouseEventArgs& e) + { onMouseMove(e); }; + gWindow->events.mouseDown = [this](const platform::MouseEventArgs& e) + { onMouseDown(e); }; + gWindow->events.mouseUp = [this](const platform::MouseEventArgs& e) { onMouseUp(e); }; + gWindow->events.mouseWheel = [this](const platform::MouseEventArgs& e) + { onMouseWheel(e); }; + } return SLANG_OK; } @@ -105,7 +113,10 @@ struct PlatformTest : public WindowedAppBase commandBuffer->close(); gQueue->executeCommandBuffer(commandBuffer); - gSwapchain->present(); + // We may not have a swapchain if we're running in test mode + SLANG_ASSERT(isTestMode() || gSwapchain); + if (gSwapchain) + gSwapchain->present(); } }; |
