summaryrefslogtreecommitdiffstats
path: root/examples/platform-test
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2024-10-29 14:49:26 +0800
committerGitHub <noreply@github.com>2024-10-29 14:49:26 +0800
commitf65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 (patch)
treeea1d61342cd29368e19135000ec2948813096205 /examples/platform-test
parenta729c15e9dce9f5116a38afc66329ab2ca4cea54 (diff)
format
* format * Minor test fixes * enable checking cpp format in ci
Diffstat (limited to 'examples/platform-test')
-rw-r--r--examples/platform-test/main.cpp188
1 files changed, 100 insertions, 88 deletions
diff --git a/examples/platform-test/main.cpp b/examples/platform-test/main.cpp
index f20a5a716..daa9bbc4b 100644
--- a/examples/platform-test/main.cpp
+++ b/examples/platform-test/main.cpp
@@ -1,6 +1,6 @@
+#include "examples/example-base/example-base.h"
#include "slang.h"
#include "tools/platform/window.h"
-#include "examples/example-base/example-base.h"
using namespace gfx;
using namespace Slang;
@@ -8,93 +8,105 @@ using namespace Slang;
struct PlatformTest : public WindowedAppBase
{
-void onSizeChanged()
-{
- printf("onSizeChanged\n");
-}
-
-void onFocus()
-{
- printf("onFocus\n");
-}
-
-void onLostFocus()
-{
- printf("onLostFocus\n");
-}
-
-void onKeyDown(platform::KeyEventArgs args)
-{
- printf("onKeyDown(key=0x%02x, buttons=0x%02x)\n", (uint32_t)args.key, args.buttons);
-}
-
-void onKeyUp(platform::KeyEventArgs args)
-{
- printf("okKeyUp(key=0x%02x, buttons=0x%02x)\n", (uint32_t)args.key, args.buttons);
-}
-
-void onKeyPress(platform::KeyEventArgs args)
-{
- printf("onKeyPress(keyChar=0x%02x)\n", args.keyChar);
-}
-
-void onMouseMove(platform::MouseEventArgs args)
-{
- printf("onMouseMove(x=%d, y=%d, delta=%d, buttons=0x%02x\n", args.x, args.y, args.delta, args.buttons);
-}
-
-void onMouseDown(platform::MouseEventArgs args)
-{
- printf("onMouseDown(x=%d, y=%d, delta=%d, buttons=0x%02x\n", args.x, args.y, args.delta, args.buttons);
-}
-
-void onMouseUp(platform::MouseEventArgs args)
-{
- printf("onMouseUp(x=%d, y=%d, delta=%d, buttons=0x%02x\n", args.x, args.y, args.delta, args.buttons);
-}
-
-void onMouseWheel(platform::MouseEventArgs args)
-{
- printf("onMouseWheel(x=%d, y=%d, delta=%d, buttons=0x%02x\n", args.x, args.y, args.delta, args.buttons);
-}
-
-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); };
-
- return SLANG_OK;
-}
-
-virtual void renderFrame(int frameBufferIndex) override
-{
- ComPtr<ICommandBuffer> commandBuffer = gTransientHeaps[frameBufferIndex]->createCommandBuffer();
-
- auto renderEncoder = commandBuffer->encodeRenderCommands(gRenderPass, gFramebuffers[frameBufferIndex]);
-
- gfx::Viewport viewport = {};
- viewport.maxZ = 1.0f;
- viewport.extentX = (float)windowWidth;
- viewport.extentY = (float)windowHeight;
- renderEncoder->setViewportAndScissor(viewport);
-
- renderEncoder->endEncoding();
- commandBuffer->close();
- gQueue->executeCommandBuffer(commandBuffer);
-
- gSwapchain->present();
-}
-
+ void onSizeChanged() { printf("onSizeChanged\n"); }
+
+ void onFocus() { printf("onFocus\n"); }
+
+ void onLostFocus() { printf("onLostFocus\n"); }
+
+ void onKeyDown(platform::KeyEventArgs args)
+ {
+ printf("onKeyDown(key=0x%02x, buttons=0x%02x)\n", (uint32_t)args.key, args.buttons);
+ }
+
+ void onKeyUp(platform::KeyEventArgs args)
+ {
+ printf("okKeyUp(key=0x%02x, buttons=0x%02x)\n", (uint32_t)args.key, args.buttons);
+ }
+
+ void onKeyPress(platform::KeyEventArgs args)
+ {
+ printf("onKeyPress(keyChar=0x%02x)\n", args.keyChar);
+ }
+
+ void onMouseMove(platform::MouseEventArgs args)
+ {
+ printf(
+ "onMouseMove(x=%d, y=%d, delta=%d, buttons=0x%02x\n",
+ args.x,
+ args.y,
+ args.delta,
+ args.buttons);
+ }
+
+ void onMouseDown(platform::MouseEventArgs args)
+ {
+ printf(
+ "onMouseDown(x=%d, y=%d, delta=%d, buttons=0x%02x\n",
+ args.x,
+ args.y,
+ args.delta,
+ args.buttons);
+ }
+
+ void onMouseUp(platform::MouseEventArgs args)
+ {
+ printf(
+ "onMouseUp(x=%d, y=%d, delta=%d, buttons=0x%02x\n",
+ args.x,
+ args.y,
+ args.delta,
+ args.buttons);
+ }
+
+ void onMouseWheel(platform::MouseEventArgs args)
+ {
+ printf(
+ "onMouseWheel(x=%d, y=%d, delta=%d, buttons=0x%02x\n",
+ args.x,
+ args.y,
+ args.delta,
+ args.buttons);
+ }
+
+ 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); };
+
+ return SLANG_OK;
+ }
+
+ virtual void renderFrame(int frameBufferIndex) override
+ {
+ ComPtr<ICommandBuffer> commandBuffer =
+ gTransientHeaps[frameBufferIndex]->createCommandBuffer();
+
+ auto renderEncoder =
+ commandBuffer->encodeRenderCommands(gRenderPass, gFramebuffers[frameBufferIndex]);
+
+ gfx::Viewport viewport = {};
+ viewport.maxZ = 1.0f;
+ viewport.extentX = (float)windowWidth;
+ viewport.extentY = (float)windowHeight;
+ renderEncoder->setViewportAndScissor(viewport);
+
+ renderEncoder->endEncoding();
+ commandBuffer->close();
+ gQueue->executeCommandBuffer(commandBuffer);
+
+ gSwapchain->present();
+ }
};
// This macro instantiates an appropriate main function to