2025-11-12 20:58:07 +01:00
|
|
|
/*
|
|
|
|
|
catcrafts.net
|
2026-07-18 23:27:41 +02:00
|
|
|
Copyright (C) 2026 Catcrafts
|
2025-11-12 20:58:07 +01:00
|
|
|
|
2026-07-18 23:27:41 +02:00
|
|
|
The source code of this website is made available for viewing purposes only.
|
2025-11-12 20:58:07 +01:00
|
|
|
No permission is granted to copy, modify, distribute, or create derivative works.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import Catcrafts;
|
2026-07-18 23:27:41 +02:00
|
|
|
import Crafter.Graphics;
|
2025-11-12 20:58:07 +01:00
|
|
|
import std;
|
|
|
|
|
using namespace Catcrafts;
|
|
|
|
|
using namespace Crafter;
|
|
|
|
|
|
2025-11-12 21:24:23 +01:00
|
|
|
int main() {
|
2026-07-18 23:27:41 +02:00
|
|
|
Device::Initialize();
|
|
|
|
|
// Window in CRAFTER_GRAPHICS_WINDOW_DOM mode is a page-level event hub
|
|
|
|
|
// plus the rAF driver; even without subscribing to its events we need
|
|
|
|
|
// it so StartSync() can keep the wasm module alive past main() (the
|
|
|
|
|
// bridge stashes a raw pointer, so the storage has to outlive main).
|
2026-07-19 01:13:30 +02:00
|
|
|
// The dimensions are a hint only — the JS bridge sizes the render
|
|
|
|
|
// surface to the canvas (full viewport, or the mount element).
|
|
|
|
|
static Window window(1280, 720, "Catcrafts");
|
|
|
|
|
|
|
|
|
|
// Build the ray-tracing pipeline + scene now (runs StartInit/FinishInit).
|
|
|
|
|
// The render canvas starts hidden; the demo only traces once a route
|
|
|
|
|
// mounts it into #webgpu-demo (see Catcrafts:Demo).
|
|
|
|
|
SetupDemo(window);
|
2026-07-18 23:27:41 +02:00
|
|
|
|
|
|
|
|
InitializePage();
|
|
|
|
|
|
|
|
|
|
Router::AddPopStateListener([]{
|
|
|
|
|
RenderRoot(Router::GetPath());
|
2025-11-12 21:24:23 +01:00
|
|
|
});
|
2025-11-12 20:58:07 +01:00
|
|
|
|
2026-07-18 23:27:41 +02:00
|
|
|
static Dom::HtmlElementPtr blogButton("blog-nav-button");
|
|
|
|
|
blogButton.AddClickListener([](Dom::MouseEvent) {
|
|
|
|
|
Router::PushState("{}", "", "/blog");
|
2025-11-12 21:56:18 +01:00
|
|
|
RenderRoot("/blog");
|
2025-11-12 20:58:07 +01:00
|
|
|
});
|
|
|
|
|
|
2026-07-18 23:27:41 +02:00
|
|
|
RenderRoot(Router::GetPath());
|
|
|
|
|
|
2026-07-19 01:13:30 +02:00
|
|
|
window.Render();
|
2026-07-18 23:27:41 +02:00
|
|
|
window.StartUpdate();
|
|
|
|
|
window.StartSync();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|