03 — RGBA on the screen

Tutorials 01 and 02 stayed headless. Now we open a window and show the video: borrow each decoded frame as RGBA, upload it to an OpenGL texture, and draw it on a fullscreen quad. This is the “easy route” — the CPU converts to RGBA inside the module and you hand the bytes straight to glTexSubImage2D.

The program

examples/play_rgba_gl.das is the whole windowed player. The video-specific part is tiny — open, then each frame get_data the RGBA bytes and upload them:

        // Borrow the decoded RGBA pixels (valid only in the block) and upload.
        player |> get_data() $(rgb : array<uint8>#) {
            glBindTexture(GL_TEXTURE_2D, texture)
            glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, vw, vh, GL_RGBA, GL_UNSIGNED_BYTE, unsafe(addr(rgb[0])))
        }

Everything else is ordinary GLFW + OpenGL setup: one GL_RGBA8 texture, a fullscreen quad, and a vsync-paced loop that decodes a frame, uploads it, and draws. It loops by default (--noloop to play once) and takes a clargs CLI (--video / --scale / --max-frames / --shot).

Run it

It needs a display, so run it by hand (not in CI):

cd <dasVideo>
daslang -load_module . examples/play_rgba_gl.das -- \
    --video tutorials/03_rgba_gl/narration.mpg

That plays the clip embedded above — Emma walking through this very tutorial — through the RGBA path. Drop --video to play the built-in test pattern instead.

Next

04 — YUV on the GPU does the same thing the fast way: skip the CPU conversion, borrow the native YUV planes, and convert on the GPU.