1 #ifndef __SCOTTISH_TEXTURES_H 2 #define __SCOTTISH_TEXTURES_H 3 4 /* 5 SCOTTISH_TEXTURES.H 6 7 Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc. 8 and the "Aleph One" developers. 9 10 This program is free software; you can redistribute it and/or modify 11 it under the terms of the GNU General Public License as published by 12 the Free Software Foundation; either version 3 of the License, or 13 (at your option) any later version. 14 15 This program is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU General Public License for more details. 19 20 This license is contained in the file "COPYING", 21 which is included with this source code; it is available online at 22 http://www.gnu.org/licenses/gpl.html 23 24 Thursday, April 28, 1994 4:54:54 PM 25 26 Feb 17, 2000 (Loren Petrich): 27 Made the polygons' origin positions and sprite rectangles' depths 28 better adapted to long distances 29 30 Mar 12, 2000 (Loren Petrich): 31 Added shape descriptors to the wall-texture render objects 32 for the convenience of OpenGL rendering; 33 also added object indices to the sprite. 34 Weapons in hand have a special index. 35 36 Aug 9, 2000 (Loren Petrich): 37 A few obsolete constants deleted; 38 rendering functions moved to Rasterizer_SW.h 39 40 May 3, 2003 (Br'fin (Jeremy Parsons)) 41 Added LowLevelShape workaround for passing LowLevelShape info of sprites 42 instead of abusing/overflowing shape_descriptors 43 */ 44 45 #include "cseries.h" 46 #include "OGL_Headers.h" 47 #include "world.h" 48 #include "shape_descriptors.h" 49 50 /* ---------- constants */ 51 52 #define MINIMUM_VERTICES_PER_SCREEN_POLYGON ((short)3) 53 #define MAXIMUM_VERTICES_PER_SCREEN_POLYGON ((short)16) 54 55 enum /* transfer modes */ 56 { 57 _tinted_transfer, /* pass background through given shading table for non-transparent 58 pixels; config word is $mmnn: mm is a mask applied to a random number in [0,32) 59 which is then added to nn and used to retrieve a tinting table. �ordinary� (pathways-style) 60 tinting can be accomplished by passing an alternate shading table. */ 61 _solid_transfer, /* writes (0,0) color of texture for non-transparent pixels; does not 62 respect shading */ 63 _big_landscaped_transfer, /* does not distort texture (texture is anchored in screen-space) */ 64 _textured_transfer, /* distorts texture to match surface */ 65 _shadeless_transfer, /* does not respect any lighting information; uses a single shading table */ 66 _static_transfer /* writes static for non-transparent pixels (config word is the unsigned 67 chance in 64k that a non-transparent pixel will become transparent). does not respect 68 shading. */ 69 // _big_landscaped_transfer 70 }; 71 72 /* ---------- shading tables */ 73 74 #define MAXIMUM_SHADING_TABLE_INDEXES PIXEL8_MAXIMUM_COLORS 75 76 #define FIRST_SHADING_TABLE 0 77 78 struct tint_table8 79 { 80 pixel8 index[PIXEL8_MAXIMUM_COLORS]; 81 }; 82 83 struct tint_table16 84 { 85 pixel16 red[PIXEL16_MAXIMUM_COMPONENT+1]; 86 pixel16 green[PIXEL16_MAXIMUM_COMPONENT+1]; 87 pixel16 blue[PIXEL16_MAXIMUM_COMPONENT+1]; 88 }; 89 90 struct tint_table32 91 { 92 pixel32 red[PIXEL32_MAXIMUM_COMPONENT+1]; 93 pixel32 green[PIXEL32_MAXIMUM_COMPONENT+1]; 94 pixel32 blue[PIXEL32_MAXIMUM_COMPONENT+1]; 95 }; 96 97 /* ---------- structures */ 98 99 struct point2d 100 { 101 short x, y; 102 }; 103 104 /* ignore multiple shading tables if set */ 105 #define _SHADELESS_BIT 0x8000 106 107 class OGL_ModelData; 108 109 struct rectangle_definition 110 { 111 uint16 flags; 112 113 struct bitmap_definition *texture; 114 115 /* screen coordinates; x0<x1, y0<y1 */ 116 int16 x0, y0; 117 int16 x1, y1; 118 119 /* screen coordinates */ 120 int16 clip_left, clip_right; 121 int16 clip_top, clip_bottom; 122 123 /* depth at logical center (used to calculate light due to viewer) */ 124 // LP change: made this long-distance friendly 125 int32 depth; 126 127 /* ambient shading table index; many objects will be self-luminescent, so this may have 128 nothing to do with the polygon the object is sitting in */ 129 _fixed ambient_shade; 130 131 /* here are all the shading tables, crammed together in memory */ 132 void *shading_tables; 133 134 /* _tinted, _textured and _static are supported; _solid would be silly and _landscape 135 would be hard (but might be cool) */ 136 int16 transfer_mode, transfer_data; 137 138 /* mirrored horizontally and vertically if true */ 139 bool flip_vertical, flip_horizontal; 140 141 // LP addition: shape-descriptor value for the convenience of OpenGL; 142 // the lower byte is the frame 143 // Note that for the convenience of 3D-model rendering, more shape information may 144 // eventually have to be transmitted. 145 shape_descriptor ShapeDesc; 146 uint16 LowLevelShape; 147 148 // For the convenience of the teleporter: shrink to the median axis, 149 // with this position on the screen 150 int16 xc; 151 152 // Set overall, so as to make semitransparent chase-cam mode easy (0 to 1) 153 float Opacity; 154 155 // For the convenience of the OpenGL 3D-model renderer 156 _fixed ceiling_light; // The ambient_shade is the floor light 157 OGL_ModelData *ModelPtr; // For models 158 short ModelSequence, ModelFrame, NextModelFrame; // For model animation 159 float MixFrac; // Mixture between current and next frame 160 world_point3d Position; // In overall world coordinates 161 short ProjDistance; // Of centroid, from view plane 162 short Azimuth; // Facing angle 163 float Scale; // how big 164 float HorizScale; // For teleporting 165 short LiquidRelHeight; // Relative to object location 166 bool BelowLiquid; // Where the rendering is relative to the liquid 167 int LightDepth; // For finding the amount of "miner's light" 168 GLfloat LightDirection[3]; // To the "light point" 169 short WorldLeft, WorldBottom, WorldRight, WorldTop; 170 171 // Constructor required defaults rectangle_definitionrectangle_definition172 rectangle_definition() : 173 LowLevelShape(0) {} 174 }; 175 176 struct polygon_definition 177 { 178 uint16 flags; 179 180 struct bitmap_definition *texture; /* ignored for _tinted and _solid polygons */ 181 182 /* ambient shading table index */ 183 _fixed ambient_shade; 184 185 /* here are all the shading tables, crammed together in memory (unless this is a tinted 186 polygon in which case it is a single 256-byte tinting table) */ 187 void *shading_tables; 188 189 /* all modes legal */ 190 int16 transfer_mode, transfer_data; 191 192 // LP change: made this long-distance friendly 193 long_point3d origin; 194 world_vector3d vector; /* used only for vertically textured polygons */ 195 196 /* clockwise vertices for this convex polygon */ 197 int16 vertex_count; 198 point2d vertices[MAXIMUM_VERTICES_PER_SCREEN_POLYGON]; 199 200 // LP addition: shape-descriptor value for the convenience of OpenGL; 201 // the lower byte is the frame 202 shape_descriptor ShapeDesc; 203 204 // Whether the void is present on one side; useful for suppressing semitransparency 205 bool VoidPresent; 206 }; 207 208 /* ---------- globals */ 209 210 extern short bit_depth; 211 extern short interface_bit_depth; 212 213 extern short number_of_shading_tables, shading_table_fractional_bits, shading_table_size; 214 215 /* ---------- prototypes/SCOTTISH_TEXTURES.C */ 216 217 void allocate_texture_tables(void); 218 219 #endif 220