6 typedef unsigned char g3d_pixel;
23 /* g3d_enable/g3d_disable bits */
25 G3D_CULL_FACE = 0x000001,
26 G3D_DEPTH_TEST = 0x000002,
27 G3D_LIGHTING = 0x000004,
28 G3D_LIGHT0 = 0x000008,
29 G3D_LIGHT1 = 0x000010,
30 G3D_LIGHT2 = 0x000020,
31 G3D_LIGHT3 = 0x000040,
32 G3D_TEXTURE_2D = 0x000080,
33 G3D_ALPHA_BLEND = 0x000100,
34 G3D_TEXTURE_GEN = 0x000200,
35 G3D_CLIP_FRUSTUM = 0x000800,/* when disabled, don't clip against the frustum */
36 G3D_CLIP_PLANE0 = 0x001000, /* user-defined 3D clipping planes XXX not impl. */
37 G3D_CLIP_PLANE1 = 0x002000,
38 G3D_CLIP_PLANE2 = 0x004000,
39 G3D_CLIP_PLANE3 = 0x008000,
41 G3D_TEXTURE_MAT = 0x010000,
42 G3D_SPECULAR = 0x020000,
44 G3D_ADD_BLEND = 0x040000,
49 /* arg to g3d_front_face */
50 enum { G3D_CCW, G3D_CW };
52 /* arg to g3d_polygon_mode */
69 G3D_COLOR_BUFFER_BIT = 1,
70 G3D_DEPTH_BUFFER_BIT = 2
74 void g3d_destroy(void);
77 void g3d_framebuffer(int width, int height, void *pixels);
78 void g3d_framebuffer_addr(void *pixels);
79 void g3d_viewport(int x, int y, int w, int h);
81 void g3d_clear_color(unsigned char r, unsigned char g, unsigned char b);
82 void g3d_clear_depth(float z);
83 void g3d_clear(unsigned int mask);
85 void g3d_enable(unsigned int opt);
86 void g3d_disable(unsigned int opt);
87 void g3d_setopt(unsigned int opt, unsigned int mask);
88 unsigned int g3d_getopt(unsigned int mask);
90 void g3d_front_face(unsigned int order);
91 void g3d_polygon_mode(int pmode);
92 int g3d_get_polygon_mode(void);
94 void g3d_matrix_mode(int mmode);
96 void g3d_load_identity(void);
97 void g3d_load_matrix(const float *m);
98 void g3d_mult_matrix(const float *m);
99 void g3d_push_matrix(void);
100 void g3d_pop_matrix(void);
102 void g3d_translate(float x, float y, float z);
103 void g3d_rotate(float angle, float x, float y, float z);
104 void g3d_scale(float x, float y, float z);
105 void g3d_ortho(float left, float right, float bottom, float top, float znear, float zfar);
106 void g3d_frustum(float left, float right, float bottom, float top, float znear, float zfar);
107 void g3d_perspective(float vfov, float aspect, float znear, float zfar);
109 /* returns pointer to the *internal* matrix, and if argument m is not null,
110 * also copies the internal matrix there. */
111 const float *g3d_get_matrix(int which, float *m);
113 void g3d_light_pos(int idx, float x, float y, float z);
114 void g3d_light_dir(int idx, float x, float y, float z);
115 void g3d_light_energy(int idx, float val);
117 void g3d_light_ambient(float val);
119 void g3d_mtl_diffuse(float diffuse);
120 void g3d_mtl_specular(float spec);
121 void g3d_mtl_shininess(float shin);
123 void g3d_set_texture(int xsz, int ysz, void *pixels);
125 void g3d_draw(int prim, const struct g3d_vertex *varr, int varr_size);
126 void g3d_draw_indexed(int prim, const struct g3d_vertex *varr, int varr_size,
127 const uint16_t *iarr, int iarr_size);
129 void g3d_begin(int prim);
131 void g3d_vertex(float x, float y, float z);
132 void g3d_normal(float x, float y, float z);
133 void g3d_color1b(unsigned char lum);
134 void g3d_color2b(unsigned char lum, unsigned char a);
135 void g3d_color1f(float lum);
136 void g3d_color2f(float lum, float a);
137 void g3d_texcoord(float u, float v);
139 #endif /* THREEDGFX_H_ */