rayzor

diff src/min3d.h @ 0:2a5340a6eee4

rayzor first commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 05 Apr 2014 08:46:27 +0300
parents
children a826bf0fb169
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/min3d.h	Sat Apr 05 08:46:27 2014 +0300
     1.3 @@ -0,0 +1,73 @@
     1.4 +#ifndef MIN3D_H_
     1.5 +#define MIN3D_H_
     1.6 +
     1.7 +#include "inttypes.h"
     1.8 +
     1.9 +/* state toggles */
    1.10 +enum {
    1.11 +	M3D_DEPTH_TEST,
    1.12 +	M3D_CULL_FACE,
    1.13 +	M3D_LIGHTING,
    1.14 +	M3D_LIGHT0,
    1.15 +	M3D_LIGHT1,
    1.16 +	M3D_LIGHT2,
    1.17 +	M3D_LIGHT3
    1.18 +};
    1.19 +
    1.20 +/* buffer bits */
    1.21 +enum {
    1.22 +	M3D_COLOR_BUFFER_BIT	= 1,
    1.23 +	M3D_DEPTH_BUFFER_BIT	= 2
    1.24 +};
    1.25 +
    1.26 +/* primitives */
    1.27 +enum {
    1.28 +	M3D_POINTS = 1,
    1.29 +	M3D_LINES = 2,
    1.30 +	M3D_TRIANGLES = 3,
    1.31 +	M3D_QUADS = 4
    1.32 +};
    1.33 +
    1.34 +/* matrix mode */
    1.35 +enum {
    1.36 +	M3D_MODELVIEW,
    1.37 +	M3D_PROJECTION
    1.38 +};
    1.39 +
    1.40 +struct m3d_image {
    1.41 +	int xsz, ysz;
    1.42 +	unsigned char *pixels;
    1.43 +};
    1.44 +
    1.45 +#ifdef __cplusplus
    1.46 +extern "C" {
    1.47 +#endif
    1.48 +
    1.49 +void m3d_set_buffers(struct m3d_image *cbuf, uint16_t *zbuf);
    1.50 +void m3d_clear(unsigned int bmask);
    1.51 +
    1.52 +void m3d_enable(int bit);
    1.53 +void m3d_disable(int bit);
    1.54 +
    1.55 +/* matrix stack */
    1.56 +void m3d_matrix_mode(int mode);
    1.57 +void m3d_load_identity(void);
    1.58 +void m3d_load_matrix(const float *m);
    1.59 +void m3d_mult_matrix(const float *m);
    1.60 +void m3d_translate(float x, float y, float z);
    1.61 +void m3d_rotate(float angle, float x, float y, float z);
    1.62 +void m3d_scale(float x, float y, float z);
    1.63 +void m3d_frustum(float left, float right, float bottom, float top, float nr, float fr);
    1.64 +void m3d_perspective(float vfov, float aspect, float znear, float zfar);
    1.65 +
    1.66 +/* drawing */
    1.67 +void m3d_draw(int prim, const float *varr, int vcount);
    1.68 +void m3d_draw_indexed(int prim, const float *varr, const int *idxarr, int icount);
    1.69 +
    1.70 +/* TODO immediate mode */
    1.71 +
    1.72 +#ifdef __cplusplus
    1.73 +}
    1.74 +#endif
    1.75 +
    1.76 +#endif	/* MIN3D_H_ */