Foundation
Loading...
Searching...
No Matches
Triangle.cpp

Animated triangle example.

#include "Examples.hpp"
namespace Examples {
class TriangleDemoApp : public RenderApplication {
void OnRendererSetup() override {
createPass(
mRenderer.get(), "Triangle", RHIDeviceQueueType::Graphics,
[=](PassHandle self, Renderer* r) {
r->BindBackbufferRTV(self);
r->BindShader(self, RHIShaderStageBits::Vertex, "vertMain", "data/shaders/Triangle.spv");
r->BindShader(self, RHIShaderStageBits::Fragment, "fragMain", "data/shaders/Triangle.spv");
r->BindPushConstant(self, RHIShaderStageBits::Vertex | RHIShaderStageBits::Fragment, 0, sizeof(float));
},
[=, this](PassHandle self, Renderer* r, RHICommandList* cmd) {
auto const& img_wh = r->GetSwapchainExtent();
r->CmdBeginGraphics(self, cmd, img_wh);
r->CmdSetPipeline(self, cmd);
r->CmdSetPushConstant(self, cmd, RHIShaderStageBits::Vertex | RHIShaderStageBits::Fragment, 0, GetApplicationTime());
cmd->SetViewport(0, 0, img_wh.x, img_wh.y)
.SetScissor(0, 0, img_wh.x, img_wh.y)
.Draw(3)
.EndGraphics();
}
);
}
};
}
int main(int argc, char** argv) {
app.Initialize<VulkanApplication>({
.windowTitle = "Triangle",
.renderer = {
.numRenderThreads = 0 /* disables MT */
}
});
app.RunForever();
}
int main(int argc, char **argv)
Definition ImGui.cpp:26
Definition MeshShader.cpp:11
void OnRendererSetup() override
Set up the renderer by creating passes, resources, and other configurations.
Definition MeshShader.cpp:12
void Initialize(ApplicationInitDesc const &desc={}, Args &&... args)
Initialize the application with the specified RHI backend.
Definition Application.hpp:205
UniquePtr< Renderer > mRenderer
Definition Application.hpp:102
void RunForever()
Start the Render thread and run the application loop indefinitely, until the window is closed or the ...
Definition Application.cpp:127
For a complete list of examples, see the Examples Page.
Definition Examples.hpp:12