deepstone
diff src/mglimpl.h @ 0:f04884489bad
dos3d initial import
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 21 Nov 2011 06:14:01 +0200 |
parents | |
children | 0e781cc43178 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/mglimpl.h Mon Nov 21 06:14:01 2011 +0200 1.3 @@ -0,0 +1,75 @@ 1.4 +/* 1.5 +256-color 3D graphics hack for real-mode DOS. 1.6 +Copyright (C) 2011 John Tsiombikas <nuclear@member.fsf.org> 1.7 + 1.8 +This program is free software: you can redistribute it and/or modify 1.9 +it under the terms of the GNU General Public License as published by 1.10 +the Free Software Foundation, either version 3 of the License, or 1.11 +(at your option) any later version. 1.12 + 1.13 +This program is distributed in the hope that it will be useful, 1.14 +but WITHOUT ANY WARRANTY; without even the implied warranty of 1.15 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1.16 +GNU General Public License for more details. 1.17 + 1.18 +You should have received a copy of the GNU General Public License 1.19 +along with this program. If not, see <http://www.gnu.org/licenses/>. 1.20 +*/ 1.21 +#ifndef MGL_IMPL_H_ 1.22 +#define MGL_IMPL_H_ 1.23 + 1.24 +#define MATRIX_STACK_SIZE 8 1.25 +#define MAX_LIGHTS 4 1.26 + 1.27 +#define ROUND(x) ((x) >= 0.0 ? (x) + 0.5 : (x) - 0.5) 1.28 + 1.29 +typedef struct { 1.30 + float x, y, z, w; 1.31 +} vec4_t; 1.32 + 1.33 +typedef struct { 1.34 + float x, y, z; 1.35 +} vec3_t; 1.36 + 1.37 +typedef struct { 1.38 + float x, y; 1.39 +} vec2_t; 1.40 + 1.41 +typedef float mat4_t[16]; 1.42 + 1.43 +struct vertex { 1.44 + vec4_t pos; 1.45 + vec3_t norm; 1.46 + vec2_t tc; 1.47 + float energy; 1.48 + int cidx; 1.49 +}; 1.50 + 1.51 +struct state { 1.52 + unsigned int flags; 1.53 + int ord, frontface, cullface; 1.54 + int mmode, mtop[2]; 1.55 + mat4_t matrix[2][MATRIX_STACK_SIZE]; 1.56 + int prim; 1.57 + struct vertex curv, v[4]; 1.58 + int vidx; 1.59 + int vp[4]; /* viewport */ 1.60 + int col_range; /* color interpolation range */ 1.61 + vec3_t ldir[MAX_LIGHTS]; 1.62 + float lint[MAX_LIGHTS]; 1.63 +}; 1.64 + 1.65 +struct framebuffer { 1.66 + int width, height; 1.67 + unsigned char *pixels; 1.68 + unsigned short **zbuf; /* zbuffer broken in 64k tiles */ 1.69 +}; 1.70 + 1.71 +int mgl_rast_init(struct state *state, struct framebuffer *fbuf); 1.72 +void mgl_rast_cleanup(void); 1.73 +void mgl_rast_prepare(void); 1.74 +void mgl_draw_point(struct vertex *v); 1.75 +void mgl_draw_line(struct vertex *v0, struct vertex *v1); 1.76 +void mgl_draw_poly(struct vertex *v, int numv); 1.77 + 1.78 +#endif /* MGL_IMPL_H_ */