2 RetroRay - integrated standalone vintage modeller/renderer
3 Copyright (C) 2023 John Tsiombikas <nuclear@mutantstargoat.com>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>.
27 /* modelview, projection, texture */
28 #define NUM_MATRICES 3
30 typedef float gaw_matrix[16];
33 #define MAX_TEXTURES 256
34 #define MAX_COMPILED 256
36 #define IMM_VBUF_SIZE 256
38 enum {LT_POS, LT_DIR};
54 float *varr, *narr, *uvarr, *carr; /* darr */
60 uint32_t savopt[STACK_SIZE];
66 const float *varr, *narr, *uvarr;
68 gaw_matrix mat[NUM_MATRICES][STACK_SIZE];
69 int mtop[NUM_MATRICES];
75 struct light lt[MAX_LIGHTS];
88 const float *vertex_ptr, *normal_ptr, *texcoord_ptr, *color_ptr;
89 int vertex_nelem, texcoord_nelem, color_nelem;
90 int vertex_stride, normal_stride, texcoord_stride, color_stride;
96 int imm_numv, imm_pcount;
97 struct vertex imm_curv;
99 struct vertex imm_vbuf[IMM_VBUF_SIZE];
100 float imm_cbuf[IMM_VBUF_SIZE * 4];
104 int textypes[MAX_TEXTURES];
106 /* compiled geometries */
108 struct comp_geom comp[MAX_COMPILED];
111 extern struct gaw_state *gaw_state;
115 void gaw_swtnl_reset(void);
116 void gaw_swtnl_init(void);
117 void gaw_swtnl_destroy(void);
119 void gaw_swtnl_enable(int what);
120 void gaw_swtnl_disable(int what);
122 void gaw_swtnl_color_mask(int rmask, int gmask, int bmask, int amask);
123 void gaw_swtnl_depth_mask(int mask);
125 void gaw_swtnl_tex1d(int ifmt, int xsz, int fmt, void *pix);
126 void gaw_swtnl_tex2d(int ifmt, int xsz, int ysz, int fmt, void *pix);
127 void gaw_swtnl_subtex2d(int lvl, int x, int y, int xsz, int ysz, int fmt, void *pix);
129 void gaw_swtnl_drawprim(int prim, struct vertex *v, int vnum);
132 #if defined(__i386__) || defined(__386__) || defined(MSDOS)
135 #if (__STDC_VERSION__ >= 199901) || defined(__GNUC__)
136 #define INLINE inline
138 #define INLINE __inline
142 /* fast conversion of double -> 32bit int
144 * - http://chrishecker.com/images/f/fb/Gdmfp.pdf
145 * - http://stereopsis.com/FPU.html#convert
147 static INLINE int32_t cround64(double val)
149 val += 6755399441055744.0;
150 return *(int32_t*)&val;
153 #define cround64(x) ((int32_t)(x))
157 #endif /* GAWSWTNL_H_ */