deepstone
view src/mglimpl.h @ 5:c8ffdbc6139e
added cleandep
removed verbosity from texture loader
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 21 Nov 2011 12:00:13 +0200 |
parents | f04884489bad |
children | bce78aaafc68 |
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 #define MATRIX_STACK_SIZE 8
22 #define MAX_LIGHTS 4
24 #define ROUND(x) ((x) >= 0.0 ? (x) + 0.5 : (x) - 0.5)
26 typedef struct {
27 float x, y, z, w;
28 } vec4_t;
30 typedef struct {
31 float x, y, z;
32 } vec3_t;
34 typedef struct {
35 float x, y;
36 } vec2_t;
38 typedef float mat4_t[16];
40 struct vertex {
41 vec4_t pos;
42 vec3_t norm;
43 vec2_t tc;
44 float energy;
45 int cidx;
46 };
48 struct texture {
49 int width, height;
50 int xshift, yshift;
51 unsigned int xmask, ymask;
52 unsigned char *pixels;
53 };
55 struct state {
56 unsigned int flags;
57 int ord, frontface, cullface;
58 int mmode, mtop[2];
59 mat4_t matrix[2][MATRIX_STACK_SIZE];
60 int prim;
61 struct vertex curv, v[4];
62 int vidx;
63 int vp[4]; /* viewport */
64 int col_range; /* color interpolation range */
65 vec3_t ldir[MAX_LIGHTS];
66 float lint[MAX_LIGHTS];
68 struct texture tex;
69 };
71 struct framebuffer {
72 int width, height;
73 unsigned char *pixels;
74 unsigned short **zbuf; /* zbuffer broken in 64k tiles */
75 };
78 int mgl_rast_init(struct state *state, struct framebuffer *fbuf);
79 void mgl_rast_cleanup(void);
80 void mgl_rast_prepare(void);
81 void mgl_draw_point(struct vertex *v);
82 void mgl_draw_line(struct vertex *v0, struct vertex *v1);
83 void mgl_draw_poly(struct vertex *v, int numv);
85 #endif /* MGL_IMPL_H_ */