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,
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,
48 G3D_ALPHA_BLEND = 0x000100,
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,
59 G3D_ADD_BLEND = 0x040000,
64 /* arg to g3d_front_face */
65 enum { G3D_CCW, G3D_CW };
67 /* arg to g3d_polygon_mode */
85 G3D_COLOR_BUFFER_BIT = 1,
86 G3D_DEPTH_BUFFER_BIT = 2
90 void g3d_destroy(void);
93 void g3d_framebuffer(int width, int height, void *pixels);
94 void g3d_framebuffer_addr(void *pixels);
95 void g3d_viewport(int x, int y, int w, int h);
97 void g3d_clear_color(unsigned char r, unsigned char g, unsigned char b);
98 void g3d_clear_depth(uint16_t zval);
99 void g3d_clear(unsigned int mask);
101 void g3d_enable(unsigned int opt);
102 void g3d_disable(unsigned int opt);
103 void g3d_setopt(unsigned int opt, unsigned int mask);
104 unsigned int g3d_getopt(unsigned int mask);
106 void g3d_front_face(unsigned int order);
107 void g3d_polygon_mode(int pmode);
108 int g3d_get_polygon_mode(void);
110 void g3d_matrix_mode(int mmode);
112 void g3d_load_identity(void);
113 void g3d_load_matrix(const float *m);
114 void g3d_mult_matrix(const float *m);
115 void g3d_push_matrix(void);
116 void g3d_pop_matrix(void);
118 void g3d_translate(float x, float y, float z);
119 void g3d_rotate(float angle, float x, float y, float z);
120 void g3d_scale(float x, float y, float z);
121 void g3d_ortho(float left, float right, float bottom, float top, float znear, float zfar);
122 void g3d_frustum(float left, float right, float bottom, float top, float znear, float zfar);
123 void g3d_perspective(float vfov, float aspect, float znear, float zfar);
125 /* returns pointer to the *internal* matrix, and if argument m is not null,
126 * also copies the internal matrix there. */
127 const float *g3d_get_matrix(int which, float *m);
129 void g3d_light_pos(int idx, float x, float y, float z);
130 void g3d_light_dir(int idx, float x, float y, float z);
131 void g3d_light_color(int idx, float r, float g, float b);
133 void g3d_light_ambient(float r, float g, float b);
135 void g3d_mtl_diffuse(float r, float g, float b);
136 void g3d_mtl_specular(float r, float g, float b);
137 void g3d_mtl_shininess(float shin);
139 void g3d_set_texture(int xsz, int ysz, void *pixels);
141 void g3d_draw(int prim, const struct g3d_vertex *varr, int varr_size);
142 void g3d_draw_indexed(int prim, const struct g3d_vertex *varr, int varr_size,
143 const uint16_t *iarr, int iarr_size);
145 void g3d_begin(int prim);
147 void g3d_vertex(float x, float y, float z);
148 void g3d_normal(float x, float y, float z);
149 void g3d_color3b(unsigned char r, unsigned char g, unsigned char b);
150 void g3d_color4b(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
151 void g3d_color3f(float r, float g, float b);
152 void g3d_color4f(float r, float g, float b, float a);
153 void g3d_texcoord(float u, float v);
155 #endif /* THREEDGFX_H_ */