Skip to content
bg2 engine

API Reference

bg2 engine provides two complementary APIs designed to target different execution environments and performance profiles: a web-oriented API written in TypeScript, and a native API implemented in C++ on top of Vulkan. Both APIs share conceptual alignment in terms of scene structure, resource handling, and rendering paradigms, enabling consistent workflows across platforms.

TypeScript API Reference

The TypeScript API is designed for deployment in browser environments, leveraging WebGL as the underlying graphics backend. It is intended for interactive web applications where ease of integration, rapid iteration, and compatibility are key requirements.

This API is particularly suited for:

  • Embedding real-time 3D content in web applications
  • Product visualization and configurators
  • Educational tools and lightweight simulators
  • Integration with modern frontend frameworks (notably React)

The architecture emphasizes:

  • Component-based scene nodes
  • Flexible rendering control (automatic or event-driven frame updates)
  • Efficient asset loading compatible with web delivery constraints (e.g., ArrayBuffer-based pipelines)

While constrained by browser capabilities, the API maintains a design that mirrors the native engine, facilitating portability of concepts and assets.

C++ API Reference

The C++ API is designed for high-performance native applications, using Vulkan as the rendering backend. It targets scenarios where maximum control over GPU resources, advanced rendering techniques, and scalability are required.

This API is intended for:

  • High-fidelity rendering applications
  • Asset processing and content authoring tools
  • Simulation systems with demanding graphical requirements
  • Offline or backend rendering pipelines

Key characteristics include:

  • Explicit GPU control using modern Vulkan constructs (e.g., dynamic rendering, manual synchronization)
  • Advanced rendering pipelines (PBR, IBL, MSAA, deferred techniques)
  • Fine-grained resource management and memory control
  • Modular pipeline configuration and extensibility

The native API prioritizes performance, predictability, and rendering quality, making it suitable for production-grade tools and systems where the web runtime would be insufficient.

Both APIs are designed to be structurally consistent:

  • Shared scene graph and component model
  • Compatible asset formats and serialization workflows
  • Similar shader logic where platform constraints allow

This alignment enables hybrid workflows, such as generating assets or scenes with the native API and deploying them directly to the web using the TypeScript API, without requiring format transformations or conceptual rewrites.