Exo, a 3D game engine
Exo enables the writing of expressive, safe 3D games with Spectre's DbC guarantees built into the engine API.
View on GitHubExo is a fully featured and uncomplicated 3D game engine, aiming to solve the issue of over-engineering in 3D game logic by adopting a near-declarative, builder-style approach to scene construction and management.
It leverages the Spectre Programming Language, offering C-like performance (working with both the QBE and C99 backends), and allowing for a modern, DbC approach to game programming that enforces safety whilst retaining performance.
As with every other project in the Spectre ecosystem, Exo is always open to contributions, so instead of complaining, maybe contribute.
A builder-style API
Exo uses a builder API that keeps the game code readable and declarative. Thus, there is no need for XML, YAML or any editor lock-in, only Spectre source code is required, which compiles quickly and reads easy.
val ecs = use("lib/exo/src/ecs.sx")
val engine = use("lib/exo/src/engine.sx")
val rendering = use("lib/exo/src/rendering.sx")
val sdl = use("lib/exo/src/engine/sdl.sx")
fn build_scene() ecs.Scene3D = {
val scene: mut ecs.Scene3D = ecs.new_scene()
ecs.add_light(scene, ecs.make_light(
ecs.make_vec3(0.0 as f32, 4.0 as f32, 1.0 as f32),
ecs.make_vec3(1.0 as f32, 1.0 as f32, 1.0 as f32),
1.8 as f32,
8.0 as f32
))
scene.gravity = 0.0 as f32
@append(scene.cubes, ecs.make_cube(
ecs.make_vec3(0.0 as f32, 0.0 as f32, -2.5 as f32),
ecs.make_vec3(0.25 as f32, 0.72 as f32, 1.00 as f32),
1.0 as f32,
1.0 as f32
))
@append(scene.spheres, ecs.make_sphere(
ecs.make_vec3(1.8 as f32, 0.0 as f32, -3.0 as f32),
ecs.make_vec3(1.00 as f32, 0.42 as f32, 0.32 as f32),
0.7 as f32
))
ecs.add_floor(scene, ecs.make_floor(-1.0 as f32, 0.2 as f32))
return scene
}
pub fn main() i32 = {
val scene: ecs.Scene3D = build_scene()
val app_builder: mut engine.ExoAppBuilder = engine.new_app()
engine.with_title(app_builder, "Hello World")
engine.with_resolution(app_builder, 1280 as i32, 720 as i32)
engine.with_scene(app_builder, scene)
engine.with_default_camera(app_builder)
engine.with_shaders(app_builder, engine.default_shader_config())
engine.with_auto_camera(app_builder)
engine.with_quit_key(app_builder, sdl.SDL_SCANCODE_ESCAPE)
engine.with_key_bindings(app_builder, rendering.default_key_bindings())
engine.with_mouse_config(app_builder, {
enabled: true,
sensitivity_x: 0.002 as f32,
sensitivity_y: 0.002 as f32,
invert_y: false
})
val app: engine.ExoApp = engine.build_app(app_builder)
return trust engine.run_app(app)
}
Installation
The install process is fairly simple, first install the Spectre programming language toolchain if you haven't already, then:
$ spectre init
$ spectre add https://github.com/navid-m/exo.git
Source
Ship some 3D scenes.
GitHub →