Skip to content

Architecture

BenJule edited this page May 31, 2026 · 1 revision

Architecture

An overview of BambuStudio's project structure, key subsystems, and how this fork extends the upstream codebase.


Repository Layout

BambuStudio/
├── src/
│   ├── libslic3r/          # Core slicing engine (C++)
│   │   ├── Print.cpp/hpp   # Print object — orchestrates slicing
│   │   ├── GCode/          # G-code generation
│   │   ├── Fill/           # Infill pattern generators
│   │   ├── Support/        # Support structure generation
│   │   └── Geometry/       # Computational geometry primitives
│   └── slic3r/
│       └── GUI/            # wxWidgets UI layer
│           ├── MainFrame.cpp/hpp   # Main application window
│           ├── GUI_App.cpp/hpp     # wxApp subclass, lifecycle
│           ├── Plater.cpp/hpp      # 3D plate editor
│           ├── GLCanvas3D.*        # OpenGL 3D viewport
│           └── GUI_Utils.*         # Shared UI utilities
├── deps/                   # Vendored C++ dependencies
│   └── CMakeLists.txt      # Dependency build definitions
├── flatpak/                # Flatpak packaging manifest
├── scripts/                # RPM, AUR, Arch packaging scripts
├── .github/
│   ├── workflows/          # All CI/CD workflows
│   ├── ISSUE_TEMPLATE/     # Bug/feature/crash templates
│   ├── CODEOWNERS          # Auto-review assignments
│   ├── dependabot.yml      # Dependency update config
│   └── PULL_REQUEST_TEMPLATE.md
├── BuildLinux.sh           # Unified Linux build script
├── version.inc             # Version definition (CMake)
└── CMakeLists.txt          # Root build definition

Lineage

Slic3r (AGPL-3.0)
  └── PrusaSlicer (Prusa Research, AGPL-3.0)
        └── BambuStudio (Bambu Lab, AGPL-3.0)
              └── BenJule/BambuStudio (this fork, AGPL-3.0)

This fork stays close to bambulab/BambuStudio upstream. Fork-specific changes are minimal, surgical fixes focused on Linux support and CI/CD.


Core Subsystems

Slicing Engine (libslic3r)

The slicing engine is pure C++ with no UI dependency. It is used both by the GUI and can be driven from the CLI via bambu-studio --slice.

Key classes:

Class Responsibility
Print Top-level slicing coordinator
PrintObject Per-object slicing state
GCode G-code generator
TriangleMesh 3D mesh representation
ExPolygon 2D polygon with holes
Fill* Infill pattern implementations
SupportMaterial Support generation

GUI Layer (slic3r/GUI)

Built on wxWidgets with OpenGL for the 3D viewport.

Component Description
GUI_App Application lifecycle, splash screen, preferences
MainFrame Main window frame, layout management
Plater The central editor: 3D view + object list + sidebar
GLCanvas3D OpenGL rendering canvas
Tab Print/filament/printer settings tabs
NotificationManager Toast notifications

Wayland Fix (fork-specific)

MainFrame::MainFrame() was updated to work correctly on Wayland compositors:

  • SetSizerAndFit()SetSizer() (avoids implicit Fit() before window realization)
  • SetSizeHints() deferred to on_window_geometry() (wxEVT_SHOW + CallAfter) so the GTK window is realized before any gtk_window_resize call
  • SetSize() / SetMinSize() remain synchronous (explicit positive values are safe before realization)
  • A shared_ptr<bool> guard ensures the deferred callback fires only once even though on_window_geometry does not unbind on Linux

Relevant file: src/slic3r/GUI/MainFrame.cpp


Build System

BambuStudio uses CMake with a two-stage build:

Stage 1 — Dependencies (deps/)

./BuildLinux.sh -d    # build deps into deps/build/destdir/

Dependencies are built from source and installed into a local prefix (deps/build/destdir). This avoids dependency on system libraries (other than basic system libs).

Key dependencies: Boost, CGAL, OpenSSL, wxWidgets, OpenGL, GLEW, TBB, nlohmann/json, and others.

The deps build is cached in CI keyed on deps/CMakeLists.txt and all deps/**/*.cmake files.

Stage 2 — BambuStudio (build/)

./BuildLinux.sh -s    # configure and build BambuStudio

CMake finds the deps prefix via CMAKE_PREFIX_PATH set by BuildLinux.sh. The build produces:

  • build/src/bambu-studio — the main binary
  • build/src/BuildLinuxImage.sh — packages the AppImage

ccache Integration (CI)

In the Debian CI job, ccache intercepts GCC calls via /usr/lib/ccache symlinks on PATH. This does not require any CMake flag — it works transparently. See CI-CD-Workflows#ccache-in-debian-build for details.


Packaging

.deb (Debian/Ubuntu)

BuildLinux.sh -p calls dpkg-deb to build a .deb from the installed tree. Package metadata is in scripts/debian/.

.rpm (Fedora/openSUSE)

scripts/build_rpm.sh generates an RPM spec and calls rpmbuild.

AppImage

build/src/BuildLinuxImage.sh uses appimagetool to wrap the binary and its dependencies into a self-contained .AppImage.

Flatpak

flatpak/com.bambulab.BambuStudio.yaml defines the Flatpak manifest. Built and submitted by cd-deploy-flatpak.yml post-release.


Key Data Flows

Slicing Flow

User clicks "Slice" in Plater
  → PrintJob created with current settings
  → libslic3r::Print::process()
    → TriangleMesh analysis
    → Layer generation
    → Perimeter/infill computation
    → Support generation
    → G-code output
  → G-code file written to disk
  → Preview updated in UI

Print Job Flow (networked printer)

User clicks "Print"
  → BambuNetworkPlugin checks printer availability
  → File transferred via MQTT/FTP to printer
  → Print status polled and displayed in Monitoring panel

Configuration

User configuration is stored in:

Platform Path
Linux ~/.config/BambuStudio/
macOS ~/Library/Application Support/BambuStudio/
Windows %APPDATA%\BambuStudio\

Key files: app_config.ini (general settings), user_presets/ (saved profiles).

Clone this wiki locally