deepstone

view src/mglimpl.h @ 24:ad6b185723cd

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 21 Sep 2013 20:18:28 +0300
parents be61704c4cc8
children 5ff8ce78059a
line source
1 #ifndef MGL_IMPL_H_
2 #define MGL_IMPL_H_
4 #include "vmath.h"
6 #define MATRIX_STACK_SIZE 8
7 #define MAX_LIGHTS 4
9 #define ZTILE_SIZE 16384
10 #define ZTILE_SHIFT 14
11 #define ZTILE_MASK 0x3fff
13 #define ZTILE(x) (((x) & ~ZTILE_MASK) >> ZTILE_SHIFT)
14 #define ZTILE_OFFS(x) ((x) & ZTILE_MASK)
16 #define ROUND(x) ((x) >= 0.0 ? (x) + 0.5 : (x) - 0.5)
19 typedef float mat4_t[16];
21 struct vertex {
22 vec4_t pos;
23 vec3_t norm;
24 vec2_t tc;
25 float energy;
26 int cidx;
27 };
29 struct texture {
30 int width, height;
31 int xshift, yshift;
32 unsigned int xmask, ymask;
33 unsigned char *pixels;
34 };
36 struct state {
37 unsigned int flags;
38 int ord, frontface, cullface;
39 int mmode, mtop[2];
40 mat4_t matrix[2][MATRIX_STACK_SIZE];
41 int prim;
42 struct vertex curv, v[4];
43 int vidx;
44 int vp[4]; /* viewport */
45 int col_range; /* color interpolation range */
46 vec4_t lpos[MAX_LIGHTS];
47 float lint[MAX_LIGHTS];
49 struct texture tex;
50 };
52 struct framebuffer {
53 int width, height;
54 unsigned char *pixels;
55 unsigned short **zbuf; /* zbuffer broken in ZTILE_SIZE tiles */
56 int num_ztiles;
57 };
60 int mgl_rast_init(struct state *state, struct framebuffer *fbuf);
61 void mgl_rast_cleanup(void);
62 void mgl_rast_prepare(void);
63 void mgl_draw_point(struct vertex *v);
64 void mgl_draw_line(struct vertex *v0, struct vertex *v1);
65 void mgl_draw_poly(struct vertex *v, int numv);
67 #endif /* MGL_IMPL_H_ */