5 typedef float g3d_matrix[16];
10 g3d_matrix mat[G3D_NUM_MATRICES][STACK_SIZE];
11 int mtop[G3D_NUM_MATRICES];
17 static struct g3d_state st;
23 memset(&st, 0, sizeof st);
25 for(i=0; i<G3D_NUM_MATRICES; i++) {
30 void g3d_framebuffer(int width, int height, void *pixels)
37 void g3d_enable(unsigned int opt)
42 void g3d_disable(unsigned int opt)
47 void g3d_setopt(unsigned int opt, unsigned int mask)
49 st.opt = (st.opt & ~mask) | (opt & mask);
52 unsigned int g3d_getopt(unsigned int mask)
57 void g3d_set_matrix(int which, const float *m)
59 int top = st.mtop[which];
60 memcpy(st.mat[which][top], m, 16 * sizeof(float));
63 #define M(i,j) (((i) << 2) + (j))
64 void g3d_mult_matrix(int which, const float *m2)
66 int i, j, top = st.mtop[which];
68 float *dest = st.mat[which][top];
70 memcpy(m1, dest, sizeof m1);
74 *dest++ = m1[M(0,j)] * m2[M(i,0)] +
75 m1[M(1,j)] * m2[M(i,1)] +
76 m1[M(2,j)] * m2[M(i,2)] +
77 m1[M(3,j)] * m2[M(i,3)];
81 /* TODO continue ... */