1 /*         ______   ___    ___
2  *        /\  _  \ /\_ \  /\_ \
3  *        \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___
4  *         \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
5  *          \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
6  *           \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
7  *            \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
8  *                                           /\____/
9  *                                           \_/__/
10  *
11  *      3D polygon drawing routines.
12  *
13  *      By Shawn Hargreaves.
14  *
15  *      See readme.txt for copyright information.
16  */
17 
18 
19 #ifndef ALLEGRO_3D_H
20 #define ALLEGRO_3D_H
21 
22 #include "base.h"
23 #include "fixed.h"
24 
25 #ifdef __cplusplus
26    extern "C" {
27 #endif
28 
29 struct BITMAP;
30 
31 typedef struct V3D                  /* a 3d point (fixed point version) */
32 {
33    fixed x, y, z;                   /* position */
34    fixed u, v;                      /* texture map coordinates */
35    int c;                           /* color */
36 } V3D;
37 
38 
39 typedef struct V3D_f                /* a 3d point (floating point version) */
40 {
41    float x, y, z;                   /* position */
42    float u, v;                      /* texture map coordinates */
43    int c;                           /* color */
44 } V3D_f;
45 
46 
47 #define POLYTYPE_FLAT               0
48 #define POLYTYPE_GCOL               1
49 #define POLYTYPE_GRGB               2
50 #define POLYTYPE_ATEX               3
51 #define POLYTYPE_PTEX               4
52 #define POLYTYPE_ATEX_MASK          5
53 #define POLYTYPE_PTEX_MASK          6
54 #define POLYTYPE_ATEX_LIT           7
55 #define POLYTYPE_PTEX_LIT           8
56 #define POLYTYPE_ATEX_MASK_LIT      9
57 #define POLYTYPE_PTEX_MASK_LIT      10
58 #define POLYTYPE_ATEX_TRANS         11
59 #define POLYTYPE_PTEX_TRANS         12
60 #define POLYTYPE_ATEX_MASK_TRANS    13
61 #define POLYTYPE_PTEX_MASK_TRANS    14
62 #define POLYTYPE_MAX                15
63 #define POLYTYPE_ZBUF               16
64 
65 AL_VAR(float, scene_gap);
66 
67 AL_FUNC(void, _soft_polygon3d, (struct BITMAP *bmp, int type, struct BITMAP *texture, int vc, V3D *vtx[]));
68 AL_FUNC(void, _soft_polygon3d_f, (struct BITMAP *bmp, int type, struct BITMAP *texture, int vc, V3D_f *vtx[]));
69 AL_FUNC(void, _soft_triangle3d, (struct BITMAP *bmp, int type, struct BITMAP *texture, V3D *v1, V3D *v2, V3D *v3));
70 AL_FUNC(void, _soft_triangle3d_f, (struct BITMAP *bmp, int type, struct BITMAP *texture, V3D_f *v1, V3D_f *v2, V3D_f *v3));
71 AL_FUNC(void, _soft_quad3d, (struct BITMAP *bmp, int type, struct BITMAP *texture, V3D *v1, V3D *v2, V3D *v3, V3D *v4));
72 AL_FUNC(void, _soft_quad3d_f, (struct BITMAP *bmp, int type, struct BITMAP *texture, V3D_f *v1, V3D_f *v2, V3D_f *v3, V3D_f *v4));
73 AL_FUNC(int, clip3d, (int type, fixed min_z, fixed max_z, int vc, AL_CONST V3D *vtx[], V3D *vout[], V3D *vtmp[], int out[]));
74 AL_FUNC(int, clip3d_f, (int type, float min_z, float max_z, int vc, AL_CONST V3D_f *vtx[], V3D_f *vout[], V3D_f *vtmp[], int out[]));
75 
76 AL_FUNC(fixed, polygon_z_normal, (AL_CONST V3D *v1, AL_CONST V3D *v2, AL_CONST V3D *v3));
77 AL_FUNC(float, polygon_z_normal_f, (AL_CONST V3D_f *v1, AL_CONST V3D_f *v2, AL_CONST V3D_f *v3));
78 
79 /* Note: You are not supposed to mix ZBUFFER with BITMAP even though it is
80  * currently possible. This is just the internal representation, and it may
81  * change in the future.
82  */
83 typedef struct BITMAP ZBUFFER;
84 
85 AL_FUNC(ZBUFFER *, create_zbuffer, (struct BITMAP *bmp));
86 AL_FUNC(ZBUFFER *, create_sub_zbuffer, (ZBUFFER *parent, int x, int y, int width, int height));
87 AL_FUNC(void, set_zbuffer, (ZBUFFER *zbuf));
88 AL_FUNC(void, clear_zbuffer, (ZBUFFER *zbuf, float z));
89 AL_FUNC(void, destroy_zbuffer, (ZBUFFER *zbuf));
90 
91 AL_FUNC(int, create_scene, (int nedge, int npoly));
92 AL_FUNC(void, clear_scene, (struct BITMAP* bmp));
93 AL_FUNC(void, destroy_scene, (void));
94 AL_FUNC(int, scene_polygon3d, (int type, struct BITMAP *texture, int vx, V3D *vtx[]));
95 AL_FUNC(int, scene_polygon3d_f, (int type, struct BITMAP *texture, int vx, V3D_f *vtx[]));
96 AL_FUNC(void, render_scene, (void));
97 
98 #ifdef __cplusplus
99    }
100 #endif
101 
102 #endif          /* ifndef ALLEGRO_3D_H */
103 
104 
105