11 i_video: Video Mode & Frame Rendering
This tour covers video mode and frame rendering in linuxdoomβs i_video
module.
It includes the interface in i_video.h
and the X11 implementation in i_video.c
, covering SHM setup, palette handling, frame updates, screen reading, and event polling.
11.0.1 π File: i_video.h
(lines 37β46)
Main video interface:
- Initialize/shutdown graphics
- Set palette
- Update frames
11.0.2 π File: i_video.h
(lines 49β54)
Additional routines: - I_WaitVBL
: wait for vertical retrace
- I_ReadScreen
: copy screen buffer
- I_BeginRead
, I_EndRead
: stubbed framebuffer reads
11.0.3 π File: i_video.c
(lines 692β702)
I_InitGraphics
sets up scaling flags, signal handlers, and computes window size.
11.0.4 π File: i_video.c
(lines 775β783)
Checks for MITβSHM extension and a local X connection before enabling shared memory rendering.
11.0.5 π File: i_video.c
(lines 855β863)
Creates a shared memory XImage
using XShmCreateImage
.
11.0.6 π File: i_video.c
(lines 887β893)
Attaches the SHM segment to the process and to the X server.
11.0.7 π File: i_video.c
(lines 896β903)
Fallback to XCreateImage
with malloc
if SHM is unavailable.
11.0.8 π File: i_video.c
(lines 910β914)
Assigns screen buffer to screens[0]
or allocates a 320Γ200 buffer if scaling is enabled.
11.0.9 π File: i_video.c
(lines 164β176)
I_ShutdownGraphics
detaches and unmaps shared memory, nulls out image data.
11.0.10 π File: i_video.c
(lines 582β585)
I_SetPalette
updates colormap by calling UploadNewPalette
.
11.0.11 π File: i_video.c
(lines 551β556)
Initializes the XColor
array with pixel indices and RGB flags.
11.0.12 π File: i_video.c
(lines 563β571)
Gamma-corrects and stores the full palette via XStoreColors
.
11.0.13 π File: i_video.c
(lines 342β347)
I_UpdateNoBlit
is a stub (no-op) in X11 β for platforms with buffer flips.
11.0.14 π File: i_video.c
(lines 483β492)
I_FinishUpdate
uses XShmPutImage
and waits for ShmCompletion
event if using SHM.
11.0.15 π File: i_video.c
(lines 507β514)
Otherwise, uses XPutImage
and XSync
to render frame without SHM.
11.0.16 π File: i_system.c
(lines 126β136)
I_WaitVBL
waits approximately count / 70
seconds using usleep
.
11.0.17 π File: i_video.c
(lines 527β530)
I_ReadScreen
copies the current frame buffer to the given array.
11.0.18 π File: i_system.c
(lines 139β146)
I_BeginRead
and I_EndRead
are stubbed on X11 β placeholders for framebuffer locking.
11.0.19 π File: i_video.c
(lines 315β323)
I_StartTic
processes all pending X events and re-centers mouse if needed.
And that was it.