Skip to content

TrussC-org/TrussC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,265 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TrussC

Build Discord

A lightweight creative coding framework based on sokol. Inspired by openFrameworks, implemented simply with modern C++.

Features

  • Lightweight: Minimal dependencies, built on sokol
  • Header-only: Most features are header-only
  • C++20: Leverages modern C++ features
  • Cross-platform: macOS 14+ (Metal), Windows (D3D11), Web (WebGPU). Linux/Raspberry Pi planned.
  • oF-like API: Familiar design for openFrameworks users

Quick Start

-> See GET_STARTED.md to get up and running!

Using Project Generator (Recommended)

Build it once from tools/ (run tools/build_mac.command, tools/build_linux.sh, or tools/build_win.bat) to create projects via GUI. Supports VSCode, Cursor, Xcode, and Visual Studio.

Command Line Build

# Build an example
cd examples/graphics/graphicsExample
cmake --preset macos      # or: windows, linux, web
cmake --build build-macos --parallel

# Run (macOS)
./bin/graphicsExample.app/Contents/MacOS/graphicsExample

Minimal Code

#include "TrussC.h"
using namespace std;
using namespace tc;

class MyApp : public App {
    void draw() override {
        clear(0.1);  // Clear to dark gray

        setColor(1.0, 0.4, 0.4);
        drawCircle(getWindowWidth() / 2, getWindowHeight() / 2, 100);
    }
};

int main() {
    WindowSettings settings;
    settings.setSize(960, 600);
    settings.setTitle("My App");
    return runApp<MyApp>(settings);
}

Examples

TrussC comes with over 30 examples covering graphics, 3D, sound, video, and more. See them running in your browser at trussc.org/examples.

Source code is available in the examples/ directory.

API Reference

Comprehensive API reference is available at trussc.org/reference.

Markdown version is also available in docs/REFERENCE.md.

Why TAU?

TrussC uses TAU (τ = 2π) as the primary circle constant instead of PI.

// TAU = one full rotation
rotate(TAU * 0.25f);   // Quarter turn (90°)
rotate(TAU * 0.5f);    // Half turn (180°)
rotate(TAU);           // Full turn (360°)

// PI is deprecated (will emit compiler warning)
rotate(PI);            // Warning: Use TAU instead

Why? TAU maps directly to the unit circle:

  • TAU * 0.25 = quarter turn = 90°
  • TAU * 0.5 = half turn = 180°
  • TAU * 0.75 = three-quarter turn = 270°
  • TAU = full turn = 360°

With PI, you constantly multiply by 2 for full rotations. TAU eliminates this mental overhead.

PI is still available for compatibility, but marked [[deprecated]] to encourage TAU adoption.

See also: The Tau Manifesto

Dependencies

sokol, stb, miniaudio, etc. are all bundled in core/include/. Dear ImGui is available as the tcxImGui addon. See LICENSE.md for details.

Directory Structure

core/include/
├── TrussC.h          # Main header (include this)
├── tcBaseApp.h       # App base class
├── tc/               # Feature headers
│   ├── graphics/     # Shapes, images, fonts
│   ├── gpu/          # FBO, shaders, textures
│   ├── 3d/           # 3D transforms, primitives, camera
│   ├── types/        # Color, Vec2/3/4, etc.
│   ├── events/       # Event system
│   ├── math/         # Math utilities, noise
│   ├── sound/        # Audio playback
│   ├── video/        # Video playback, webcam
│   ├── network/      # TCP, UDP
│   └── utils/        # Timer, file dialogs, etc.
├── sokol/            # sokol library
└── stb/              # stb library

examples/             # Example projects
src/                  # Platform-specific implementations

Documentation

License

MIT License - See LICENSE.md for details.

References