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.
RayHit
What a ray ran into, and where.
Returned by Scene->Raycast. Always an object, never Nil -- ask IsHit rather than checking for Nil, so a miss does not need a different code path from a hit.
The normal is the surface the ray struck, which is what a decal, a ricochet or a spark effect needs to orient itself. For a box it is an axis direction; for a prop it points away from the prop's centre, because a prop is tested against its bounding SPHERE rather than its actual geometry.
Operations
GetBox #
Which box was struck.
method : public : GetBox() ~ BoxReturn
| Type | Description |
|---|---|
| Box | the box, or Nil when a prop was hit or nothing was |
GetDistance #
How far along the ray the hit was, in world units.
method : public : GetDistance() ~ FloatReturn
| Type | Description |
|---|---|
| Float | the distance, or 0 on a miss |
GetNormalX #
method : public : GetNormalX() ~ FloatReturn
| Type | Description |
|---|---|
| Float | x of the surface normal at the hit |
GetNormalY #
method : public : GetNormalY() ~ FloatReturn
| Type | Description |
|---|---|
| Float | y of the surface normal at the hit |
GetNormalZ #
method : public : GetNormalZ() ~ FloatReturn
| Type | Description |
|---|---|
| Float | z of the surface normal at the hit |
GetProp #
Which prop was struck.
method : public : GetProp() ~ PropReturn
| Type | Description |
|---|---|
| Prop | the prop, or Nil when a box was hit or nothing was |
IsHit #
Did the ray hit anything?
method : public : IsHit() ~ BoolReturn
| Type | Description |
|---|---|
| Bool | true when it did |
New # constructor
A hit. Built by Scene->Raycast; there is no reason to construct one yourself, and no way to change it afterwards -- a result that can be edited after the fact is a result nobody can trust.
New(distance:Float, x:Float, y:Float, z:Float, nx:Float, ny:Float, nz:Float, box:Box, prop:Prop)Parameters
| Name | Type | Description |
|---|---|---|
| distance | Float | how far along the ray |
| x | Float | where it struck |
| y | Float | where it struck |
| z | Float | where it struck |
| nx | Float | surface normal |
| ny | Float | surface normal |
| nz | Float | surface normal |
| box | Box | the box struck, or Nil |
| prop | Prop | the prop struck, or Nil |