]> icculus.org git repositories - btb/d2x.git/blob - include/texmap.h
add level component saving functions which use PhysicsFS (didn't commit properly...
[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.3 $
16  * $Author: schaffner $
17  * $Date: 2004-08-28 23:17:45 $
18  *
19  * Include file for entities using texture mapper library.
20  *
21  */
22
23 #ifndef _TEXMAP_H
24 #define _TEXMAP_H
25
26 #include "fix.h"
27 #include "3d.h"
28 #include "gr.h"
29
30 #define NUM_LIGHTING_LEVELS 32
31 #define MAX_TMAP_VERTS 25
32 #define MAX_LIGHTING_VALUE      ((NUM_LIGHTING_LEVELS-1)*F1_0/NUM_LIGHTING_LEVELS)
33 #define MIN_LIGHTING_VALUE      (F1_0/NUM_LIGHTING_LEVELS)
34
35 #define FIX_RECIP_TABLE_SIZE    641 //increased from 321 to 641, since this res is now quite achievable.. slight fps boost -MM
36 // -------------------------------------------------------------------------------------------------------
37 extern fix compute_lighting_value(g3s_point *vertptr);
38
39 // -------------------------------------------------------------------------------------------------------
40 // This is the main texture mapper call.
41 //      tmap_num references a texture map defined in Texmap_ptrs.
42 //      nverts = number of vertices
43 //      vertbuf is a pointer to an array of vertex pointers
44 extern void draw_tmap(grs_bitmap *bp, int nverts, g3s_point **vertbuf);
45
46 // -------------------------------------------------------------------------------------------------------
47 // Texture map vertex.
48 //      The fields r,g,b and l are mutually exclusive.  r,g,b are used for rgb lighting.
49 //      l is used for intensity based lighting.
50 typedef struct g3ds_vertex {
51         fix     x,y,z;
52         fix     u,v;
53         fix     x2d,y2d;
54         fix     l;
55         fix     r,g,b;
56 } g3ds_vertex;
57
58 // A texture map is defined as a polygon with u,v coordinates associated with
59 // one point in the polygon, and a pair of vectors describing the orientation
60 // of the texture map in the world, from which the deltas Du_dx, Dv_dy, etc.
61 // are computed.
62 typedef struct g3ds_tmap {
63         int     nv;                     // number of vertices
64         g3ds_vertex     verts[MAX_TMAP_VERTS];  // up to 8 vertices, this is inefficient, change
65 } g3ds_tmap;
66
67 // -------------------------------------------------------------------------------------------------------
68
69 //      Note:   Not all interpolation method and lighting combinations are supported.
70 //      Set Interpolation_method to 0/1/2 for linear/linear, perspective/linear, perspective/perspective
71 extern  int     Interpolation_method;
72
73 // Set Lighting_on to 0/1/2 for no lighting/intensity lighting/rgb lighting
74 extern  int     Lighting_on;
75
76 // HACK INTERFACE: how far away the current segment (& thus texture) is
77 extern  int     Current_seg_depth;              
78 extern  int     Max_perspective_depth;          //      Deepest segment at which perspective interpolation will be used.
79 extern  int     Max_linear_depth;                               //      Deepest segment at which linear interpolation will be used.
80 extern  int     Max_flat_depth;                         //      Deepest segment at which flat shading will be used. (If not flat shading, then what?)
81
82 //      These are pointers to texture maps.  If you want to render texture map #7, then you will render
83 //      the texture map defined by Texmap_ptrs[7].
84 extern  grs_bitmap Texmap_ptrs[];
85 extern  grs_bitmap Texmap4_ptrs[];
86
87 // Interface for sky renderer
88 extern void texture_map_lin_lin_sky(grs_bitmap *srcb, g3ds_tmap *t);
89 extern void texture_map_lin_lin_sky_v(grs_bitmap *srcb, g3ds_tmap *t);
90 extern void texture_map_hyp_lin_v(grs_bitmap *srcb, g3ds_tmap *t);
91
92 extern void ntexture_map_lighted_linear(grs_bitmap *srcb, g3ds_tmap *t);
93
94 //      This is the gr_upoly-like interface to the texture mapper which uses texture-mapper compatible
95 //      (ie, avoids cracking) edge/delta computation.
96 void gr_upoly_tmap(int nverts, int *vert );
97
98 //This is like gr_upoly_tmap() but instead of drawing, it calls the specified
99 //function with ylr values
100 void gr_upoly_tmap_ylr(int nverts, int *vert, void (*ylr_func)(int, fix, fix) );
101
102 extern int Transparency_on,per2_flag;
103
104 //      Set to !0 to enable Sim City 2000 (or Eric's Drive Through, or Eric's Game) specific code.
105 extern  int     SC2000;
106
107 extern int Window_clip_left, Window_clip_bot, Window_clip_right, Window_clip_top;
108
109 // for ugly hack put in to be sure we don't overflow render buffer
110
111 #define FIX_XLIMIT      (639 * F1_0)
112 #define FIX_YLIMIT      (479 * F1_0)
113
114 extern void init_interface_vars_to_assembler(void);
115
116 #endif
117