1 /* Emacs style mode select -*- C++ -*- 2 *----------------------------------------------------------------------------- 3 * 4 * 5 * PrBoom: a Doom port merged with LxDoom and LSDLDoom 6 * based on BOOM, a modified and improved DOOM engine 7 * Copyright (C) 1999 by 8 * id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman 9 * Copyright (C) 1999-2000 by 10 * Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze 11 * Copyright 2005, 2006 by 12 * Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko 13 * 14 * This program is free software; you can redistribute it and/or 15 * modify it under the terms of the GNU General Public License 16 * as published by the Free Software Foundation; either version 2 17 * of the License, or (at your option) any later version. 18 * 19 * This program is distributed in the hope that it will be useful, 20 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * GNU General Public License for more details. 23 * 24 * You should have received a copy of the GNU General Public License 25 * along with this program; if not, write to the Free Software 26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 27 * 02111-1307, USA. 28 * 29 * DESCRIPTION: 30 * Gamma correction LUT. 31 * Color range translation support 32 * Functions to draw patches (by post) directly to screen. 33 * Functions to blit a block to the screen. 34 * 35 *-----------------------------------------------------------------------------*/ 36 37 #ifndef __V_VIDEO__ 38 #define __V_VIDEO__ 39 40 #include "doomtype.h" 41 #include "doomdef.h" 42 // Needed because we are refering to patches. 43 #include "r_data.h" 44 45 // 46 // VIDEO 47 // 48 49 #define CENTERY (SCREENHEIGHT/2) 50 51 // Screen 0 is the screen updated by I_Update screen. 52 // Screen 1 is an extra buffer. 53 54 // array of pointers to color translation tables 55 extern const byte *colrngs[]; 56 57 // symbolic indices into color translation table pointer array 58 typedef enum 59 { 60 CR_BRICK, //0 61 CR_TAN, //1 62 CR_GRAY, //2 63 CR_GREEN, //3 64 CR_BROWN, //4 65 CR_GOLD, //5 66 CR_RED, //6 67 CR_BLUE, //7 68 CR_ORANGE, //8 69 CR_YELLOW, //9 70 CR_BLUE2, //10 // proff 71 CR_LIMIT //11 //jff 2/27/98 added for range check 72 } crange_idx_e; 73 //jff 1/16/98 end palette color range additions 74 75 #define CR_DEFAULT CR_RED /* default value for out of range colors */ 76 77 typedef struct { 78 byte *data; // pointer to the screen content 79 boolean not_on_heap; // if set, no malloc or free is preformed and 80 // data never set to NULL. Used i.e. with SDL doublebuffer. 81 int width; // the width of the surface 82 int height; // the height of the surface, used when mallocing 83 int byte_pitch; // tha actual width of one line, used when mallocing 84 int short_pitch; // tha actual width of one line, used when mallocing 85 int int_pitch; // tha actual width of one line, used when mallocing 86 } screeninfo_t; 87 88 #define NUM_SCREENS 6 89 extern screeninfo_t screens[NUM_SCREENS]; 90 extern int usegamma; 91 92 // Varying bit-depth support -POPE 93 // 94 // For bilinear filtering, each palette color is pre-weighted and put in a 95 // table for fast blending operations. These macros decide how many weights 96 // to create for each color. The lower the number, the lower the blend 97 // accuracy, which can produce very bad artifacts in texture filtering. 98 #define VID_NUMCOLORWEIGHTS 64 99 #define VID_COLORWEIGHTMASK (VID_NUMCOLORWEIGHTS-1) 100 #define VID_COLORWEIGHTBITS 6 101 102 // Palettes for converting from 8 bit color to 16 and 32 bit. Also 103 // contains the weighted versions of each palette color for filtering 104 // operations 105 extern unsigned short *V_Palette15; 106 extern unsigned short *V_Palette16; 107 extern unsigned int *V_Palette32; 108 109 #define VID_PAL15(color, weight) V_Palette15[ (color)*VID_NUMCOLORWEIGHTS + (weight) ] 110 #define VID_PAL16(color, weight) V_Palette16[ (color)*VID_NUMCOLORWEIGHTS + (weight) ] 111 #define VID_PAL32(color, weight) V_Palette32[ (color)*VID_NUMCOLORWEIGHTS + (weight) ] 112 113 // The available bit-depth modes 114 typedef enum { 115 VID_MODE8, 116 VID_MODE15, 117 VID_MODE16, 118 VID_MODE32, 119 VID_MODEGL, 120 VID_MODEMAX 121 } video_mode_t; 122 123 extern const char *default_videomode; 124 125 void V_InitMode(video_mode_t mode); 126 127 // video mode query interface 128 video_mode_t V_GetMode(void); 129 int V_GetModePixelDepth(video_mode_t mode); 130 int V_GetNumPixelBits(void); 131 int V_GetPixelDepth(void); 132 133 //jff 4/24/98 loads color translation lumps 134 void V_InitColorTranslation(void); 135 136 // Allocates buffer screens, call before R_Init. 137 void V_Init (void); 138 139 // V_CopyRect 140 typedef void (*V_CopyRect_f)(int srcx, int srcy, int srcscrn, 141 int width, int height, 142 int destx, int desty, int destscrn, 143 enum patch_translation_e flags); 144 extern V_CopyRect_f V_CopyRect; 145 146 // V_FillRect 147 typedef void (*V_FillRect_f)(int scrn, int x, int y, 148 int width, int height, byte colour); 149 extern V_FillRect_f V_FillRect; 150 151 // CPhipps - patch drawing 152 // Consolidated into the 3 really useful functions: 153 154 // V_DrawNumPatch - Draws the patch from lump num 155 typedef void (*V_DrawNumPatch_f)(int x, int y, int scrn, 156 int lump, int cm, 157 enum patch_translation_e flags); 158 extern V_DrawNumPatch_f V_DrawNumPatch; 159 160 // V_DrawNamePatch - Draws the patch from lump "name" 161 #define V_DrawNamePatch(x,y,s,n,t,f) V_DrawNumPatch(x,y,s,W_GetNumForName(n),t,f) 162 163 /* cph - 164 * Functions to return width & height of a patch. 165 * Doesn't really belong here, but is often used in conjunction with 166 * this code. 167 */ 168 #define V_NamePatchWidth(name) R_NumPatchWidth(W_GetNumForName(name)) 169 #define V_NamePatchHeight(name) R_NumPatchHeight(W_GetNumForName(name)) 170 171 /* cphipps 10/99: function to tile a flat over the screen */ 172 typedef void (*V_DrawBackground_f)(const char* flatname, int scrn); 173 extern V_DrawBackground_f V_DrawBackground; 174 175 void V_DestroyUnusedTrueColorPalettes(void); 176 // CPhipps - function to set the palette to palette number pal. 177 void V_SetPalette(int pal); 178 179 // CPhipps - function to plot a pixel 180 181 // V_PlotPixel 182 typedef void (*V_PlotPixel_f)(int,int,int,byte); 183 extern V_PlotPixel_f V_PlotPixel; 184 185 typedef struct 186 { 187 int x, y; 188 } fpoint_t; 189 190 typedef struct 191 { 192 fpoint_t a, b; 193 } fline_t; 194 195 // V_DrawLine 196 typedef void (*V_DrawLine_f)(fline_t* fl, int color); 197 extern V_DrawLine_f V_DrawLine; 198 199 void V_AllocScreen(screeninfo_t *scrn); 200 void V_AllocScreens(); 201 void V_FreeScreen(screeninfo_t *scrn); 202 void V_FreeScreens(); 203 204 #ifdef GL_DOOM 205 #include "gl_struct.h" 206 #endif 207 #endif 208