picking and brute force ray intersections
[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         GAW_POLYGON_OFFSET
63 };
64
65 enum {
66         GAW_NEVER,
67         GAW_LESS,
68         GAW_EQUAL,
69         GAW_LEQUAL,
70         GAW_GREATER,
71         GAW_NOTEQUAL,
72         GAW_GEQUAL,
73         GAW_ALWAYS
74 };
75
76 enum {
77         GAW_ZERO,
78         GAW_ONE,
79         GAW_SRC_ALPHA,
80         GAW_ONE_MINUS_SRC_ALPHA
81 };
82
83 enum {
84         GAW_LUMINANCE,
85         GAW_RGB,
86         GAW_RGBA
87 };
88
89 enum {
90         GAW_NEAREST,
91         GAW_BILINEAR,
92         GAW_TRILINEAR
93 };
94
95 enum {
96         GAW_REPEAT,
97         GAW_CLAMP
98 };
99
100 void gaw_viewport(int x, int y, int w, int h);
101 void gaw_get_viewport(int *vp);
102
103 void gaw_matrix_mode(int mode);
104 void gaw_load_identity(void);
105 void gaw_load_matrix(const float *m);
106 void gaw_mult_matrix(const float *m);
107 void gaw_push_matrix(void);
108 void gaw_pop_matrix(void);
109 void gaw_get_modelview(float *m);
110 void gaw_get_projection(float *m);
111
112 void gaw_translate(float x, float y, float z);
113 void gaw_rotate(float angle, float x, float y, float z);
114 void gaw_scale(float sx, float sy, float sz);
115 void gaw_ortho(float l, float r, float b, float t, float n, float f);
116 void gaw_frustum(float l, float r, float b, float t, float n, float f);
117 void gaw_perspective(float vfov, float aspect, float znear, float zfar);
118
119 void gaw_save(void);
120 void gaw_restore(void);
121 void gaw_enable(int st);
122 void gaw_disable(int st);
123
124 void gaw_depth_func(int func);
125 void gaw_blend_func(int src, int dest);
126 void gaw_alpha_func(int func, float ref);
127
128 void gaw_zoffset(float offs);
129
130 void gaw_clear_color(float r, float g, float b, float a);
131 void gaw_clear(unsigned int flags);
132 void gaw_depth_mask(int mask);
133
134 void gaw_vertex_array(int nelem, int stride, const void *ptr);
135 void gaw_normal_array(int stride, const void *ptr);
136 void gaw_texcoord_array(int nelem, int stride, const void *ptr);
137 void gaw_color_array(int nelem, int stride, const void *ptr);
138 void gaw_draw(int prim, int nverts);
139 void gaw_draw_indexed(int prim, const unsigned int *idxarr, int nidx);
140
141 void gaw_begin(int prim);
142 void gaw_end(void);
143 void gaw_color3f(float r, float g, float b);
144 void gaw_color4f(float r, float g, float b, float a);
145 void gaw_color3ub(int r, int g, int b);
146 void gaw_normal(float x, float y, float z);
147 void gaw_texcoord1f(float u);
148 void gaw_texcoord2f(float u, float v);
149 void gaw_vertex2f(float x, float y);
150 void gaw_vertex3f(float x, float y, float z);
151 void gaw_vertex4f(float x, float y, float z, float w);
152
153 void gaw_rect(float x1, float y1, float x2, float y2);
154
155 void gaw_pointsize(float sz);
156 void gaw_linewidth(float w);
157
158 int gaw_compile_begin(void);
159 void gaw_compile_end(void);
160 void gaw_draw_compiled(int id);
161 void gaw_free_compiled(int id);
162
163 void gaw_mtl_diffuse(float r, float g, float b, float a);
164 void gaw_mtl_specular(float r, float g, float b, float shin);
165 void gaw_mtl_emission(float r, float g, float b);
166 void gaw_texenv_sphmap(int enable);
167
168 unsigned int gaw_create_tex1d(int texfilter);
169 unsigned int gaw_create_tex2d(int texfilter);
170 void gaw_destroy_tex(unsigned int tex);
171
172 void gaw_bind_tex1d(int tex);
173 void gaw_bind_tex2d(int tex);
174
175 void gaw_texfilter1d(int texfilter);
176 void gaw_texfilter2d(int texfilter);
177
178 void gaw_texwrap1d(int wrap);
179 void gaw_texwrap2d(int uwrap, int vwrap);
180
181 void gaw_tex1d(int ifmt, int xsz, int fmt, void *pix);
182 void gaw_tex2d(int ifmt, int xsz, int ysz, int fmt, void *pix);
183 void gaw_subtex2d(int lvl, int x, int y, int xsz, int ysz, int fmt, void *pix);
184
185 void gaw_set_tex1d(unsigned int texid);
186 void gaw_set_tex2d(unsigned int texid);
187
188 void gaw_ambient(float r, float g, float b);
189 void gaw_light_dir(int idx, float x, float y, float z);
190 void gaw_light_color(int idx, float r, float g, float b, float s);
191 void gaw_lighting_fast(void);
192
193 void gaw_fog_color(float r, float g, float b);
194 void gaw_fog_linear(float z0, float z1);
195 void gaw_fog_fast(void);
196
197 void gaw_poly_wire(void);
198 void gaw_poly_flat(void);
199 void gaw_poly_gouraud(void);
200
201 #endif  /* GRAPHICS_API_WRAPPER_H_ */