]> icculus.org git repositories - btb/d2x.git/blob - include/texmap.h
update
[btb/d2x.git] / include / texmap.h
1 /*
2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
11 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13 /*
14  * $Source: /cvs/cvsroot/d2x/include/texmap.h,v $
15  * $Revision: 1.1.1.1 $
16  * $Author: bradleyb $
17  * $Date: 2001-01-19 03:30:16 $
18  *
19  * Include file for entities using texture mapper library.
20  *
21  * $Log: not supported by cvs2svn $
22  * Revision 1.2  1999/07/07 21:21:56  donut
23  * increased recip table size to better accommodate 640 res
24  *
25  * Revision 1.1.1.1  1999/06/14 22:02:20  donut
26  * Import of d1x 1.37 source.
27  *
28  * Revision 1.2  1995/09/04  14:22:10  allender
29  * #defines for fixed point limits on render buffer
30  *
31  * Revision 1.1  1995/05/04  20:14:50  allender
32  * Initial revision
33  *
34  * Revision 1.17  1994/11/10  11:09:16  mike
35  * detail level stuff.
36  * 
37  * Revision 1.16  1994/11/09  22:55:32  matt
38  * Added variable Current_seg_depth for detail level optimization
39  * 
40  * Revision 1.15  1994/06/09  16:10:04  mike
41  * Add prototype for SC2000
42  * 
43  * Revision 1.14  1994/05/25  18:46:16  matt
44  * Added gr_upoly_tmap_ylr(), which generates ylr's for a polygon
45  * 
46  * Revision 1.13  1994/05/25  09:47:12  mike
47  * Added interface support for linear texture mapper (Mike change, Matt commnet)
48  * 
49  * Revision 1.12  1994/05/24  17:30:43  mike
50  * Prototype a bunch of linear, vertical scanning functions.
51  * 
52  * Revision 1.11  1994/05/19  23:26:14  mike
53  * Add constants NUM_LIGHTING_VALUES, MAX_LIGHTING_VALUE, MIN_LIGHTING_VALUE,
54  * all part of new lighting_values_in_0_to_1 system.
55  * 
56  * Revision 1.10  1994/05/14  17:19:21  matt
57  * Added externs
58  * 
59  * Revision 1.9  1994/04/13  23:55:44  matt
60  * Increased max_tmap_verts from 16 to 25
61  * 
62  * Revision 1.8  1994/03/31  08:35:43  mike
63  * Prototype for gr_upoly_tmap.
64  * 
65  * Revision 1.7  1994/02/08  15:17:54  mike
66  * define label for MAX_TMAP_VERTS
67  * 
68  * Revision 1.6  1994/01/31  15:41:51  mike
69  * Add texture_map_lin_lin_sky_v
70  * 
71  * Revision 1.5  1994/01/18  10:49:40  mike
72  * prototype for texture_map_lin_lin_sky
73  * 
74  * Revision 1.4  1993/11/30  17:09:46  mike
75  * prototype for compute_lighting_value.
76  * 
77  * Revision 1.3  1993/11/22  10:50:38  matt
78  * Add ifndef around body of file
79  * 
80  * Revision 1.2  1993/10/06  12:41:25  mike
81  * Change prototype for draw_tmap.
82  * 
83  * Revision 1.1  1993/09/08  17:29:11  mike
84  * Initial revision
85  * 
86  *
87  */
88
89 #ifndef _TEXMAP_H
90 #define _TEXMAP_H
91
92 #include "fix.h"
93 #include "3d.h"
94 #include "gr.h"
95
96 #define NUM_LIGHTING_LEVELS 32
97 #define MAX_TMAP_VERTS 25
98 #define MAX_LIGHTING_VALUE      ((NUM_LIGHTING_LEVELS-1)*F1_0/NUM_LIGHTING_LEVELS)
99 #define MIN_LIGHTING_VALUE      (F1_0/NUM_LIGHTING_LEVELS)
100
101 #define FIX_RECIP_TABLE_SIZE    641 //increased from 321 to 641, since this res is now quite achievable.. slight fps boost -MM
102 // -------------------------------------------------------------------------------------------------------
103 extern fix compute_lighting_value(g3s_point *vertptr);
104
105 // -------------------------------------------------------------------------------------------------------
106 // This is the main texture mapper call.
107 //      tmap_num references a texture map defined in Texmap_ptrs.
108 //      nverts = number of vertices
109 //      vertbuf is a pointer to an array of vertex pointers
110 extern void draw_tmap(grs_bitmap *bp, int nverts, g3s_point **vertbuf);
111
112 // -------------------------------------------------------------------------------------------------------
113 // Texture map vertex.
114 //      The fields r,g,b and l are mutually exclusive.  r,g,b are used for rgb lighting.
115 //      l is used for intensity based lighting.
116 typedef struct g3ds_vertex {
117         fix     x,y,z;
118         fix     u,v;
119         fix     x2d,y2d;
120         fix     l;
121         fix     r,g,b;
122 } g3ds_vertex;
123
124 // A texture map is defined as a polygon with u,v coordinates associated with
125 // one point in the polygon, and a pair of vectors describing the orientation
126 // of the texture map in the world, from which the deltas Du_dx, Dv_dy, etc.
127 // are computed.
128 typedef struct g3ds_tmap {
129         int     nv;                     // number of vertices
130         g3ds_vertex     verts[MAX_TMAP_VERTS];  // up to 8 vertices, this is inefficient, change
131 } g3ds_tmap;
132
133 // -------------------------------------------------------------------------------------------------------
134
135 //      Note:   Not all interpolation method and lighting combinations are supported.
136 //      Set Interpolation_method to 0/1/2 for linear/linear, perspective/linear, perspective/perspective
137 extern  int     Interpolation_method;
138
139 // Set Lighting_on to 0/1/2 for no lighting/intensity lighting/rgb lighting
140 extern  int     Lighting_on;
141
142 // HACK INTERFACE: how far away the current segment (& thus texture) is
143 extern  int     Current_seg_depth;              
144 extern  int     Max_perspective_depth;          //      Deepest segment at which perspective interpolation will be used.
145 extern  int     Max_linear_depth;                               //      Deepest segment at which linear interpolation will be used.
146 extern  int     Max_flat_depth;                         //      Deepest segment at which flat shading will be used. (If not flat shading, then what?)
147
148 //      These are pointers to texture maps.  If you want to render texture map #7, then you will render
149 //      the texture map defined by Texmap_ptrs[7].
150 extern  grs_bitmap Texmap_ptrs[];
151 extern  grs_bitmap Texmap4_ptrs[];
152
153 // Interface for sky renderer
154 extern void texture_map_lin_lin_sky(grs_bitmap *srcb, g3ds_tmap *t);
155 extern void texture_map_lin_lin_sky_v(grs_bitmap *srcb, g3ds_tmap *t);
156 extern void texture_map_hyp_lin_v(grs_bitmap *srcb, g3ds_tmap *t);
157
158 extern void ntexture_map_lighted_linear(grs_bitmap *srcb, g3ds_tmap *t);
159
160 //      This is the gr_upoly-like interface to the texture mapper which uses texture-mapper compatible
161 //      (ie, avoids cracking) edge/delta computation.
162 void gr_upoly_tmap(int nverts, int *vert );
163
164 //This is like gr_upoly_tmap() but instead of drawing, it calls the specified
165 //function with ylr values
166 void gr_upoly_tmap_ylr(int nverts, int *vert, void (*ylr_func)(int, fix, fix) );
167
168 extern int Transparency_on,per2_flag;
169
170 //      Set to !0 to enable Sim City 2000 (or Eric's Drive Through, or Eric's Game) specific code.
171 extern  int     SC2000;
172
173 extern int Window_clip_left, Window_clip_bot, Window_clip_right, Window_clip_top;
174
175 // for ugly hack put in to be sure we don't overflow render buffer
176
177 #define FIX_XLIMIT      (639 * F1_0)
178 #define FIX_YLIMIT      (479 * F1_0)
179
180 #endif
181