clay-template/README.md
Sara 9b2ae482f1 feat: setup template
feat: implemented game of life

feat: implemented automatic stepping

fix: operator< Cell Cell now sorts by y first, then x

fix: equalized scroll x/y

fix: removed unused code path

fix: marked simulation::living as static since it's no longer forward
declared

tweak: decreased number of cells on random initialization

feat: defined Toggle element

feat: added debug information toggle to UI

feat: implemented simulation multithreading

feat: improved simulation frame delta controls

feat: inverted direction of panel colours

fix: removed leftover die colors

feat: reorganized and cleaned up style namespace

chore: increased button border width

feat: added SDL3 submodule

feat: added SDL3_ttf submodule

feat: moved clay to vendor (rather than include)

feat: replaced premake5 with CMake to vendor SDL3

chore: translated more C stuff to C++ in main.cpp

fix: stepping being inconsistent while running

feat: fixed incorrect behaviour on simulation and added benchmarking
code

feat: minor adjustments to UI layout

feat: increased thread count for pool

feat: improved simulation benchmarking

feat: simulation tasks can now be subdivided into separate workloads for
separate threads

feat: improved task counting thread safety

chore: massively increased random field

fix: target delta time is now enforced

feat: added toggle for locked framerate

fix: replaced manual .lock()/.unlock() calls with std::scoped_lock

fix: benchmarking code was off by a magnitude of 1

feat: separated cell state checking into separate function in case
another algo is faster than .contains

chore: some comments on variables in simulation.cpp

feat: set task split to hardware_concurrency()

feat: added basic culling to cell renderer

feat: implemented simulation threading toggle

chore: lowered random button's field size

chore: reduced padding on panel containers

chore: minor formatting adjustment

feat: added README.md

fix: inverted x scroll

feat: converted project to template

feat: added .clangd
2025-09-25 13:12:30 +02:00

2.4 KiB

Clay SDL3 Template

Using Template

Just use just

Run just set-project-name {project name} first.

And remember to git remote set-url origin {repo}.

Otherwise

Modify the CMakeLists.txt manually, just replace CHANGEME with whatever your binary should be called.

Compiling

Remember to git submodule update --init --recursive!

Just again

just configure runs cmake configuration and generates a compile_commands.json.

just build runs the cmake build.

CMake works too, I guess

cmake -S. -Bbuild

cmake --build build

Same as always

Files

thread_pool.h/cpp

Thread pool used for parallel GoL generation ticking.

application.h/cpp

UI and layout logic.

style.h/cpp

Reusable UI styling

resources.h/cpp

Font loading.

elements.h/cpp

Reusable UI elements

input.h/cpp

Handling of input events.

main.cpp:

Entrypoint, setup, and main application loop.

Prerequisites

  • CMake 3.21 or higher

  • Compiler capable of C++23 and C23.

Dependencies

SDL3

Included as git submodule at vendor/SDL3/ and dynamically linked.

SDL3_ttf

Included as git submodule at vendor/SDL3_ttf/ and dynamically linked.

Clay

Included as files in vendor/clay/clay.h; Single header library.

Clay SDL3 renderer

Included as files in vendor/renderer/ and compiled as part of the project.

Note: Mildly modified from the official Clay_SDL3_renderer to enable more advanced styling.

Code Standards

  • Keep program structure as simple as possible. No class Application { class or other Java-isms. Prefer namespaces with static lifetime variables.

  • Use STL where possible. Don't reinvent the wheel.

  • K&R brackets. With notable exceptions(1)

  • camelCase for variables, PascalCase for types and functions (that's what SDL and Clay do).

  • In class member functions, always use this-> to access member variables.

  • const applies to the name to it's left, so it goes after the type, not const int x; but int const x.

  • * and & flush with the declaration name. Type const &Function(Type &inRef)

(1) Bracket exceptions:

  • using scoped_lock in arbitrary blocks, prefer tailed lisp brackets
struct Data {
    int x{ 0 }, y{ 0 };
};
void MyFunction(Data const &data) { // K&R here
    DoAsynchronousThings();
    { scoped_lock lock{ myMutex };
        myVariable++;
    } // not quite lisp, lisp with a tail
    DoMoreAsynchronousThings();
}