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.

Skybox

The sky: a gradient with a sun in it, drawn behind everything else.

Why this is not a textured cube map

The usual skybox is six images. That needs a colour cube map, which needs a native upload path this library does not have, and it needs the caller to find or make six matched images before they can see anything at all.

This one is computed in the fragment shader from the view direction, so it needs no files, no native additions, and no assets in a release. An outdoor scene gets a horizon, a zenith and a sun by saying what colour they are. A photographic sky is a different feature and would want the cube map.

How it draws

Three things have to be true or a skybox goes wrong in a way that looks like something else broke:

no translation The view matrix's translation is stripped, so the sky does not move when the camera walks. Leave it in and the sky slides past like painted scenery on a nearby wall. inside the cube Mesh->CubeInterior winds its triangles inward. Using Mesh->Cube instead leaves every face back-facing and the sky vanishes the moment culling is on. behind Drawn first with depth WRITES off, so everything after it covers it without the sky having to be far away.

Draw takes the Camera rather than a matrix, because all three of those are easy to get wrong and none of them are interesting.

sky := Skybox->New(); sky->SetHorizon(0.55, 0.62, 0.70); sky->SetZenith(0.12, 0.26, 0.55); sky->SetSun(0.3, 0.55, -0.75); ... window->BeginFrame(); sky->Draw(camera); # first, before the scene scene->Draw(view_projection);

Implements: Freeable

Operations

ClearSun #

Turn the sun off and leave only the gradient.

method : public : ClearSun() ~ Nil

Draw #

Draw the sky.

Call FIRST, before the scene, and after BeginFrame has cleared. The depth buffer is left untouched, so everything drawn afterwards covers this regardless of distance.

Restores depth writing and the cull mode on the way out, because a pass that quietly leaves state changed is the kind of bug that surfaces three draw calls later in unrelated geometry.

method : public : Draw(camera:Camera) ~ Nil

Parameters

NameTypeDescription
cameraCamerathe eye. Its rotation is used and its position is not.

Free #

Release the shader, and the mesh if this sky made it.

method : public : Free() ~ Nil

GetError #

method : public : GetError() ~ String

Return

TypeDescription
Stringwhy this sky cannot draw, or an empty string

IsOk #

method : public : IsOk() ~ Bool

Return

TypeDescription
Booltrue when the shader built and the geometry uploaded

New # constructor

A daylight sky, ready to draw.

New()

New # constructor

A sky drawn with geometry the caller owns.

New(mesh:Mesh)

Parameters

NameTypeDescription
meshMeshan INWARD-facing cube. Mesh->CubeInterior makes one; Mesh->Cube does not and will be invisible under back-face culling.

SetHorizon #

The colour at eye level.

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

Parameters

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

SetSun #

Where the sun is, as a DIRECTION from the viewer -- not a position. It is normalised here, so any non-zero length will do.

Point this the same way as the scene's directional Light and the shadows will agree with the sky. Nothing enforces that: they are two separate settings, and a sun in one corner with shadows from the other is a mistake this class cannot see.

method : public : SetSun(x:Float, y:Float, z:Float) ~ Nil

Parameters

NameTypeDescription
xFloatdirection x
yFloatdirection y, positive is up
zFloatdirection z

SetSunColor #

The sun's colour.

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

Parameters

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

SetSunSize #

How tight the sun's disc is.

This is the cosine of its angular radius, so LARGER is smaller: 0.9999 is a pinpoint, 0.99 is a soft glow, and anything at or below 0.0 fills half the sky. Clamped below 1.0, because exactly 1.0 is a sun of zero size that flickers as it crosses a pixel centre.

method : public : SetSunSize(cosine:Float) ~ Nil

Parameters

NameTypeDescription
cosineFloat0..1, nearer 1 for a smaller sun

SetZenith #

The colour straight up.

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

Parameters

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