Files
TeslaRel410/emulator/render-bridge/chase_render.py
T
CydandClaude Fable 5 0f5b2e28da Renderer: vendor live-bridge scripts; GPU backend unblocked (60fps)
- emulator/render-bridge/: the pod->Dave's-renderer live bridge (rescued
  from session scratchpad): live_bridge.py (first-person cam from the 0x1f
  pose, arrow-key eye-height trim), fp/chase offline renders, fifobridge,
  diagnostics, gauge_arena[_sound].conf, and launch_pod.ps1 (one-command
  pod+bridge restart: pentapus VPX_EXPLODE + AWE32 sound + GL bridge).
- _backend.py: renderer selection -- vrview_gl.GLRenderer (moderngl) by
  default, VRVIEW_SOFT=1 for the software reference; backend-agnostic
  frame save via last_frame.
- GPU backend runs on side-by-side CPython 3.13 (moderngl/glcontext cp313
  wheels; no MSVC needed): 63fps headless / 60.7 windowed vs 21fps software
  on the same scene, and the GL path also draws the vertex-alpha cloud dome.
- vrview.py: VRVIEW_GAMMA env selects DAC gamma (1.25 live-renderer legacy
  vs 1.7 per the original GAMMA.C) for A/B against the real pod.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 13:34:02 -05:00

32 lines
1.2 KiB
Python

import os, sys, struct
os.environ['VRVIEW_CHASE'] = sys.argv[3] if len(sys.argv) > 3 else '2'
os.environ.setdefault('SDL_VIDEODRIVER', 'dummy')
from _backend import pick_renderer, save_frame
from vrboard import VirtualBoard, Msg, A
Renderer, backend = pick_renderer()
data = open(sys.argv[1], 'rb').read()
board = VirtualBoard()
off = 0
while off + 8 <= len(data):
if data[off:off + 4] != b'VPXM':
off += 1; continue
ln = struct.unpack_from('<I', data, off + 4)[0]
body = data[off + 8:off + 8 + ln]; off += 8 + ln
if len(body) >= 4:
a = struct.unpack_from('<I', body, 0)[0]
if a < 0x100:
try: board.handle(Msg(False, 0xff, a, body[4:]))
except Exception: pass
r = Renderer(w=832, h=512)
r.cache.maybe_rebuild(board)
c = r.cache
# how many geometries got a texture bound?
bound = sum(1 for inst in c.instances for g in inst['geoms'] if g in c.geom_tex)
tot = sum(len(inst['geoms']) for inst in c.instances)
print(f"instances={len(c.instances)} geoms_total={tot} geoms_textured={bound} "
f"geom_tex={len(c.geom_tex)} geom_mtl={len(c.geom_mtl)} "
f"ambient={c.ambient.round(2).tolist()} dirlights={len(c.dirlights)}")
r.draw(board)
save_frame(r, sys.argv[2])
print("wrote", sys.argv[2], f"[{backend}]")