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.

LightRig

Several lights at once, plus the ambient they all sit on top of.

One directional light is enough to see a scene; anything with a lamp, a fire, a torch or a window needs more, and this is how a forward renderer carries them -- as arrays with a count, written once per frame.

The limit is fixed, and low on purpose

GLSL needs a compile-time array size, so the maximum is a constant rather than whatever you add. Eight, because a forward renderer evaluates EVERY light for EVERY fragment -- the cost is lights times pixels, and this is the point where a deferred renderer would be the answer instead. Lights past the limit are ignored rather than silently replacing others.

The eye position

Specular highlights depend on where the viewer is, so SetViewPosition has to be told each frame if the camera moves. Forget it and the highlights sit still while the camera orbits, which looks like the material is wrong rather than like a missing call.

Example

rig := LightRig->New();
rig->Add(Light->Directional(Vector3->New(-0.3, 1.0, 0.4)));
rig->Add(Light->Point(Vector3->New(2.0, 1.5, 0.0), 8.0));
rig->SetAmbient(0.18, 0.19, 0.24);

# once a frame, before drawing
rig->SetViewPosition(camera->GetPosition());
rig->ApplyTo(shader);

Operations

Add #

Add a light. Beyond GetMaxLights it is ignored.

method : public : Add(light:Light) ~ Bool

Parameters

NameTypeDescription
lightLightthe light

Return

TypeDescription
Booltrue when it was taken

ApplyTo #

Write the whole rig into a shader.

Once a frame, not once per object: none of it varies between objects. Uniforms the shader does not declare are skipped, so an unlit program can be handed this without filing a diagnostic.

method : public : ApplyTo(shader:Shader) ~ Nil

Parameters

NameTypeDescription
shaderShaderthe program about to draw

Clear #

Remove every light. Ambient and the material settings are kept.

method : public : Clear() ~ Nil

Get #

method : public : Get(index:Int) ~ Light

Parameters

NameTypeDescription
indexIntwhich light

Return

TypeDescription
Lightthe light, or Nil when out of range

GetCount #

method : public : GetCount() ~ Int

Return

TypeDescription
Inthow many lights are in the rig

GetMaxLights # function

How many lights a shader built by this bundle can take.

function : GetMaxLights() ~ Int

Return

TypeDescription
Intthe maximum

GetShininess #

method : public : GetShininess() ~ Float

Return

TypeDescription
Floatthe scene-wide shininess, so a Material that overrode it can be put back rather than guessed at

GetSpecular #

method : public : GetSpecular() ~ Float

Return

TypeDescription
Floatthe scene-wide specular strength

SetAmbient #

The light every surface gets regardless of which way it faces.

method : public : SetAmbient(r:Float, g:Float, b:Float) ~ Nil

Parameters

NameTypeDescription
rFloatred, 0..1
gFloatgreen, 0..1
bFloatblue, 0..1

SetViewPosition #

Where the viewer is, which specular highlights depend on. Set it each frame if the camera moves.

method : public : SetViewPosition(position:Vector3) ~ Nil

Parameters

NameTypeDescription
positionVector3the eye position in world space