Written from a line-by-line source review; the classic drawing verbs each map to one OpenGL call, while the window, event and texture verbs manage the SDL2/GL lifecycle.
Introduction
The gl namespace is a layer around the classic OpenGL fixed-pipeline calls that is now self-contained: it opens its own window and OpenGL context (gl.Open), handles window events (gl.PollEvent, gl.PumpEvents, etc.) and texture slots (gl.CreateTextureSlot, gl.UpdateTexture). The classic drawing verbs still map one-to-one to OpenGL entry points (Viewport, Clear, MatrixMode, Frustum, Begin/End, Vertex3f, Color3f, BindTexture, etc.). There is no high-level scene or cube logic — the script builds that from gl.* primitives.
Official positioning
gl.* is the officially supported OpenGL layer of DominScript. The goal is a stable, small, and understandable surface: when new OpenGL knowledge enters script-level code, the 43-verb list gives a solid starting point. Higher-level (scene, camera, cube renderer) abstractions are NOT part of this official layer — those are to be built up in the script-driven demos' own functions from gl.* primitives.
Lifecycle and context
gl.* rendering code requires a valid OpenGL context. This is now created by gl.Open itself: it opens its own window with a matching OpenGL context and vsync enabled, so no external windowing layer is needed. (For backward compatibility, if a current context already exists before the call, the layer can rely on that instead.) Before custom drawing call gl.MakeCurrent, and at the end gl.UnbindCurrent — this activates and deactivates the context on the current thread. Buffer swapping (making the freshly drawn frame visible) is the job of gl.SwapBuffers.
Two-level separation
DominScript's previous (cube-rotating) demo was built on top of a thick opengl.* facade that also contained the higher-level scene logic. After the separation, the opengl.* facade has moved to the non-official tree (non_official/plugins/opengl_thick_facade), and only gl.* remains on the official surface. The new script-driven demo (Examples/opengl_ffmpeg_script_driven_demo.dom) uses this thin gl.* layer: the entire cube rendering is built from script-level primitives over the thin adapter.
Loading the plugin
plugin "../plugins/print/PrintPlugin";
plugin "../plugins/opengl/GlPlugin"; // the file registers the gl.*
namespaceA typical flow — drawing custom geometry
// the runtime must provide a valid GL context gl.MakeCurrent(); gl.ClearColor(0.0, 0.0, 0.0, 1.0); gl.Clear(0x4100); // GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT gl.MatrixMode(0x1701); // GL_PROJECTION gl.LoadIdentity(); gl.Frustum(-1.0, 1.0, -0.75, 0.75, 1.0, 100.0); gl.MatrixMode(0x1700); // GL_MODELVIEW gl.LoadIdentity(); gl.Translatef(0.0, 0.0, -5.0); gl.Rotatef(45.0, 0.0, 1.0, 0.0); gl.Begin(0x0007); // GL_QUADS gl.Color3f(1.0, 0.0, 0.0); gl.Vertex3f(-1.0, -1.0, 0.0); gl.Color3f(0.0, 1.0, 0.0); gl.Vertex3f( 1.0, -1.0, 0.0); gl.Color3f(0.0, 0.0, 1.0); gl.Vertex3f( 1.0, 1.0, 0.0); gl.Color3f(1.0, 1.0, 0.0); gl.Vertex3f(-1.0, 1.0, 0.0); gl.End(); gl.SwapBuffers(); gl.UnbindCurrent();
What to know about every function (the basics)
Every gl.* verb returns 0 on success. The meaningful feedback is in GL state — getters are not (currently) part of the thin adapter.
The verbs call exactly the matching GL entry point (gl.Clear -> glClear, gl.Vertex3f -> glVertex3f, etc.). No intermediate conversion, no script-level state machine.
Rendering needs a valid context — first gl.MakeCurrent, at the end gl.UnbindCurrent.
Verbs valid inside a gl.Begin / gl.End block (Vertex3f, Color3f, TexCoord2f) only work there.
GL constants (GL_COLOR_BUFFER_BIT, GL_PROJECTION, etc.) are numeric values; the script-driven demo stores them in its own named-constants block for readability.
An error (stopping the script) is caused by a wrong argument count or type, and an uninitialized OpenGL context.
How to read the signatures
Numbers (number) are IEEE 754 double precision (DominScript double). Masks and modes are int; GL constants can be passed directly (e.g. 0x0007 = GL_QUADS). textureSlot is a previously created OpenGL texture object id. The type after the -> arrow is the return type (most verbs return int; gl.FrameInfo returns a descriptive string).
GL context and state
Activating/deactivating the OpenGL fixed-pipeline context, buffer swap, and classic state setup (color, blend, depth, alpha, line width, matrix mode).
gl.MakeCurrent
gl.MakeCurrent() -> int
Activates the OpenGL context on the current thread (for subsequent gl.* calls).
This function takes no arguments.
0 on success.
gl.MakeCurrent();
// ... your gl.* drawing ...
gl.UnbindCurrent();(gl.* calls are now valid)
Call before your own gl.* drawing so the context becomes active on the thread. Particularly important in multi-threaded code.
gl.UnbindCurrent
gl.UnbindCurrent() -> int
Deactivates the OpenGL context on the current thread.
This function takes no arguments.
0 on success.
gl.MakeCurrent();
// ...
gl.UnbindCurrent();(gl.* calls are no longer valid)
The counterpart of gl.MakeCurrent: release the context at the end of your drawing. Useful when another thread wants access.
gl.SwapBuffers
gl.SwapBuffers() -> int
Swaps the window's front and back video buffers (the newly drawn frame becomes visible).
This function takes no arguments.
0 on success.
// ... your drawing ...
gl.SwapBuffers();(the image appears)
At the end of your gl.* rendering: this makes the new frame visible.
gl.Viewport
gl.Viewport(x, y, width, height) -> int
Sets the rendering viewport within the window.
| Parameter | Type | Description |
|---|---|---|
| x | int | Viewport bottom-left X coordinate. |
| y | int | Viewport bottom-left Y coordinate. |
| width | int | Viewport width. |
| height | int | Viewport height. |
0 on success.
gl.Viewport(0, 0, 800, 600);
(rendering focuses on the given area)
After custom rendering or resolution change. On window resize, call this with the new size in the resize event handler.
gl.Clear
gl.Clear(mask) -> int
Clears the selected buffers based on the given bitmask.
| Parameter | Type | Description |
|---|---|---|
| mask | int | The bitmask (e.g. GL_COLOR_BUFFER_BIT=0x4000, GL_DEPTH_BUFFER_BIT=0x100). |
0 on success.
gl.Clear(0x4100); // color + depth(the selected buffers are cleared)
At the start of every frame to clear the background and depth buffer.
gl.ClearColor
gl.ClearColor(r, g, b, a) -> int
Sets the background color used by gl.Clear.
| Parameter | Type | Description |
|---|---|---|
| r | number | Red (0..1). |
| g | number | Green (0..1). |
| b | number | Blue (0..1). |
| a | number | Alpha (0..1). |
0 on success.
gl.ClearColor(0.0, 0.0, 0.0, 1.0); gl.Clear(0x4000);
(background is black)
Usually call before gl.Clear: this sets which color the background is cleared to.
gl.Enable
gl.Enable(cap) -> int
Enables an OpenGL capability.
| Parameter | Type | Description |
|---|---|---|
| cap | int | The capability code (e.g. GL_DEPTH_TEST=0x0B71, GL_BLEND=0x0BE2). |
0 on success.
gl.Enable(0x0B71); // GL_DEPTH_TEST(depth test active)
For toggling rendering state bits — e.g. depth test in 3D, or blending for transparent textures.
gl.Disable
gl.Disable(cap) -> int
Disables an OpenGL capability.
| Parameter | Type | Description |
|---|---|---|
| cap | int | The capability code. |
0 on success.
gl.Disable(0x0B71); // GL_DEPTH_TEST(depth test inactive)
The counterpart of gl.Enable: when a state needs to be temporarily turned off (e.g. for 2D UI layers where the depth test interferes).
gl.BlendFunc
gl.BlendFunc(sFactor, dFactor) -> int
Sets the source and destination factors for blending.
| Parameter | Type | Description |
|---|---|---|
| sFactor | int | Source factor (e.g. GL_SRC_ALPHA=0x0302). |
| dFactor | int | Destination factor (e.g. GL_ONE_MINUS_SRC_ALPHA=0x0303). |
0 on success.
gl.Enable(0x0BE2); // GL_BLEND
gl.BlendFunc(0x0302, 0x0303);(alpha blending active)
For correctly rendering transparent textures and surfaces: GL_SRC_ALPHA / GL_ONE_MINUS_SRC_ALPHA is the standard alpha-blending setup.
gl.AlphaFunc
gl.AlphaFunc(func, ref) -> int
Sets the alpha test (filters pixels by alpha value).
| Parameter | Type | Description |
|---|---|---|
| func | int | The comparison function (e.g. GL_GREATER=0x0204). |
| ref | number | The reference value (0..1). |
0 on success.
gl.Enable(0x0BC0); // GL_ALPHA_TEST
gl.AlphaFunc(0x0204, 0.5);(only alpha>0.5 pixels visible)
For hard alpha-masked textures (e.g. trees, leaves) where you want sharp cutoff rather than blending.
gl.LineWidth
gl.LineWidth(width) -> int
Sets the line drawing width in pixels.
| Parameter | Type | Description |
|---|---|---|
| width | number | The line width. |
0 on success.
gl.LineWidth(2.0);
(following lines are 2 pixels thick)
For wireframe drawing, contours, and helper lines — e.g. drawing the edges of a cube thickly.
gl.MatrixMode
gl.MatrixMode(mode) -> int
Selects which matrix the following matrix operations (LoadIdentity, Frustum, Translatef, Rotatef) apply to.
| Parameter | Type | Description |
|---|---|---|
| mode | int | The matrix mode (GL_PROJECTION=0x1701, GL_MODELVIEW=0x1700). |
0 on success.
gl.MatrixMode(0x1701); // GL_PROJECTION
gl.LoadIdentity();(projection matrix becomes active)
For switching between projection (PROJECTION) and model-view (MODELVIEW) in the classic OpenGL matrix system. The selected matrix becomes the target for Load/Translate/Rotate.
gl.LoadIdentity
gl.LoadIdentity() -> int
Sets the current matrix (selected by MatrixMode) to the identity matrix.
This function takes no arguments.
0 on success.
gl.MatrixMode(0x1700); // GL_MODELVIEW
gl.LoadIdentity();(current matrix is identity)
At the start of a frame: reset the projection and model-view matrices so the following Translate/Rotate/Frustum build them up from scratch.
gl.Frustum
gl.Frustum(left, right, bottom, top, near, far) -> int
Applies a perspective projection to the current matrix with the given frustum parameters.
| Parameter | Type | Description |
|---|---|---|
| left | number | Left plane coordinate. |
| right | number | Right plane coordinate. |
| bottom | number | Bottom plane coordinate. |
| top | number | Top plane coordinate. |
| near | number | Near clip plane. |
| far | number | Far clip plane. |
0 on success.
gl.MatrixMode(0x1701); gl.LoadIdentity(); gl.Frustum(-1.0, 1.0, -0.75, 0.75, 1.0, 100.0);
(perspective projection set)
For building the perspective projection of a 3D scene.
gl.Translatef
gl.Translatef(x, y, z) -> int
Translates the current matrix by the given vector.
| Parameter | Type | Description |
|---|---|---|
| x | number | X translation. |
| y | number | Y translation. |
| z | number | Z translation. |
0 on success.
gl.Translatef(0.0, 0.0, -5.0);
(coordinate system shifts back)
For positioning objects on the model-view matrix. A negative Z typically moves the object further from the camera.
gl.Rotatef
gl.Rotatef(angle, x, y, z) -> int
Rotates the current matrix around the given axis by the given angle.
| Parameter | Type | Description |
|---|---|---|
| angle | number | Rotation angle in degrees. |
| x | number | Axis X component. |
| y | number | Axis Y component. |
| z | number | Axis Z component. |
0 on success.
gl.Rotatef(45.0, 0.0, 1.0, 0.0);
(45 degrees around the Y axis)
For custom rotations: orienting individual geometry.
Primitive drawing
Classic OpenGL primitive drawing inside a Begin/End block: vertices, colors, texture coordinates, and texture binding.
gl.Begin
gl.Begin(mode) -> int
Opens a primitive-drawing block in the given mode (lines, quads, etc.).
| Parameter | Type | Description |
|---|---|---|
| mode | int | Primitive mode (GL_LINES=0x0001, GL_QUADS=0x0007). |
0 on success.
gl.Begin(0x0007); // GL_QUADS
gl.Vertex3f(-1,-1,0);
gl.Vertex3f( 1,-1,0);
gl.Vertex3f( 1, 1,0);
gl.Vertex3f(-1, 1,0);
gl.End();(a quad appears)
The start of classic immediate-mode drawing. Inside the block, Vertex3f, Color3f, TexCoord2f specify the primitive; End closes it.
gl.End
gl.End() -> int
Closes the primitive block opened by Begin.
This function takes no arguments.
0 on success.
gl.Begin(0x0001); // GL_LINES
gl.Vertex3f(0,0,0); gl.Vertex3f(1,0,0);
gl.End();(a line appears)
Every gl.Begin must be matched with exactly one gl.End. Outside the block, Vertex/Color/TexCoord has no effect.
gl.Vertex3f
gl.Vertex3f(x, y, z) -> int
Adds a 3D vertex to the current primitive block.
| Parameter | Type | Description |
|---|---|---|
| x | number | X coordinate. |
| y | number | Y coordinate. |
| z | number | Z coordinate. |
0 on success.
gl.Begin(0x0007); gl.Vertex3f(-1,-1,0); gl.Vertex3f(1,-1,0); gl.Vertex3f(1,1,0); gl.Vertex3f(-1,1,0); gl.End();
(corners of a quad)
For specifying primitive corners. The current Color3f and TexCoord2f apply to every following vertex.
gl.Color3f
gl.Color3f(r, g, b) -> int
Sets the current vertex color for the next Vertex3f calls.
| Parameter | Type | Description |
|---|---|---|
| r | number | Red (0..1). |
| g | number | Green (0..1). |
| b | number | Blue (0..1). |
0 on success.
gl.Begin(0x0007); gl.Color3f(1,0,0); gl.Vertex3f(-1,-1,0); gl.Color3f(0,1,0); gl.Vertex3f( 1,-1,0); gl.Color3f(0,0,1); gl.Vertex3f( 1, 1,0); gl.Color3f(1,1,0); gl.Vertex3f(-1, 1,0); gl.End();
(gradient quad)
For per-vertex color gradients. If every vertex has a different color, the primitive's interior is auto-interpolated.
gl.TexCoord2f
gl.TexCoord2f(s, t) -> int
Sets the current texture coordinate for the next Vertex3f calls.
| Parameter | Type | Description |
|---|---|---|
| s | number | S (horizontal) texture coordinate (typically 0..1). |
| t | number | T (vertical) texture coordinate (typically 0..1). |
0 on success.
gl.BindTexture(0x0DE1, $slot); // GL_TEXTURE_2D
gl.Begin(0x0007);
gl.TexCoord2f(0,0); gl.Vertex3f(-1,-1,0);
gl.TexCoord2f(1,0); gl.Vertex3f( 1,-1,0);
gl.TexCoord2f(1,1); gl.Vertex3f( 1, 1,0);
gl.TexCoord2f(0,1); gl.Vertex3f(-1, 1,0);
gl.End();(textured quad)
For drawing textured primitives: the four corner (s,t) values determine how the texture stretches over the quad.
gl.BindTexture
gl.BindTexture(target, textureSlot) -> int
Activates the given texture slot for subsequent draws.
| Parameter | Type | Description |
|---|---|---|
| target | int | Texture target (GL_TEXTURE_2D=0x0DE1). |
| textureSlot | int | The texture slot id. |
0 on success.
gl.BindTexture(0x0DE1, $slot);
// the next gl.Begin/End draws textured(slot becomes active)
For your own textured drawing: before gl.Begin/End bind a slot so the TexCoord2f maps to a valid texture. Slot 0 disables texturing.
gl.Open
gl.Open(width, height, title) -> int
Creates its own SDL2 window and OpenGL context, makes it current on the calling thread, loads the GL entry points and enables vsync (swap interval 1). This is what makes the thin gl.* layer self-sufficient: it no longer needs an external opengl.Open. Width and height must be in the 64..8192 range.
| Parameter | Type | Description |
|---|---|---|
| width | int | Window client width in pixels (64..8192). |
| height | int | Window client height in pixels (64..8192). |
| title | string | The window title-bar text. |
1 on success; 0 (with a runtime error) if the window or context cannot be created.
plugin "../plugins/opengl/GlPlugin";
if (gl.Open(1280, 720, "DominScript GL") == 0) {
os.Println("could not open GL window");
return 1;
}
// ... sajat gl.* renderelo ciklus ...
gl.Close();(a 1280x720 window with a GL context appears)
When the script wants to open its own window and not rely on the non-official thick facade. Call gl.SwapBuffers at the end of each frame and gl.Close on exit.
gl.IsOpen
gl.IsOpen() -> int
Reports whether a gl-owned window is currently open (i.e. a successful gl.Open ran and gl.Close has not closed it yet).
This function takes no arguments.
1 if the self-owned window is open, otherwise 0.
while (gl.IsOpen() != 0) {
gl.PollEvents();
// ... rajzolas ...
gl.SwapBuffers();
}As the main render-loop condition: run while the window stays open. A QUIT event from gl.PollEvent together with gl.Close ends the loop.
gl.Close
gl.Close() -> int
Releases the resources created by gl.Open: deletes the slot and video textures, destroys the GL context and the SDL2 window, then sets the open state to 0. If no self-owned window was open, it safely does nothing.
This function takes no arguments.
Always 1.
// a renderelo ciklus utan
gl.Close();(the window closes and the GL resources are released)
At program exit, or when the self-owned window is no longer needed. It is the counterpart of gl.Open.
gl.PollEvent
gl.PollEvent() -> int
Fetches a single pending SDL event, updates the internal "last event" state (type, X, Y, dx, dy, button, wheel, size) and returns the event type. If no event is waiting, the type is 0 (NONE).
This function takes no arguments.
The event type: 0=NONE, 1=QUIT, 2=RESIZE, 3=MOUSE_DOWN, 4=MOUSE_UP, 5=MOUSE_MOVE, 6=MOUSE_WHEEL.
def i32 $ev = gl.PollEvent();
if ($ev == 1) { // QUIT
gl.Close();
} elseif ($ev == 6) { // MOUSE_WHEEL
$zoom = $zoom + gl.EventWheelY();
}When you want to react one event at a time in an if/elseif chain and then read the details with the gl.Event* getters.
gl.PollEvents
gl.PollEvents() -> int
Drains all pending SDL events in a single call and returns the number processed. The internal "last event" state reflects the last event in the queue.
This function takes no arguments.
The number of events processed (0 if none were waiting).
while (gl.IsOpen() != 0) {
gl.PollEvents(); // az ablakkezelo valaszkepes marad
// ... rajzolas + gl.SwapBuffers() ...
}At the top of a render loop, when you only need the window to stay responsive and do not need to handle each event individually.
gl.PumpEvents
gl.PumpEvents(callback) -> int
Drains all pending events and invokes the named DominScript callback for each one with a 32-byte event packet (OMGE header). Packet fields: magic "OMGE", version=1, type, button, then little-endian 16-bit X, Y, dx, dy, wheel, width, height. No callback is invoked for NONE events.
| Parameter | Type | Description |
|---|---|---|
| callback | string | The name of the DominScript callback function to invoke (must be non-empty). |
The number of events handed to the callback.
callback $OnGlEvent(blob $packet) {
// a $packet[5] bajt az esemenytipus
return 0;
}
gl.PumpEvents("OnGlEvent");When you prefer callback-style event dispatch over polling — one function handles every event, with the details in the binary-packed blob.
gl.EventType
gl.EventType() -> int
The type of the most recent event processed by gl.PollEvent / gl.PollEvents.
This function takes no arguments.
0=NONE, 1=QUIT, 2=RESIZE, 3=MOUSE_DOWN, 4=MOUSE_UP, 5=MOUSE_MOVE, 6=MOUSE_WHEEL.
if (gl.EventType() == 3) { /* MOUSE_DOWN */ }The starting point of getter-style event reading: first the type, then the fields relevant to that type.
gl.EventX
gl.EventX() -> int
The mouse X coordinate of the most recent event, in window client pixels.
This function takes no arguments.
X coordinate in pixels.
def i32 $mx = gl.EventX();
Reading the cursor position on MOUSE_DOWN/UP/MOVE events.
gl.EventY
gl.EventY() -> int
The mouse Y coordinate of the most recent event, in window client pixels.
This function takes no arguments.
Y coordinate in pixels.
def i32 $my = gl.EventY();
Reading the cursor position on MOUSE_DOWN/UP/MOVE events.
gl.EventDx
gl.EventDx() -> int
The relative mouse motion in X for the most recent MOUSE_MOVE event, in pixels.
This function takes no arguments.
X motion delta (signed).
$angleY = $angleY + gl.EventDx() * 0.5; // huzas-forgatasFor drag-to-rotate cameras: dx/dy give the amount of mouse movement directly.
gl.EventDy
gl.EventDy() -> int
The relative mouse motion in Y for the most recent MOUSE_MOVE event, in pixels.
This function takes no arguments.
Y motion delta (signed).
$angleX = $angleX + gl.EventDy() * 0.5;
For the vertical component of a drag-to-rotate camera.
gl.EventButton
gl.EventButton() -> int
The mouse button for a MOUSE_DOWN/MOUSE_UP event (SDL convention: 1=left, 2=middle, 3=right).
This function takes no arguments.
The button id (1=left, 2=middle, 3=right).
if (gl.EventType() == 3 && gl.EventButton() == 1) { $dragging
= 1; }Distinguishing left/right clicks (e.g. a drag starts with the left button).
gl.EventWheelY
gl.EventWheelY() -> int
The vertical scroll amount for a MOUSE_WHEEL event (positive = up/away).
This function takes no arguments.
The signed scroll amount.
if (gl.EventType() == 6) { $zoom = $zoom - gl.EventWheelY() * 0.2;
}For wheel-controlled zoom.
gl.EventWidth
gl.EventWidth() -> int
The window new client width on a RESIZE event (gl.Open initializes it to the starting width).
This function takes no arguments.
Width in pixels.
if (gl.EventType() == 2) { gl.Viewport(0, 0, gl.EventWidth(),
gl.EventHeight()); }Handling window resize: on a RESIZE event, reset the viewport and projection.
gl.EventHeight
gl.EventHeight() -> int
The window new client height on a RESIZE event (gl.Open initializes it to the starting height).
This function takes no arguments.
Height in pixels.
gl.SetViewportSize(gl.EventWidth(), gl.EventHeight());
Handling window resize together with gl.EventWidth.
gl.SetViewportSize
gl.SetViewportSize(width, height) -> int
Updates the viewport size the plugin keeps track of (used for aspect-ratio math). It does not call glViewport directly — that is gl.Viewport; this maintains the logical size. Width and height must be in the 64..8192 range.
| Parameter | Type | Description |
|---|---|---|
| width | int | The new logical width (64..8192). |
| height | int | The new logical height (64..8192). |
Always 1.
gl.SetViewportSize(1280, 720);
After a window resize, alongside gl.Viewport, so the plugin aspect logic also sees the fresh size.
gl.CreateTextureSlot
gl.CreateTextureSlot() -> int
Allocates a new texture slot and returns its index (0..31). There are 32 slots in total; they identify the texture in gl.UpdateTexture and gl.BindTexture calls. If all slots are used up, it raises a runtime error.
This function takes no arguments.
The allocated slot index (0..31).
def i32 $logoSlot = gl.CreateTextureSlot(); gl.UpdateTexture($logoSlot, $logoFrame);
For managing several distinct textures (e.g. different images on the faces of a cube). Allocate one slot per face.
gl.UpdateTexture
gl.UpdateTexture(textureSlot, framePacket) -> int
Uploads an OMVF-format frame blob into the OpenGL texture of the given slot. The blob has a 64-byte header, magic "OMVF", version=1, format RGBA8 (1) or BGRA8 (2). The operation requires an open window (gl.Open); the slot must be in 0..31.
| Parameter | Type | Description |
|---|---|---|
| textureSlot | int | The slot index returned by gl.CreateTextureSlot (0..31). |
| framePacket | blob | An OMVF-format frame blob (e.g. output of ffmpeg.* or image.*). |
1 on success; 0 (with a runtime error) if there is no open window or the blob is invalid.
def blob $frame = image.Load($ProjectAssetPath);
gl.UpdateTexture($logoSlot, $frame);
gl.BindTexture(0x0DE1, $logoSlot); // GL_TEXTURE_2DWhen you refresh the contents of a slot texture — once for a static image, per frame for video.
gl.CreateVideoTexture
gl.CreateVideoTexture(width, height, format) -> int
A compatibility entry point for the shared video-texture path. In the current thin adapter it does not pre-allocate a separate GL object (the actual upload is done by gl.UpdateVideoTexture from the frame dimensions); the call simply returns 1. The three arguments keep the calling convention uniform.
| Parameter | Type | Description |
|---|---|---|
| width | int | The video frame width (informational on the compatibility path). |
| height | int | The video frame height (informational on the compatibility path). |
| format | string | The pixel format name (e.g. "RGBA8" or "BGRA8"). |
Always 1.
gl.CreateVideoTexture(1280, 720, "BGRA8");
When the code follows the old video-texture convention; the actual per-frame upload is gl.UpdateVideoTexture.
gl.UpdateVideoTexture
gl.UpdateVideoTexture(framePacket) -> int
Uploads an OMVF frame blob into the shared (single) video texture — the simplified, single-texture counterpart of the slot-based gl.UpdateTexture. Requires an open window; the blob uses the same 64-byte OMVF header.
| Parameter | Type | Description |
|---|---|---|
| framePacket | blob | An OMVF-format frame blob (e.g. output of ffmpeg.DecodeNext). |
1 on success; 0 (with a runtime error) if there is no open window or the blob is invalid.
def blob $frame = ffmpeg.DecodeNext($video); gl.UpdateVideoTexture($frame);
When displaying a single video stream where multiple separate slots are not needed.
gl.FrameInfo
gl.FrameInfo(framePacket) -> string
Reads the header of an OMVF frame blob and returns a human-readable, space-separated summary string: version, width, height, stride, format (RGBA8/BGRA8), frame index, ptsMs and the pixel-data size. It does not modify any texture — it is purely diagnostic.
| Parameter | Type | Description |
|---|---|---|
| framePacket | blob | An OMVF-format frame blob. |
A string, e.g.: omvf version=1 width=1280 height=720 stride=5120 format=BGRA8 frame=0 ptsMs=0 pixels=3686400
def blob $frame = ffmpeg.DecodeNext($video); os.Println(gl.FrameInfo($frame));
omvf version=1 width=1280 height=720 stride=5120 format=BGRA8 frame=0 ptsMs=0 pixels=3686400
For debugging: you can check the dimensions and format of a decoded frame before uploading it.
Practical notes
What the gl thin adapter is good for
Classic OpenGL fixed-pipeline drawing directly from the script — each verb is one GL entry point.
Building your own geometry, your own matrix setup, your own rendering loop — without high-level demo specifics.
Stable surface for new OpenGL projects: the 43-verb list is clearly bounded and easy to scan.
What it does NOT contain
The gl.* layer is now self-sufficient for low-level tasks: it DOES have window and context opening (gl.Open, gl.Close, gl.IsOpen), an event pump (gl.PollEvent, gl.PumpEvents, gl.EventType, etc.) and texture-slot management (gl.CreateTextureSlot, gl.UpdateTexture). What it intentionally does NOT contain: high-level scene, camera and cube logic, and ready-made drawing routines (DrawCube, DrawFace). These higher-level abstractions lived in the old opengl.* facade, and have moved to the non-official tree (non_official/plugins/opengl_thick_facade) during this separation. If beginner code needs a full scene scaffold, the script-driven demos show how to build higher-level layers from the gl.* primitives.
Context activation pattern
A typical frame looks like this: gl.MakeCurrent -> gl.ClearColor + gl.Clear -> matrix setup (MatrixMode + LoadIdentity + Frustum/Translate/Rotate) -> gl.Begin / Color3f / TexCoord2f / Vertex3f / gl.End sequence -> gl.SwapBuffers -> gl.UnbindCurrent. The context is active between MakeCurrent and UnbindCurrent, and every gl.* call in that range is valid.
Handling GL constants
The thin adapter does not provide named constants — GL_QUADS, GL_PROJECTION, GL_DEPTH_TEST and friends are numeric values from <GL/gl.h>. The script-driven demo stores them in its own const block (const i32 $GL_QUADS = 0x0007; etc.), so the script reads cleanly. You can follow this pattern in your own code.
Error handling
A wrong argument count or type, and an uninitialized OpenGL context are reported by the runtime as a runtime error, and the script stops. Invalid GL constants are silently ignored by OpenGL itself (or set an error code) — the thin adapter does not query that; so in script-driven code it pays to copy constants from a trusted source (well-known GL header).
The sdl multimedia plugin
SDL2-based window handling, drawing, audio, textures, and events — complete function reference