1 // Emacs style mode select -*- C++ -*- 2 //----------------------------------------------------------------------------- 3 // 4 // $Id: hw_defs.h 1257 2016-09-20 17:14:21Z wesleyjohnson $ 5 // 6 // Copyright (C) 1998-2016 by DooM Legacy Team. 7 // 8 // This program is free software; you can redistribute it and/or 9 // modify it under the terms of the GNU General Public License 10 // as published by the Free Software Foundation; either version 2 11 // of the License, or (at your option) any later version. 12 // 13 // This program is distributed in the hope that it will be useful, 14 // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 // GNU General Public License for more details. 17 // 18 // 19 // $Log: hw_defs.h,v $ 20 // Revision 1.17 2001/12/26 15:56:12 hurdler 21 // Manage transparent wall a little better 22 // 23 // Revision 1.16 2001/12/15 18:41:36 hurdler 24 // small commit, mainly splitscreen fix 25 // 26 // Revision 1.15 2001/08/26 15:27:29 bpereira 27 // added fov for glide and fixed newcoronas code 28 // 29 // Revision 1.14 2001/08/19 15:40:07 bpereira 30 // added Treansform (and lighting) to glide 31 // 32 // Revision 1.13 2001/08/09 21:35:23 hurdler 33 // Add translucent 3D water in hw mode 34 // 35 // Revision 1.12 2001/08/07 00:44:05 hurdler 36 // MD2 implementation is getting better but still need lots of work 37 // 38 // Revision 1.11 2001/02/28 17:50:56 bpereira 39 // Revision 1.10 2001/02/10 12:27:14 bpereira 40 // Revision 1.9 2001/01/25 18:56:27 bpereira 41 // Revision 1.8 2000/11/02 19:49:39 bpereira 42 // Revision 1.7 2000/08/31 14:30:57 bpereira 43 // Revision 1.6 2000/07/01 09:23:50 bpereira 44 // Revision 1.5 2000/05/05 18:00:05 bpereira 45 // 46 // Revision 1.4 2000/04/18 16:07:16 hurdler 47 // better support of decals 48 // 49 // Revision 1.3 2000/04/11 01:00:59 hurdler 50 // Better coronas support 51 // 52 // Revision 1.2 2000/02/27 00:42:11 hurdler 53 // Revision 1.1.1.1 2000/02/22 20:32:33 hurdler 54 // Initial import into CVS (v1.29 pr3) 55 // 56 // 57 // DESCRIPTION: 58 // 3D hardware renderer API definitions 59 // 60 //----------------------------------------------------------------------------- 61 62 #ifndef HW_DEFS_H 63 #define HW_DEFS_H 64 65 #include "doomdef.h" 66 #include "doomtype.h" 67 68 // ========================================================================== 69 // SIMPLE TYPES 70 // ========================================================================== 71 72 #if 1 73 // 64bit safe 74 typedef int32_t FINT; // unused 75 typedef uint32_t FUINT; 76 //typedef unsigned char FUBYTE; 77 typedef uint32_t FBITFIELD; 78 //typedef float FLOAT; 79 //typedef unsigned char FBOOLEAN; 80 #else 81 typedef long FINT; // unused 82 typedef unsigned long FUINT; 83 typedef unsigned char FUBYTE; 84 typedef unsigned long FBITFIELD; 85 typedef float FLOAT; 86 typedef unsigned char FBOOLEAN; 87 #endif 88 89 // ========================================================================== 90 // MATHS 91 // ========================================================================== 92 93 // Constants 94 #undef PI 95 #define PI (3.1415926535897932) 96 #define DEGREE (.01745328f) // 2*PI/360 97 98 99 // ========================================================================== 100 // COLORS 101 // ========================================================================== 102 103 // byte value for paletted graphics, which represent the transparent color 104 #define HWR_PATCHES_CHROMAKEY_COLORINDEX 247 105 #define HWR_CHROMAKEY_EQUIVALENTCOLORINDEX 0 106 107 // the chroma key color shows on border sprites, set it to black 108 #define HWR_PATCHES_CHROMAKEY_COLORVALUE (0x00000000) //RGBA format as in grSstWinOpen() 109 110 // RGBA Color components with float type ranging [ 0 ... 1 ] 111 typedef struct 112 { 113 float red; 114 float green; 115 float blue; 116 float alpha; 117 } RGBA_float_t; 118 119 #if 0 120 // Unused 121 typedef struct 122 { 123 byte alpha; 124 byte red; 125 byte green; 126 byte blue; 127 } ARGB_t; 128 #endif 129 130 131 132 // ========================================================================== 133 // VECTORS 134 // ========================================================================== 135 136 // Simple 2D coordinate 137 typedef struct 138 { 139 float x,y; 140 } v2d_t; 141 142 // Simple 3D vector 143 typedef struct FVector 144 { 145 float x,y,z; 146 } v3d_t; 147 148 // [WDJ] joint 3D model vector (vertex coords + texture coords) 149 // used for wallVerts and HWR API 150 // No more extra copying 151 typedef struct 152 { 153 float x,y,z; 154 float sow,tow; // texture coordinates (s over w) (t over w) 155 // float w; // only set to 1.0 (unused) 156 #ifdef _GLIDE_ARGB_ 157 FUINT argb; // flat-shaded color (used only in Glide, maybe) 158 #endif 159 } vxtx3d_t; 160 161 //Hurdler: Transform (coords + angles) 162 //BP: transform order : scale(rotation_x(rotation_y(translation(v)))) 163 typedef struct 164 { 165 float x,y,z; // position 166 float anglex,angley; // aimingangle / viewangle 167 float scalex,scaley,scalez; 168 float fovxangle, fovyangle; 169 int splitscreen; 170 } FTransform_t; 171 172 173 // ========================================================================== 174 // RENDER MODES 175 // ========================================================================== 176 177 // Flags describing how to render a polygon 178 // You pass a combination of these flags to DrawPolygon() 179 typedef enum 180 { 181 // the first 5 are mutually exclusive Blending 182 PF_Masked = 0x00000001, // Poly is alpha scaled and 0 alpha pels are discarded (holes in texture) 183 PF_Translucent = 0x00000002, // Poly is transparent, alpha = level of transparency 184 PF_Additive = 0x00000084, // Poly is added to the frame buffer 185 PF_Environment = 0x00000008, // Poly should be drawn environment mapped. 186 // Hurdler: used for text drawing 187 PF_Substractive = 0x00000010, // for splat 188 PF_Fog = PF_Translucent, // Fog sheet, alpha = translucency 189 // PF_Fog = 0x00000020, // Fog sheet, alpha = translucency 190 191 // additional effects 192 PF_NoAlphaTest = 0x00000080, // hidden param, used by Additive 193 PF_Blending = (PF_Environment|PF_Additive|PF_Translucent|PF_Masked|PF_Substractive)&~PF_NoAlphaTest, 194 195 // other flag bits 196 PF_Occlude = 0x00000100, // Update the depth buffer 197 PF_NoDepthTest = 0x00000200, // Disable the depth test mode 198 PF_Invisible = 0x00000400, // Disable write to color buffer 199 PF_Decal = 0x00000800, // Enable polygon offset 200 PF_Modulated = 0x00001000, // Modulation ( multiply output with constant ARGB ) 201 // When set, pass the color constant into the FSurfaceInfo -> FlatColor 202 PF_NoTexture = 0x00002000, // Use the small white texture 203 PF_Corona = 0x00004000, // Tell the rendrer we are drawing a corona 204 PF_MD2 = 0x00008000, // Tell the rendrer we are drawing an MD2 205 PF_Clip = 0x40000000, // clip to frustum and nearz plane (glide only, automatic in opengl) 206 PF_NoZClip = 0x20000000, // in conjonction with PF_Clip 207 PF_Debug = 0x80000000 // print debug message in driver :) 208 } PolyFlags_e; 209 210 211 typedef enum 212 { 213 SF_DYNLIGHT = 0x00000001, 214 215 } SurfFlags_e; 216 217 typedef enum 218 { 219 TF_WRAPX = 0x00000001, // wrap around X 220 TF_WRAPY = 0x00000002, // wrap around Y 221 TF_WRAPXY = TF_WRAPY | TF_WRAPX, // very common so use alias is more easy 222 TF_CHROMAKEYED = 0x00000010, 223 TF_Her_Raw_Pic = 0x00000020, // the lump is a raw heretic pic 224 TF_TRANSPARENT = 0x00000040, // texture with some alpha=0 225 TF_Opaquetrans = 0x00000100, // Some translucent pixels are opaque (fx1) 226 TF_Fogsheet = 0x00000200, // Generate a fog sheet 227 } TextureFlags_e; 228 229 #ifdef TODO 230 struct FTextureInfo_s 231 { 232 FUINT Width; // Pixels 233 FUINT Height; // Pixels 234 byte *TextureData; // Image data 235 FUINT Format; // FORMAT_RGB, ALPHA ... 236 FBITFIELD Flags; // Flags to tell driver about texture (see ETextureFlags) 237 void DriverExtra; // (OpenGL texture object nr, ... ) 238 // chromakey enabled,... 239 240 struct FTextureInfo_s * next; // Manage list of downloaded textures. 241 }; 242 typedef struct FTextureInfo_s FTextureInfo_t; 243 #else 244 typedef struct Mipmap_s FTextureInfo_t; 245 #endif 246 247 // Description of a renderable surface 248 typedef struct 249 { 250 FUINT polyflags; // PF_ flags (used for blend) 251 FUINT texflags; // TF_ flags (used for transparent) 252 RGBA_t FlatColor; // Flat-shaded color used with PF_Modulated mode 253 } FSurfaceInfo_t; 254 255 //Hurdler: added for backward compatibility 256 typedef enum { 257 HWD_SET_FOG_TABLE = 1, 258 HWD_SET_FOG_MODE, 259 HWD_SET_FOG_COLOR, 260 HWD_SET_FOG_DENSITY, 261 HWD_SET_FOV, 262 HWD_SET_POLYGON_SMOOTH, 263 HWD_SET_TINT_COLOR, // damage and special object palette 264 HWD_SET_TEXTUREFILTERMODE, 265 HWD_NUMSTATE, 266 // [WDJ] Stifle compiler complaints 267 // Unknown where this value is ever set 268 HWD_MIRROR_77 = 77 // see SetSpecialState where it does ClearBuffer 269 } hwd_specialstate_e; 270 271 typedef enum { 272 HWD_SET_TEXTUREFILTER_POINTSAMPLED, 273 HWD_SET_TEXTUREFILTER_BILINEAR, 274 HWD_SET_TEXTUREFILTER_TRILINEAR, 275 HWD_SET_TEXTUREFILTER_MIXED1, 276 HWD_SET_TEXTUREFILTER_MIXED2, 277 } hwd_filtermode_e; 278 279 280 #endif // HW_DEFS_H 281