Epok Engine

EPOK RUNTIME

Polygon

polygon.hpp · PSX polygon preparation, clipping and submission

Declarations are extracted from the pinned headers. Examples and general guidance are generated sketches, not verified complete programs; consult the linked source and guides for the actual contract.

Module

PSX polygon preparation, clipping and submission.

Header
polygon.hpp
Include
#include "polygon.hpp"
Stability
Epok runtime API

Include this module

C++ include
#include "polygon.hpp"

Types

Functions and methods

blend_fogPerforms `blend fog` as part of PSX polygon preparation, clipping and submission.Functionblend_vertex_fogPerforms `blend vertex fog` as part of PSX polygon preparation, clipping and submission.FunctionbucketOrdering table bucket from three depths: (za+zb+zc) / (3 << DepthShift), exact for the frustum range without an integer division.Methodclip_fraction16Performs `clip fraction16` as part of PSX polygon preparation, clipping and submission.Functionclip_polygonPerforms `clip polygon` as part of PSX polygon preparation, clipping and submission.Function templateclip_polygon_distancesSutherland-Hodgman against the frustum planes named by `planes` (bit i = plane i of frustum_outcode).Function templatecompact_gpu_safeScreen/depth-only projection is also sufficient for off-screen chunks when every vertex is depth-valid and the complete packet span fits the GPU.Functioncompact_mesh_gpu_safeUnrelated faces in one spatial chunk can span more than the GPU limit even though every submitted triangle fits.Function templatefloor_divFloor division for a positive divisor, matching the GTE's arithmetic shift.Functionfog_amountLinear fog: 0 before start, 4096 at or beyond end.Functionmodulate_channel(c * 128 + 127) / 255 for c in 0..255, exact without a division.Functionmodulate_colorPerforms `modulate color` as part of PSX polygon preparation, clipping and submission.Functionoperator[]Performs `operator []` as part of PSX polygon preparation, clipping and submission.MethodoutcodePerforms `outcode` as part of PSX polygon preparation, clipping and submission.Methodpack_colorPerforms `pack color` as part of PSX polygon preparation, clipping and submission.Functionpacket_colorPerforms `packet color` as part of PSX polygon preparation, clipping and submission.Functionproject_cpuCPU perspective for clipped or fallback vertices, rounding like the GTE so mixed triangles share edges.Function templatescale_channela * b / 255 for 0..255 inputs, exact.Functionscreen_areaPerforms `screen area` as part of PSX polygon preparation, clipping and submission.Function templatescreen_backfaceScreen area sign in the GPU's coordinate system; zero for degenerate triangles.Functiontint_colorPerforms `tint color` as part of PSX polygon preparation, clipping and submission.Function

Fields, variables and values

cameraExposes `camera` on `epok::CompactProjectedVertex` for PSX polygon preparation, clipping and submission.Fieldcameracamera space, CameraUnits scaleFieldclut16already shifted into the high halfwordFieldcolorExposes `color` on `epok::ClipVertex` for PSX polygon preparation, clipping and submission.FieldcommandGPU command byte with transparency bitFielddepth_biasExposes `depth_bias` on `epok::QuadPacket` for PSX polygon preparation, clipping and submission.FieldfarExposes `far` on `epok::CameraUnits` for PSX polygon preparation, clipping and submission.Variablefinal_colorpacked 0x00BBGGRR; modulated (128 = 1.0) when texturedFieldfogQ12 fog amount, 0 when nearer than the fog startFieldgpu_colorsshaded/clip values already use the PSX packet domainFieldhas_screenExposes `has_screen` on `epok::ClipVertex` for PSX polygon preparation, clipping and submission.FieldnearExposes `near` on `epok::CameraUnits` for PSX polygon preparation, clipping and submission.VariableoutcodeExposes `outcode` on `epok::ProjectedVertex` for PSX polygon preparation, clipping and submission.FieldpExposes `p` on `epok::ClipVertex` for PSX polygon preparation, clipping and submission.FieldscreenAn input corner may keep its already projected screen position; intersections never have one and are projected after clipping.FieldscreenExposes `screen` on `epok::CompactProjectedVertex` for PSX polygon preparation, clipping and submission.Fieldscreenvalid when visibleFieldshadedpacked fogged 0..255 colors kept for the clipperFieldtexturedExposes `textured` on `epok::QuadPacket` for PSX polygon preparation, clipping and submission.Fieldtpage16already shifted into the high halfwordFielduv16.16 texture pixelsFielduvu | v << 8FieldvalueExposes `value` on `epok::CompactProjectedVertex::Depth` for PSX polygon preparation, clipping and submission.FieldvisibleExposes `visible` on `epok::ProjectedVertex` for PSX polygon preparation, clipping and submission.Field