v2026.11.2
All Bundles
Bundle

OpenGL 3.3 core rendering on top of SDL2. Builds on sdl2.obl for the window and context; this bundle is the GL side. Compile with -lib sdl2.

Layers, thinnest first: GLWindow (window and context), GL (state), Shader, Mesh, Texture2D, Light, RenderTarget, Material, Frustum, ShadowMap, PointShadow, Overlay, Transform, and Box/Scene. All public, so nothing is capped.

Targets the 3.3 core profile, forward-compatible: the highest common denominator across the desktop platforms Objeck ships, since macOS caps at 4.1 core. GLES-only hardware is out of scope by construction.

See docs/opengl.md for setup, a minimal program, why the calls are coarse-grained, and how to add one.

Frustum

The six planes bounding what a camera can see, for skipping what it cannot.

A Scene submits every box it holds, every frame, whether or not the box is on screen -- so a large world costs the same to draw as a small one, and all of it is spent on geometry the viewer will never see. Testing a box against six planes first is a few dozen arithmetic operations against a draw call plus a matrix multiply plus two uniform uploads.

Scene does this for you and has it on by default. Reach for Frustum directly only for content Scene does not hold.

Where the planes come from

Straight out of the view-projection matrix. Clip space is the region where every coordinate lies between -w and +w, and each of those six inequalities is a plane in world space once written in terms of the matrix's rows -- so no separate description of the camera is needed, and a frustum built this way automatically matches whatever projection is in use, perspective or orthographic.

The planes are normalised, so a plane test yields an actual distance. That costs six square roots per rebuild and makes the box test exact rather than scaled by whatever magnitude the matrix happened to have.

Conservative, on purpose

The box test can keep a box that is fully outside -- a large box near a corner can be outside the view while remaining on the inner side of all six planes individually. It never DISCARDS one that is partly visible, which is the direction that matters: a false keep costs a draw call, a false discard is a hole in the picture.

Example

frustum := Frustum->New();
frustum->SetFromMatrix(view_projection);
if(frustum->ContainsBox(centre, half)) {
# ... draw it ...
};

Operations

ContainsBox #

Whether an axis-aligned box is at least partly inside.

Projects the box's half-extents onto each plane's normal, which is the tightest test available without checking corners individually -- and unlike wrapping the box in a sphere it does not inflate a long thin box into something far larger than it is.

method : public : ContainsBox(center:Vector3, half:Vector3) ~ Bool

Parameters

NameTypeDescription
centerVector3the box's centre
halfVector3its half-extents on each axis

Return

TypeDescription
Booltrue when any part of it could be visible

ContainsSphere #

Whether a sphere is at least partly inside.

method : public : ContainsSphere(x:Float, y:Float, z:Float, radius:Float) ~ Bool

Parameters

NameTypeDescription
xFloatcentre x
yFloatcentre y
zFloatcentre z
radiusFloatthe radius

Return

TypeDescription
Booltrue when any part of it could be visible

IsReady #

method : public : IsReady() ~ Bool

Return

TypeDescription
Booltrue once SetFromMatrix has succeeded; a frustum that is not ready contains everything, so nothing is wrongly culled

SetFromMatrix #

Rebuild from a view-projection matrix. Call once per frame, after the camera has moved.

method : public : SetFromMatrix(view_projection:Float[]) ~ Nil

Parameters

NameTypeDescription
view_projectionFloatprojection times view, column-major