SlimEngine
A minimalist and platform-agnostic base project for interactive graphical applications (2D/3D)
with a strong emphasis on simplicity, ease of use and almost no setup to get started with.
Available as either a single header file, or a directory of headers (a "unity build").
Written in plain C and can be complied in either C or C++.
This project uses SlimApp as it's base platform/application layer(s).
(*A bare-bone application executable on Windows measures at around 17 KB(!))
Architecture:
The platform layer only uses operating-system headers (no standard library used).
The application layer itself has no dependencies, apart from the standard math header.
It is just a library that the platform layer uses - it has no knowledge of the platform.
More details on this architecture here.
Usage:
The single header file variant includes everything.
Otherwise, specific headers can be included from the directory of headers.
The main entry point for the app needs to be defined explicitly (see SlimApp).
Features:
All features of SlimApp are available here as well.
Additional features include basic facilities needed in interactive 3D application:
- A 3D viewport with wireframe rendering, a HUD and rich mouse/keyboard navigation.
- A scene with cameras, meshes and parametric shapes.
- Scene selection and interactive transformations (moving, rotating and scaling).
Well documented example applications cover the features:
-
Viewport: HUD (Head-UP Display)
Viewports come with a HUD that can be toggled on/off
SlimEngine comes with an empty scene, apart from a default camera bound to a default viewport.
The window content is bound to the default viewport so they resize together.
Customizing the scene/viewport can be done in callbacks that get invoked when they're ready.
The HUD is fully customizable, and can hold any number of lines set at viewport-initialization time. -
Viewport: Navigation
Viewport navigation actions can be composed to set-up WASD(FPS)/DCC(orb) navigation style(s).
Keyboard navigation is agnostic to key-binding and is trivial to map keys to.
It supports moving forward, backwards, left, right, up and down and turning left or right.
Mouse navigation controls the viewport's camera and is more granular.
It can pan, zoom, dolly, orient or orbit the camera around a target. -
Cameras: Viewport binding
The scene can have any number of cameras which can be bound to any viewport dynamically.
The camera can be drawn as part of the drawing of the scene -
Shapes: Setup and drawing parametric primitives (Grid, Box, Curves, etc.)
SlimEngine allocates and initializes the scene based on quantities set at app-initialization time.
Wireframe drawing of the scene to the viewport can be set-up to occur on window-redraw. -
Scene: Object selection and manipulation (Translation, Rotation and Scale)
Scene objects can be dragged around the screen, moving them parallel to the viewing plane.
Selecting an object displays it's bouding box, enabling for per-axis translation, rotation and scaling.
-
Scene: Mesh loading from file, instancing and wire-frame drawing
Meshes can be loaded from binary files, with vertex positions, normals and texture coordinates.
They can be moves and transformed just like any other kind of primitive.
A mesh can have multiple instances, each with their own transformation and colors.
Simply have multiple mesh primitives all set with same mesh id.
Memory is allocated automatically for the meshes by reading their headers before loading. -
Scene: Saving to and loading from
.scene
files
Scenes can be saved to a file and later loaded back in-place. -
obj2mesh: Also privided is a separate CLI tool for converting
.obj
files to.mesh
files.
It is also written in plain C, so should compile with either C or C++.
Usage is simple:./obj2mesh my_obj_file.obj my_mesh_file.mesh