summaryrefslogtreecommitdiffstats
path: root/examples/shader-toy/main.cpp
diff options
context:
space:
mode:
authorAnders Leino <aleino@nvidia.com>2024-12-18 14:39:17 +0200
committerGitHub <noreply@github.com>2024-12-18 12:39:17 +0000
commit41c627fd420a644f0ae86e36f4752e820e2d683c (patch)
tree03c7f119271eec616cf192b573b2487d5b1c2df3 /examples/shader-toy/main.cpp
parent45af2467289bd39baff0269bb7de8a538f617dec (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/shader-toy/main.cpp')
-rw-r--r--examples/shader-toy/main.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/examples/shader-toy/main.cpp b/examples/shader-toy/main.cpp
index 1ab85c0b2..185d18246 100644
--- a/examples/shader-toy/main.cpp
+++ b/examples/shader-toy/main.cpp
@@ -282,10 +282,18 @@ struct ShaderToyApp : public WindowedAppBase
Result initialize()
{
- initializeBase("Shader Toy", 1024, 768);
- gWindow->events.mouseMove = [this](const platform::MouseEventArgs& e) { handleEvent(e); };
- gWindow->events.mouseUp = [this](const platform::MouseEventArgs& e) { handleEvent(e); };
- gWindow->events.mouseDown = [this](const platform::MouseEventArgs& e) { handleEvent(e); };
+ SLANG_RETURN_ON_FAIL(initializeBase("Shader Toy", 1024, 768));
+
+ // We may not have a window if we're running in test mode
+ SLANG_ASSERT(isTestMode() || gWindow);
+ if (gWindow)
+ {
+ gWindow->events.mouseMove = [this](const platform::MouseEventArgs& e)
+ { handleEvent(e); };
+ gWindow->events.mouseUp = [this](const platform::MouseEventArgs& e) { handleEvent(e); };
+ gWindow->events.mouseDown = [this](const platform::MouseEventArgs& e)
+ { handleEvent(e); };
+ }
InputElementDesc inputElements[] = {
{"POSITION", 0, Format::R32G32_FLOAT, offsetof(FullScreenTriangle::Vertex, position)},
@@ -383,7 +391,11 @@ struct ShaderToyApp : 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();
}
void handleEvent(const platform::MouseEventArgs& event)