/* tex3d.h - a small 3D library for the GXT120P (MGA-1164SG): textured, lit, Z-buffered * triangles at any size up to 640x480x16, and frame readback through IDUMP. * Claude Opus 5.5, 2026-10-14. Drawing code from ../texmap/texmap.c. X must be stopped. */ #ifndef TEX3D_H #define TEX3D_H typedef struct { double x, y, z, r, g, b, s, t, q; } t3_vtx; /* s, t, q already divided by w */ /* flags for t3_bind */ #define T3_PERSP 1 /* perspective correction (else affine) */ #define T3_MODUL 2 /* multiply texels by the vertex colour */ #define T3_CLAMP 4 /* clamp instead of repeat */ int t3_open(int w, int h); /* take the card; 0 = ok */ void t3_close(void); void t3_clear(unsigned int rgb565); /* colour and Z */ int t3_texture(const unsigned short *tex, int size); /* upload size x size 565; returns handle */ void t3_bind(int tex, int flags); void t3_tri(t3_vtx a, t3_vtx b, t3_vtx c); /* integer x, y; textured, Z-tested (less) */ int t3_finish(void); /* wait for the engine; 0 = ok */ void t3_read(unsigned int *dst); /* IDUMP the frame: w*h 16-bit pixels, native order, two per word, first pixel in the high half */ extern int t3_nodraw; /* 1: compute everything, write no registers */ #endif