catcrafts.net/interfaces/Catcrafts-Blog.cppm
Jorijn van der Graaf fb2f6079cc
All checks were successful
Deploy / build-deploy (push) Successful in 1m38s
webgpu demo
2026-07-19 01:13:30 +02:00

68 lines
No EOL
3.3 KiB
C++

/*
catcrafts.net
Copyright (C) 2026 Catcrafts
The source code of this website is made available for viewing purposes only.
No permission is granted to copy, modify, distribute, or create derivative works.
*/
export module Catcrafts:Blog;
import Crafter.Graphics;
import std;
using namespace Crafter;
export namespace Catcrafts {
struct BlogPost {
std::string name;
std::string slug;
std::string date;
std::string content;
};
std::vector<BlogPost> posts {
{
"Hello World! 2?",
"hello-world-2",
"2026-07-18",
R"(So this blog has been mega dead but today i bring something exciting that was already released months ago but never deployed xd.
Crafter.CppDOM is dead, long live Crafter.Graphics!
This website is now updated to use the new Crafter.Graphics library, which allow for C++ manpiulation of the DOM, and as a new feature WebGPU!
And what better way to flex WebGPU than ray tracing? Here's a little scene traced live in your browser, shadows and all, straight from the same C++ compiled to WASM that rendered this very post:
)"
},
{
"In WASM, Exit doesn't mean done.",
"in-wasm-exit-doesnt-mean-done",
"2025-11-14",
R"(So if anyone looked at the source code for this website pefore this post you would have seen that everything was allocated with new, for example this very blog was defined as <code>std::vector&lt;BlogPost&gt; posts = new std::vector&lt;BlogPost&gt;{...};</code><br><br>
Reason for this was that everything became corrupted when callbacking from JS, not knowing sure as to why this was the fastest solution, but after debugging the problem became clear.<br><br>
When we reach the end of <code>int main()</code> from the eyes of C++ we're finished, deconstruct everything and wrap it up. Unkowing that we just registered a bunch of event handlers with JS.<br><br>
This caused all the memory corruption errors since everything was destructed.<br><br>
Luckily this is a very simple fix of adding <code>-fno-c++-static-destructors</code>, and the ease of things like this is also one of the reasons i use clang instead of gcc.<br><br>
So now all examples and this site have been updated to use normal variables again.<br><br>
Stick around for the next post for the <strong>CI/CD nightmare</strong> (not for the faint of heart))"
},
{
"Hello World!",
"hello-world",
"2025-11-12",
R"(Welcome to catcrafts.net!<br><br>
Here we believe optimization is everything and C++ is a gift from god.<br>
This blog will mostly be dedicated to random tidbits i come across while working on my Crafter series of libraries.<br><br>
Like this website which is fully written in C++ using the Crafter.Graphics library.<br>
And source available too!<br>
<a href="https://forgejo.catcrafts.net/Catcrafts/catcrafts.net">https://forgejo.catcrafts.net/Catcrafts/catcrafts.net<a>)"
}
};
void RenderBlog();
void RenderBlogPost(const std::string_view slug);
}