dos3d
view src/mglimpl.h @ 24:698c4d07702d
fixed the linux makefile
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 20 Jun 2017 21:55:49 +0300 |
parents | 0909996838ff |
children |
line source
1 /*
2 256-color 3D graphics hack for real-mode DOS.
3 Copyright (C) 2011 John Tsiombikas <nuclear@member.fsf.org>
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 <http://www.gnu.org/licenses/>.
17 */
18 #ifndef MGL_IMPL_H_
19 #define MGL_IMPL_H_
21 #include "vmath.h"
23 #define MATRIX_STACK_SIZE 8
24 #define MAX_LIGHTS 4
26 #define ZTILE_SIZE 16384
27 #define ZTILE_SHIFT 14
28 #define ZTILE_MASK 0x3fff
30 #define ZTILE(x) (((x) & ~ZTILE_MASK) >> ZTILE_SHIFT)
31 #define ZTILE_OFFS(x) ((x) & ZTILE_MASK)
33 #define ROUND(x) ((x) >= 0.0 ? (x) + 0.5 : (x) - 0.5)
36 typedef float mat4_t[16];
38 struct vertex {
39 vec4_t pos;
40 vec3_t norm;
41 vec2_t tc;
42 float energy;
43 int cidx;
44 };
46 struct texture {
47 int width, height;
48 int xshift, yshift;
49 unsigned int xmask, ymask;
50 unsigned char *pixels;
51 };
53 struct state {
54 unsigned int flags;
55 int ord, frontface, cullface;
56 int mmode, mtop[2];
57 mat4_t matrix[2][MATRIX_STACK_SIZE];
58 int prim;
59 struct vertex curv, v[4];
60 int vidx;
61 int vp[4]; /* viewport */
62 int col_range; /* color interpolation range */
63 vec4_t lpos[MAX_LIGHTS];
64 float lint[MAX_LIGHTS];
66 struct texture tex;
67 };
69 struct framebuffer {
70 int width, height;
71 unsigned char *pixels;
72 unsigned short **zbuf; /* zbuffer broken in ZTILE_SIZE tiles */
73 int num_ztiles;
74 };
77 int mgl_rast_init(struct state *state, struct framebuffer *fbuf);
78 void mgl_rast_cleanup(void);
79 void mgl_rast_prepare(void);
80 void mgl_draw_point(struct vertex *v);
81 void mgl_draw_line(struct vertex *v0, struct vertex *v1);
82 void mgl_draw_poly(struct vertex *v, int numv);
84 #endif /* MGL_IMPL_H_ */