8 typedef uint16_t g3d_pixel;
11 #define G3D_PACK_RGB(r, g, b) PACK_RGB16(r, g, b)
12 #define G3D_UNPACK_R(c) UNPACK_R16(c)
13 #define G3D_UNPACK_G(c) UNPACK_G16(c)
14 #define G3D_UNPACK_B(c) UNPACK_B16(c)
17 #define G3D_PACK_RGB(r, g, b) PACK_RGB32(r, g, b)
18 #define G3D_UNPACK_R(c) UNPACK_R32(c)
19 #define G3D_UNPACK_G(c) UNPACK_G32(c)
20 #define G3D_UNPACK_B(c) UNPACK_B32(c)
28 unsigned char r, g, b, a;
38 /* g3d_enable/g3d_disable bits */
40 G3D_CULL_FACE = 0x000001,
41 G3D_DEPTH_TEST = 0x000002, /* XXX not implemented */
42 G3D_LIGHTING = 0x000004,
43 G3D_LIGHT0 = 0x000008,
44 G3D_LIGHT1 = 0x000010,
45 G3D_LIGHT2 = 0x000020,
46 G3D_LIGHT3 = 0x000040,
47 G3D_TEXTURE_2D = 0x000080, /* XXX doesn't affect anything, use g3d_polygon_mode */
49 G3D_TEXTURE_GEN = 0x000200,
50 G3D_CLIP_FRUSTUM = 0x000800,/* when disabled, don't clip against the frustum */
51 G3D_CLIP_PLANE0 = 0x001000, /* user-defined 3D clipping planes XXX not impl. */
52 G3D_CLIP_PLANE1 = 0x002000,
53 G3D_CLIP_PLANE2 = 0x004000,
54 G3D_CLIP_PLANE3 = 0x008000,
56 G3D_TEXTURE_MAT = 0x010000,
57 G3D_SPECULAR = 0x020000,
62 /* arg to g3d_front_face */
63 enum { G3D_CCW, G3D_CW };
65 /* arg to g3d_polygon_mode */
82 void g3d_destroy(void);
84 void g3d_framebuffer(int width, int height, void *pixels);
85 void g3d_framebuffer_addr(void *pixels);
86 void g3d_viewport(int x, int y, int w, int h);
88 void g3d_enable(unsigned int opt);
89 void g3d_disable(unsigned int opt);
90 void g3d_setopt(unsigned int opt, unsigned int mask);
91 unsigned int g3d_getopt(unsigned int mask);
93 void g3d_front_face(unsigned int order);
94 void g3d_polygon_mode(int pmode);
96 void g3d_matrix_mode(int mmode);
98 void g3d_load_identity(void);
99 void g3d_load_matrix(const float *m);
100 void g3d_mult_matrix(const float *m);
101 void g3d_push_matrix(void);
102 void g3d_pop_matrix(void);
104 void g3d_translate(float x, float y, float z);
105 void g3d_rotate(float angle, float x, float y, float z);
106 void g3d_scale(float x, float y, float z);
107 void g3d_ortho(float left, float right, float bottom, float top, float znear, float zfar);
108 void g3d_frustum(float left, float right, float bottom, float top, float znear, float zfar);
109 void g3d_perspective(float vfov, float aspect, float znear, float zfar);
111 /* returns pointer to the *internal* matrix, and if argument m is not null,
112 * also copies the internal matrix there. */
113 const float *g3d_get_matrix(int which, float *m);
115 void g3d_light_pos(int idx, float x, float y, float z);
116 void g3d_light_dir(int idx, float x, float y, float z);
117 void g3d_light_color(int idx, float r, float g, float b);
119 void g3d_light_ambient(float r, float g, float b);
121 void g3d_mtl_diffuse(float r, float g, float b);
122 void g3d_mtl_specular(float r, float g, float b);
123 void g3d_mtl_shininess(float shin);
125 void g3d_set_texture(int xsz, int ysz, void *pixels);
127 void g3d_draw(int prim, const struct g3d_vertex *varr, int varr_size);
128 void g3d_draw_indexed(int prim, const struct g3d_vertex *varr, int varr_size,
129 const uint16_t *iarr, int iarr_size);
131 void g3d_begin(int prim);
133 void g3d_vertex(float x, float y, float z);
134 void g3d_normal(float x, float y, float z);
135 void g3d_color3b(unsigned char r, unsigned char g, unsigned char b);
136 void g3d_color4b(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
137 void g3d_color3f(float r, float g, float b);
138 void g3d_color4f(float r, float g, float b, float a);
139 void g3d_texcoord(float u, float v);
141 #endif /* THREEDGFX_H_ */