integrating software renderer
[retroray] / src / gaw / gaw.h
1 /*
2 RetroRay - integrated standalone vintage modeller/renderer
3 Copyright (C) 2023  John Tsiombikas <nuclear@mutantstargoat.com>
4
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.
9
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.
14
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/>.
17 */
18 #ifndef GRAPHICS_API_WRAPPER_H_
19 #define GRAPHICS_API_WRAPPER_H_
20
21 enum {
22         GAW_COLORBUF    = 1,
23         GAW_DEPTHBUF    = 2,
24         GAW_STENCILBUF  = 4
25 };
26
27 enum {
28         GAW_POINTS,
29         GAW_LINES,
30         GAW_TRIANGLES,
31         GAW_QUADS,
32         GAW_QUAD_STRIP
33 };
34
35 enum {
36         GAW_DIFFUSE,
37         GAW_SPECULAR,
38         GAW_SHININESS,
39         GAW_EMISSION
40 };
41
42 enum {
43         GAW_MODELVIEW,
44         GAW_PROJECTION,
45         GAW_TEXTURE
46 };
47
48 enum {
49         GAW_CULL_FACE,
50         GAW_DEPTH_TEST,
51         GAW_ALPHA_TEST,
52         GAW_BLEND,
53         GAW_FOG,
54         GAW_DITHER,
55         GAW_LIGHTING,
56         GAW_LIGHT0,
57         GAW_LIGHT1,
58         GAW_LIGHT2,
59         GAW_LIGHT3,
60         GAW_TEXTURE_1D,
61         GAW_TEXTURE_2D
62 };
63
64 enum {
65         GAW_NEVER,
66         GAW_LESS,
67         GAW_EQUAL,
68         GAW_LEQUAL,
69         GAW_GREATER,
70         GAW_NOTEQUAL,
71         GAW_GEQUAL,
72         GAW_ALWAYS
73 };
74
75 enum {
76         GAW_ZERO,
77         GAW_ONE,
78         GAW_SRC_ALPHA,
79         GAW_ONE_MINUS_SRC_ALPHA
80 };
81
82 enum {
83         GAW_LUMINANCE,
84         GAW_RGB,
85         GAW_RGBA
86 };
87
88 enum {
89         GAW_NEAREST,
90         GAW_BILINEAR,
91         GAW_TRILINEAR
92 };
93
94 enum {
95         GAW_REPEAT,
96         GAW_CLAMP
97 };
98
99 void gaw_viewport(int x, int y, int w, int h);
100
101 void gaw_matrix_mode(int mode);
102 void gaw_load_identity(void);
103 void gaw_load_matrix(const float *m);
104 void gaw_mult_matrix(const float *m);
105 void gaw_push_matrix(void);
106 void gaw_pop_matrix(void);
107 void gaw_get_modelview(float *m);
108 void gaw_get_projection(float *m);
109
110 void gaw_translate(float x, float y, float z);
111 void gaw_rotate(float angle, float x, float y, float z);
112 void gaw_scale(float sx, float sy, float sz);
113 void gaw_ortho(float l, float r, float b, float t, float n, float f);
114 void gaw_frustum(float l, float r, float b, float t, float n, float f);
115 void gaw_perspective(float vfov, float aspect, float znear, float zfar);
116
117 void gaw_save(void);
118 void gaw_restore(void);
119 void gaw_enable(int st);
120 void gaw_disable(int st);
121
122 void gaw_depth_func(int func);
123 void gaw_blend_func(int src, int dest);
124 void gaw_alpha_func(int func, float ref);
125
126 void gaw_clear_color(float r, float g, float b, float a);
127 void gaw_clear(unsigned int flags);
128 void gaw_depth_mask(int mask);
129
130 void gaw_vertex_array(int nelem, int stride, const void *ptr);
131 void gaw_normal_array(int stride, const void *ptr);
132 void gaw_texcoord_array(int nelem, int stride, const void *ptr);
133 void gaw_color_array(int nelem, int stride, const void *ptr);
134 void gaw_draw(int prim, int nverts);
135 void gaw_draw_indexed(int prim, const unsigned int *idxarr, int nidx);
136
137 void gaw_begin(int prim);
138 void gaw_end(void);
139 void gaw_color3f(float r, float g, float b);
140 void gaw_color4f(float r, float g, float b, float a);
141 void gaw_color3ub(int r, int g, int b);
142 void gaw_normal(float x, float y, float z);
143 void gaw_texcoord1f(float u);
144 void gaw_texcoord2f(float u, float v);
145 void gaw_vertex2f(float x, float y);
146 void gaw_vertex3f(float x, float y, float z);
147 void gaw_vertex4f(float x, float y, float z, float w);
148
149 void gaw_rect(float x1, float y1, float x2, float y2);
150
151 void gaw_pointsize(float sz);
152 void gaw_linewidth(float w);
153
154 int gaw_compile_begin(void);
155 void gaw_compile_end(void);
156 void gaw_draw_compiled(int id);
157 void gaw_free_compiled(int id);
158
159 void gaw_mtl_diffuse(float r, float g, float b, float a);
160 void gaw_mtl_specular(float r, float g, float b, float shin);
161 void gaw_mtl_emission(float r, float g, float b);
162 void gaw_texenv_sphmap(int enable);
163
164 unsigned int gaw_create_tex1d(int texfilter);
165 unsigned int gaw_create_tex2d(int texfilter);
166 void gaw_destroy_tex(unsigned int tex);
167
168 void gaw_bind_tex1d(int tex);
169 void gaw_bind_tex2d(int tex);
170
171 void gaw_texfilter1d(int texfilter);
172 void gaw_texfilter2d(int texfilter);
173
174 void gaw_texwrap1d(int wrap);
175 void gaw_texwrap2d(int uwrap, int vwrap);
176
177 void gaw_tex1d(int ifmt, int xsz, int fmt, void *pix);
178 void gaw_tex2d(int ifmt, int xsz, int ysz, int fmt, void *pix);
179 void gaw_subtex2d(int lvl, int x, int y, int xsz, int ysz, int fmt, void *pix);
180
181 void gaw_set_tex1d(unsigned int texid);
182 void gaw_set_tex2d(unsigned int texid);
183
184 void gaw_ambient(float r, float g, float b);
185 void gaw_light_dir(int idx, float x, float y, float z);
186 void gaw_light_color(int idx, float r, float g, float b, float s);
187 void gaw_lighting_fast(void);
188
189 void gaw_fog_color(float r, float g, float b);
190 void gaw_fog_linear(float z0, float z1);
191 void gaw_fog_fast(void);
192
193 void gaw_poly_wire(void);
194 void gaw_poly_flat(void);
195 void gaw_poly_gouraud(void);
196
197 #endif  /* GRAPHICS_API_WRAPPER_H_ */