MiniDoom

src/r_main.ml

Builds view/projection tables, derives interpolated camera state, and orchestrates software or OpenGL player-view rendering.

Package
(global)
Reachable
Yes

Imports

Declarations

_R_Abs

inline function _R_Abs(x)

Converts an arbitrary numeric value to an integer and returns its non-negative magnitude.

ParameterTypeDefaultDescription
xdynamic—Horizontal map- or screen-space coordinate.

View source

_R_AngNorm

inline function _R_AngNorm(a)

Normalizes an angle or numeric input to Doom's unsigned 32-bit binary-angle domain.

ParameterTypeDefaultDescription
adynamic—First input operand.

View source

_R_AngSub

inline function _R_AngSub(a, b)

Subtracts two binary angles with unsigned 32-bit wraparound.

ParameterTypeDefaultDescription
adynamic—First input operand.
bdynamic—Second input operand.

View source

_R_ColorMapAt

inline function _R_ColorMapAt(level)

Returns one clamped 256-entry lighting colormap, or a black fallback when COLORMAP data is missing.

ParameterTypeDefaultDescription
leveldynamic—Level value supplied to `_R_ColorMapAt`.

View source

_R_FineSineAt

inline function _R_FineSineAt(angle)

Samples the wrapped fine-sine table for a binary angle, returning zero if tables are unavailable.

ParameterTypeDefaultDescription
angledynamic—Doom binary-angle measurement.

View source

_R_HasSignBit

inline function _R_HasSignBit(v)

Tests the high bit of a normalized binary angle or wrapped 32-bit delta.

ParameterTypeDefaultDescription
vdynamic—Value consumed by the operation.

View source

_R_IDiv

inline function _R_IDiv(a, b)

Coerces numeric operands and returns their signed quotient truncated toward zero, using zero for a zero divisor.

ParameterTypeDefaultDescription
adynamic—First input operand.
bdynamic—Second input operand.

View source

_R_InitTextureMapping

function _R_InitTextureMapping()

Builds inverse screen-column/binary-angle tables from the current projection and establishes the horizontal clip angle.

View source

_r_interp_cur_angle

_r_interp_cur_angle

Tracks the mutable r interp cur angle value used by the r main subsystem.

View source

_r_interp_cur_x

_r_interp_cur_x

Tracks the mutable r interp cur x value used by the r main subsystem.

View source

_r_interp_cur_y

_r_interp_cur_y

Tracks the mutable r interp cur y value used by the r main subsystem.

View source

_r_interp_cur_z

_r_interp_cur_z

Tracks the mutable r interp cur z value used by the r main subsystem.

View source

_r_interp_last_tic

_r_interp_last_tic

Tracks the mutable r interp last tic value used by the r main subsystem.

View source

_r_interp_player

_r_interp_player

Holds the optional r interp player resource used by the r main subsystem.

View source

_r_interp_prev_angle

_r_interp_prev_angle

Tracks the mutable r interp prev angle value used by the r main subsystem.

View source

_r_interp_prev_x

_r_interp_prev_x

Tracks the mutable r interp prev x value used by the r main subsystem.

View source

_r_interp_prev_y

_r_interp_prev_y

Tracks the mutable r interp prev y value used by the r main subsystem.

View source

_r_interp_prev_z

_r_interp_prev_z

Tracks the mutable r interp prev z value used by the r main subsystem.

View source

_R_IsSeq

inline function _R_IsSeq(v)

Recognizes the array and list containers accepted by renderer lookup tables.

ParameterTypeDefaultDescription
vdynamic—Value consumed by the operation.

View source

_R_LerpAngle

inline function _R_LerpAngle(a, b, frac)

Interpolates along the shortest wrapped path between two 32-bit binary angles.

ParameterTypeDefaultDescription
adynamic—First input operand.
bdynamic—Second input operand.
fracdynamic—Frac value supplied to `_R_LerpAngle`.

View source

_R_LerpS32

inline function _R_LerpS32(a, b, frac)

Linearly interpolates signed 32-bit coordinates and preserves signed wrap semantics at the result.

ParameterTypeDefaultDescription
adynamic—First input operand.
bdynamic—Second input operand.
fracdynamic—Frac value supplied to `_R_LerpS32`.

View source

_r_prof_bsp_ms

_r_prof_bsp_ms

Tracks the mutable r prof bsp ms value used by the r main subsystem.

View source

_r_prof_clear_ms

_r_prof_clear_ms

Tracks the mutable r prof clear ms value used by the r main subsystem.

View source

_r_prof_enabled

_r_prof_enabled

Tracks whether r prof enabled is active in the r main subsystem.

View source

_r_prof_frames

_r_prof_frames

Tracks the mutable r prof frames value used by the r main subsystem.

View source

_r_prof_masked_ms

_r_prof_masked_ms

Tracks the mutable r prof masked ms value used by the r main subsystem.

View source

_r_prof_planes_ms

_r_prof_planes_ms

Tracks the mutable r prof planes ms value used by the r main subsystem.

View source

_r_prof_t0

_r_prof_t0

Tracks the mutable r prof t0 value used by the r main subsystem.

View source

_R_ProfileFlushMaybe

function _R_ProfileFlushMaybe()

Once per second, prints accumulated pipeline counters and resets renderer, BSP, and draw profiling windows.

View source

_R_RebuildScaleLight

function _R_RebuildScaleLight()

Recomputes scale-indexed wall colormaps for the active view width and detail shift.

View source

_R_RenderOpenGLPlayerView

function _R_RenderOpenGLPlayerView(player)

Attempts to draw the current player view with the active OpenGL renderer.

ParameterTypeDefaultDescription
playerdynamic—Player state affected by the operation.

View source

_R_S32

function _R_S32(v)

Coerces a numeric value and reinterprets its low 32 bits as a signed integer.

ParameterTypeDefaultDescription
vdynamic—Value consumed by the operation.

View source

_R_SetupFrame

function _R_SetupFrame(player)

Derives the camera from player state, interpolates uncapped frames, selects fixed lighting, and advances frame validity counters.

ParameterTypeDefaultDescription
playerdynamic—Player state affected by the operation.

View source

_R_TanToAngle

inline function _R_TanToAngle(num, den)

Converts a non-negative slope ratio into a clamped lookup-table binary angle.

ParameterTypeDefaultDescription
numdynamic—Index identifying the requested item.
dendynamic—Den value supplied to `_R_TanToAngle`.

View source

_R_TimeMs

inline function _R_TimeMs()

Returns the platform tick counter as an integer millisecond timestamp for render profiling.

View source

_R_ToFrac

inline function _R_ToFrac(v)

Converts the render interpolation control to a scalar clamped to [0,1], defaulting invalid inputs to one.

ParameterTypeDefaultDescription
vdynamic—Value consumed by the operation.

View source

_R_ToIntOr

inline function _R_ToIntOr(v, fallback)

Coerces numbers and numeric values to a truncation-toward-zero integer, returning fallback on failure.

ParameterTypeDefaultDescription
vdynamic—Value consumed by the operation.
fallbackdynamic—Value returned when the requested conversion or lookup is unavailable.

View source

basecolfunc

basecolfunc

Holds the optional basecolfunc resource used by the r main subsystem.

View source

centerx

centerx

Tracks the mutable centerx value used by the r main subsystem.

View source

centerxfrac

centerxfrac

Tracks the mutable centerxfrac value used by the r main subsystem.

View source

centery

centery

Tracks the mutable centery value used by the r main subsystem.

View source

centeryfrac

centeryfrac

Tracks the mutable centeryfrac value used by the r main subsystem.

View source

colfunc

colfunc

Holds the optional colfunc resource used by the r main subsystem.

View source

detailshift

detailshift

Tracks the mutable detailshift value used by the r main subsystem.

View source

extralight

extralight

Tracks the mutable extralight value used by the r main subsystem.

View source

FIELDOFVIEW

const FIELDOFVIEW = 2048

Defines fieldofview for the r main subsystem.

View source

fixedcolormap

fixedcolormap

Holds the optional fixedcolormap resource used by the r main subsystem.

View source

framecount

framecount

Tracks the mutable framecount value used by the r main subsystem.

View source

fuzzcolfunc

fuzzcolfunc

Holds the optional fuzzcolfunc resource used by the r main subsystem.

View source

LIGHTLEVELS

const LIGHTLEVELS = 16

Defines lightlevels for the r main subsystem.

View source

LIGHTSCALESHIFT

const LIGHTSCALESHIFT = 12

Defines lightscaleshift for the r main subsystem.

View source

LIGHTSEGSHIFT

const LIGHTSEGSHIFT = 4

Defines lightsegshift for the r main subsystem.

View source

LIGHTZSHIFT

const LIGHTZSHIFT = 20

Defines lightzshift for the r main subsystem.

View source

linecount

linecount

Tracks the mutable linecount value used by the r main subsystem.

View source

loopcount

loopcount

Tracks the mutable loopcount value used by the r main subsystem.

View source

MAXLIGHTSCALE

const MAXLIGHTSCALE = 48

Defines the maximum maxlightscale accepted by the r main subsystem.

View source

MAXLIGHTZ

const MAXLIGHTZ = 128

Defines the maximum maxlightz accepted by the r main subsystem.

View source

NUMCOLORMAPS

const NUMCOLORMAPS = 32

Defines the numcolormaps count used by the r main subsystem.

View source

projection

projection

Tracks the mutable projection value used by the r main subsystem.

View source

R_AddPointToBox

function R_AddPointToBox(x, y, box)

Expands a four-entry BOXLEFT/RIGHT/BOTTOM/TOP bounds array to include a point.

ParameterTypeDefaultDescription
xdynamic—Horizontal map- or screen-space coordinate.
ydynamic—Vertical map- or screen-space coordinate.
boxdynamic—Bounding-box array to read or update.

View source

R_ExecuteSetViewSize

function R_ExecuteSetViewSize()

Applies the deferred block/detail request only when a view-size rebuild is pending.

View source

R_Init

function R_Init()

Initializes render data, geometry/light tables, view sizing, translations, and optional profiling hooks.

View source

R_InitLightTables

function R_InitLightTables()

Builds distance-indexed, scale-indexed, and fixed-colormap lighting lookup matrices.

View source

R_InitPointToAngle

function R_InitPointToAngle()

Ensures the trigonometric tables required by point-to-angle calculations are populated.

View source

R_InitTables

function R_InitTables()

Initializes the shared fine-angle, tangent, sine, and slope lookup tables.

View source

R_InitTextureMapping

function R_InitTextureMapping()

Rebuilds the public view-column-to-angle and angle-to-column mapping tables.

View source

R_PointInSubsector

function R_PointInSubsector(x, y)

Walks the BSP from its root to locate the leaf subsector containing a world coordinate.

ParameterTypeDefaultDescription
xdynamic—Horizontal map- or screen-space coordinate.
ydynamic—Vertical map- or screen-space coordinate.

View source

R_PointOnSegSide

inline function R_PointOnSegSide(x, y, seg)

Classifies a fixed-point position against an oriented seg for clipping and sprite-side decisions.

ParameterTypeDefaultDescription
xdynamic—Horizontal map- or screen-space coordinate.
ydynamic—Vertical map- or screen-space coordinate.
segdynamic—Seg value supplied to `R_PointOnSegSide`.

View source

R_PointOnSide

inline function R_PointOnSide(x, y, node)

Classifies a fixed-point position against a BSP partition, using axis fast paths and overflow-safe sign tests.

ParameterTypeDefaultDescription
xdynamic—Horizontal map- or screen-space coordinate.
ydynamic—Vertical map- or screen-space coordinate.
nodedynamic—Node value supplied to `R_PointOnSide`.

View source

R_PointToAngle

function R_PointToAngle(x, y)

Computes the wrapped binary angle from the current view origin to a world point via octant slope lookup.

ParameterTypeDefaultDescription
xdynamic—Horizontal map- or screen-space coordinate.
ydynamic—Vertical map- or screen-space coordinate.

View source

R_PointToAngle2

inline function R_PointToAngle2(x1, y1, x2, y2)

Computes the binary angle between arbitrary endpoints while restoring the renderer's global view origin afterward.

ParameterTypeDefaultDescription
x1dynamic—Horizontal coordinate of the first endpoint.
y1dynamic—Vertical coordinate of the first endpoint.
x2dynamic—Horizontal coordinate of the second endpoint.
y2dynamic—Vertical coordinate of the second endpoint.

View source

R_PointToDist

inline function R_PointToDist(x, y)

Computes fixed-point planar distance from the view origin using slope and sine lookup tables.

ParameterTypeDefaultDescription
xdynamic—Horizontal map- or screen-space coordinate.
ydynamic—Vertical map- or screen-space coordinate.

View source

R_RenderClassicPlayerView

function R_RenderClassicPlayerView(player)

Draws the current player view with the classic CPU renderer only.

ParameterTypeDefaultDescription
playerdynamic—Player state affected by the operation.

View source

R_RenderPlayerView

function R_RenderPlayerView(player)

Dispatches the player view to exactly one active renderer.

ParameterTypeDefaultDescription
playerdynamic—Player state affected by the operation.

View source

R_ResetViewInterpolation

function R_ResetViewInterpolation()

Discards the previous camera sample so a spawn or level transition cannot interpolate from stale world coordinates.

View source

R_ScaleFromGlobalAngle

function R_ScaleFromGlobalAngle(visangle)

Derives the perspective scale for a wall column and clamps it to Doom's supported fixed-point range.

ParameterTypeDefaultDescription
visangledynamic—Visangle value supplied to `R_ScaleFromGlobalAngle`.

View source

R_SetupFrame

function R_SetupFrame(player)

Public entry point that derives view position, angle, lighting, and interpolation state for one player frame.

ParameterTypeDefaultDescription
playerdynamic—Player state affected by the operation.

View source

R_SetViewSize

function R_SetViewSize(blocks, detail)

Clamps and applies a view-block request, rebuilding projection, draw callbacks, buffers, sprite scale, and light tables.

ParameterTypeDefaultDescription
blocksdynamic—Blocks value supplied to `R_SetViewSize`.
detaildynamic—Detail value supplied to `R_SetViewSize`.

View source

scalelight

scalelight

Holds the optional scalelight resource used by the r main subsystem.

View source

scalelightfixed

scalelightfixed

Holds the optional scalelightfixed resource used by the r main subsystem.

View source

setblocks

setblocks

Tracks the mutable setblocks value used by the r main subsystem.

View source

setdetail

setdetail

Tracks the mutable setdetail value used by the r main subsystem.

View source

setsizeneeded

setsizeneeded

Tracks whether setsizeneeded is active in the r main subsystem.

View source

spanfunc

spanfunc

Holds the optional spanfunc resource used by the r main subsystem.

View source

sscount

sscount

Tracks the mutable sscount value used by the r main subsystem.

View source

transcolfunc

transcolfunc

Holds the optional transcolfunc resource used by the r main subsystem.

View source

validcount

validcount

Tracks the mutable validcount value used by the r main subsystem.

View source

viewangleoffset

viewangleoffset

Tracks the mutable viewangleoffset value used by the r main subsystem.

View source

viewcos

viewcos

Tracks the mutable viewcos value used by the r main subsystem.

View source

viewheight

viewheight

Tracks the mutable viewheight value used by the r main subsystem.

View source

viewsin

viewsin

Tracks the mutable viewsin value used by the r main subsystem.

View source

viewwidth

viewwidth

Tracks the mutable viewwidth value used by the r main subsystem.

View source

viewwindowx

viewwindowx

Tracks the mutable viewwindowx value used by the r main subsystem.

View source

viewwindowy

viewwindowy

Tracks the mutable viewwindowy value used by the r main subsystem.

View source

zlight

zlight

Holds the optional zlight resource used by the r main subsystem.

View source