| 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 "SDL.h" |
| 41 |
|
| 42 |
#include "doomtype.h" |
| 43 |
#include "doomdef.h" |
| 44 |
// Needed because we are refering to patches. |
| 45 |
#include "r_data.h" |
| 46 |
|
| 47 |
// |
| 48 |
// VIDEO |
| 49 |
// |
| 50 |
|
| 51 |
// DWF 2012-05-10 |
| 52 |
// SetRatio sets the following global variables based on window geometry and |
| 53 |
// user preferences. The integer ratio is hardly used anymore, so further |
| 54 |
// simplification may be in order. |
| 55 |
void SetRatio(int width, int height); |
| 56 |
extern dboolean tallscreen; |
| 57 |
extern unsigned int ratio_multiplier, ratio_scale; |
| 58 |
extern float gl_ratio; |
| 59 |
extern int psprite_offset; // Needed for "tallscreen" modes |
| 60 |
|
| 61 |
#define CENTERY (SCREENHEIGHT/2) |
| 62 |
|
| 63 |
// Screen 0 is the screen updated by I_Update screen. |
| 64 |
// Screen 1 is an extra buffer. |
| 65 |
|
| 66 |
// array of pointers to color translation tables |
| 67 |
extern const byte *colrngs[]; |
| 68 |
|
| 69 |
// symbolic indices into color translation table pointer array |
| 70 |
typedef enum |
| 71 |
{ |
| 72 |
CR_DEFAULT, |
| 73 |
CR_BRICK, |
| 74 |
CR_TAN, |
| 75 |
CR_GRAY, |
| 76 |
CR_GREEN, |
| 77 |
CR_BROWN, |
| 78 |
CR_GOLD, |
| 79 |
CR_RED, |
| 80 |
CR_BLUE, |
| 81 |
CR_ORANGE, |
| 82 |
CR_YELLOW, |
| 83 |
CR_LIGHTBLUE, |
| 84 |
CR_BLACK, |
| 85 |
CR_PURPLE, |
| 86 |
CR_WHITE, |
| 87 |
CR_HUD_LIMIT, |
| 88 |
CR_DARKEN = CR_HUD_LIMIT, |
| 89 |
CR_DARKEN_BRICK, |
| 90 |
CR_DARKEN_TAN, |
| 91 |
CR_DARKEN_GRAY, |
| 92 |
CR_DARKEN_GREEN, |
| 93 |
CR_DARKEN_BROWN, |
| 94 |
CR_DARKEN_GOLD, |
| 95 |
CR_DARKEN_RED, |
| 96 |
CR_DARKEN_BLUE, |
| 97 |
CR_DARKEN_ORANGE, |
| 98 |
CR_DARKEN_YELLOW, |
| 99 |
CR_DARKEN_LIGHTBLUE, |
| 100 |
CR_DARKEN_BLACK, |
| 101 |
CR_DARKEN_PURPLE, |
| 102 |
CR_DARKEN_WHITE, |
| 103 |
CR_BLOOD, |
| 104 |
CR_BLOOD_GRAY = CR_BLOOD, |
| 105 |
CR_BLOOD_GREEN, |
| 106 |
CR_BLOOD_BLUE, |
| 107 |
CR_BLOOD_YELLOW, |
| 108 |
CR_BLOOD_BLACK, |
| 109 |
CR_BLOOD_PURPLE, |
| 110 |
CR_BLOOD_WHITE, |
| 111 |
CR_BLOOD_ORANGE, |
| 112 |
CR_LIMIT, |
| 113 |
} crange_idx_e; |
| 114 |
//jff 1/16/98 end palette color range additions |
| 115 |
|
| 116 |
typedef struct { |
| 117 |
byte *data; // pointer to the screen content |
| 118 |
dboolean not_on_heap; // if set, no malloc or free is preformed and |
| 119 |
// data never set to NULL. Used i.e. with SDL doublebuffer. |
| 120 |
int width; // the width of the surface |
| 121 |
int height; // the height of the surface, used when mallocing |
| 122 |
int pitch; // tha actual width of one line, used when mallocing |
| 123 |
} screeninfo_t; |
| 124 |
|
| 125 |
#define NUM_SCREENS 6 |
| 126 |
extern screeninfo_t screens[NUM_SCREENS]; |
| 127 |
extern int usegamma; |
| 128 |
|
| 129 |
// Varying bit-depth support -POPE |
| 130 |
// |
| 131 |
// For bilinear filtering, each palette color is pre-weighted and put in a |
| 132 |
// table for fast blending operations. These macros decide how many weights |
| 133 |
// to create for each color. The lower the number, the lower the blend |
| 134 |
// accuracy, which can produce very bad artifacts in texture filtering. |
| 135 |
#define VID_NUMCOLORWEIGHTS 64 |
| 136 |
#define VID_COLORWEIGHTMASK (VID_NUMCOLORWEIGHTS-1) |
| 137 |
#define VID_COLORWEIGHTBITS 6 |
| 138 |
|
| 139 |
// [XA] size of a single palette within PLAYPAL: |
| 140 |
// 256 colors * 3 bytes per color = 768 |
| 141 |
#define PALETTE_SIZE 768 |
| 142 |
|
| 143 |
// [XA] wonder why this was never a constant... silly id. :P |
| 144 |
#define NUM_GAMMA_LEVELS 5 |
| 145 |
|
| 146 |
// The available bit-depth modes |
| 147 |
typedef enum { |
| 148 |
VID_MODESW, |
| 149 |
VID_MODEGL |
| 150 |
} video_mode_t; |
| 151 |
|
| 152 |
void V_InitMode(video_mode_t mode); |
| 153 |
|
| 154 |
// video mode query interface |
| 155 |
dboolean V_IsSoftwareMode(void); |
| 156 |
dboolean V_IsOpenGLMode(void); |
| 157 |
|
| 158 |
// [XA] indexed lightmode query interface |
| 159 |
dboolean V_IsUILightmodeIndexed(void); |
| 160 |
dboolean V_IsAutomapLightmodeIndexed(void); |
| 161 |
dboolean V_IsMenuLightmodeIndexed(void); |
| 162 |
|
| 163 |
//jff 4/24/98 loads color translation lumps |
| 164 |
void V_InitColorTranslation(void); |
| 165 |
|
| 166 |
void V_InitFlexTranTable(void); |
| 167 |
|
| 168 |
// Allocates buffer screens, call before R_Init. |
| 169 |
void V_Init (void); |
| 170 |
|
| 171 |
// V_BeginUIDraw |
| 172 |
typedef void(*V_BeginUIDraw_f)(void); |
| 173 |
extern V_BeginUIDraw_f V_BeginUIDraw; |
| 174 |
|
| 175 |
// V_EndUIDraw |
| 176 |
typedef void(*V_EndUIDraw_f)(void); |
| 177 |
extern V_EndUIDraw_f V_EndUIDraw; |
| 178 |
|
| 179 |
// V_BeginAutomapDraw |
| 180 |
typedef void(*V_BeginAutomapDraw_f)(void); |
| 181 |
extern V_BeginAutomapDraw_f V_BeginAutomapDraw; |
| 182 |
|
| 183 |
// V_EndAutomapDraw |
| 184 |
typedef void(*V_EndAutomapDraw_f)(void); |
| 185 |
extern V_EndAutomapDraw_f V_EndAutomapDraw; |
| 186 |
|
| 187 |
// V_BeginMenuDraw |
| 188 |
typedef void(*V_BeginMenuDraw_f)(void); |
| 189 |
extern V_BeginMenuDraw_f V_BeginMenuDraw; |
| 190 |
|
| 191 |
// V_EndMenuDraw |
| 192 |
typedef void(*V_EndMenuDraw_f)(void); |
| 193 |
extern V_EndMenuDraw_f V_EndMenuDraw; |
| 194 |
|
| 195 |
// V_CopyRect |
| 196 |
typedef void (*V_CopyRect_f)(int srcscrn, int destscrn, |
| 197 |
int x, int y, |
| 198 |
int width, int height, |
| 199 |
enum patch_translation_e flags); |
| 200 |
extern V_CopyRect_f V_CopyRect; |
| 201 |
|
| 202 |
void V_CopyScreen(int srcscrn, int destscrn); |
| 203 |
|
| 204 |
// V_FillRect |
| 205 |
typedef void (*V_FillRect_f)(int scrn, int x, int y, |
| 206 |
int width, int height, byte colour); |
| 207 |
extern V_FillRect_f V_FillRect; |
| 208 |
|
| 209 |
// CPhipps - patch drawing |
| 210 |
// Consolidated into the 3 really useful functions: |
| 211 |
|
| 212 |
// V_DrawNumPatchGen - Draws the patch from lump num |
| 213 |
typedef void (*V_DrawNumPatchGen_f)(int x, int y, int scrn, |
| 214 |
int lump, dboolean center, int cm, |
| 215 |
enum patch_translation_e flags); |
| 216 |
extern V_DrawNumPatchGen_f V_DrawNumPatchGen; |
| 217 |
|
| 218 |
typedef void (*V_DrawNumPatchGenPrecise_f)(float x, float y, int scrn, |
| 219 |
int lump, dboolean center, int cm, |
| 220 |
enum patch_translation_e flags); |
| 221 |
extern V_DrawNumPatchGenPrecise_f V_DrawNumPatchGenPrecise; |
| 222 |
|
| 223 |
// V_DrawNumPatch - Draws the patch from lump "num" |
| 224 |
#define V_DrawNumPatch(x,y,s,n,t,f) V_DrawNumPatchGen(x,y,s,n,false,t,f) |
| 225 |
#define V_DrawNumPatchPrecise(x,y,s,n,t,f) V_DrawNumPatchGenPrecise(x,y,s,n,false,t,f) |
| 226 |
|
| 227 |
// V_DrawNamePatch - Draws the patch from lump "name" |
| 228 |
#define V_DrawNamePatch(x,y,s,n,t,f) V_DrawNumPatchGen(x,y,s,W_GetNumForName(n),false,t,f) |
| 229 |
#define V_DrawNamePatchPrecise(x,y,s,n,t,f) V_DrawNumPatchGenPrecise(x,y,s,W_GetNumForName(n),false,t,f) |
| 230 |
|
| 231 |
// These functions center patches if width > 320 : |
| 232 |
#define V_DrawNumPatchFS(x,y,s,n,t,f) V_DrawNumPatchGen(x,y,s,n,true,t,f) |
| 233 |
#define V_DrawNumPatchPreciseFS(x,y,s,n,t,f) V_DrawNumPatchGenPrecise(x,y,s,n,true,t,f) |
| 234 |
#define V_DrawNamePatchFS(x,y,s,n,t,f) V_DrawNumPatchGen(x,y,s,W_GetNumForName(n),true,t,f) |
| 235 |
#define V_DrawNamePatchPreciseFS(x,y,s,n,t,f) V_DrawNumPatchGenPrecise(x,y,s,W_GetNumForName(n),true,t,f) |
| 236 |
|
| 237 |
/* cph - |
| 238 |
* Functions to return width & height of a patch. |
| 239 |
* Doesn't really belong here, but is often used in conjunction with |
| 240 |
* this code. |
| 241 |
*/ |
| 242 |
#define V_NamePatchWidth(name) R_NumPatchWidth(W_GetNumForName(name)) |
| 243 |
#define V_NamePatchHeight(name) R_NumPatchHeight(W_GetNumForName(name)) |
| 244 |
|
| 245 |
// e6y |
| 246 |
typedef void (*V_FillFlat_f)(int lump, int scrn, int x, int y, int width, int height, enum patch_translation_e flags); |
| 247 |
extern V_FillFlat_f V_FillFlat; |
| 248 |
#define V_FillFlatName(flatname, scrn, x, y, width, height, flags) \ |
| 249 |
V_FillFlat(R_FlatNumForName(flatname), (scrn), (x), (y), (width), (height), (flags)) |
| 250 |
|
| 251 |
typedef void (*V_FillPatch_f)(int lump, int scrn, int x, int y, int width, int height, enum patch_translation_e flags); |
| 252 |
extern V_FillPatch_f V_FillPatch; |
| 253 |
#define V_FillPatchName(name, scrn, x, y, width, height, flags) \ |
| 254 |
V_FillPatch(W_GetNumForName(name), (scrn), (x), (y), (width), (height), (flags)) |
| 255 |
|
| 256 |
|
| 257 |
/* cphipps 10/99: function to tile a flat over the screen */ |
| 258 |
typedef void (*V_DrawBackground_f)(const char* flatname, int scrn); |
| 259 |
extern V_DrawBackground_f V_DrawBackground; |
| 260 |
|
| 261 |
typedef void (*V_DrawShaded_f)(int scrn, int x, int y, int width, int height, int shade); |
| 262 |
extern V_DrawShaded_f V_DrawShaded; |
| 263 |
|
| 264 |
// CPhipps - function to set the palette to palette number pal. |
| 265 |
void V_TouchPalette(void); |
| 266 |
void V_SetPalette(int pal); |
| 267 |
void V_SetPlayPal(int playpal_index); |
| 268 |
|
| 269 |
// Alt-Enter: fullscreen <-> windowed |
| 270 |
void V_ToggleFullscreen(void); |
| 271 |
void V_ChangeScreenResolution(void); |
| 272 |
|
| 273 |
// CPhipps - function to plot a pixel |
| 274 |
|
| 275 |
// V_PlotPixel |
| 276 |
typedef void (*V_PlotPixel_f)(int,int,int,byte); |
| 277 |
extern V_PlotPixel_f V_PlotPixel; |
| 278 |
|
| 279 |
typedef struct |
| 280 |
{ |
| 281 |
int x, y; |
| 282 |
float fx, fy; |
| 283 |
} fpoint_t; |
| 284 |
|
| 285 |
typedef struct |
| 286 |
{ |
| 287 |
fpoint_t a, b; |
| 288 |
} fline_t; |
| 289 |
|
| 290 |
// V_DrawLine |
| 291 |
typedef void (*V_DrawLine_f)(fline_t* fl, int color); |
| 292 |
extern V_DrawLine_f V_DrawLine; |
| 293 |
|
| 294 |
// V_DrawLineWu |
| 295 |
typedef void (*V_DrawLineWu_f)(fline_t* fl, int color); |
| 296 |
extern V_DrawLineWu_f V_DrawLineWu; |
| 297 |
|
| 298 |
// V_PlotPixelWu |
| 299 |
typedef void (*V_PlotPixelWu_f)(int scrn, int x, int y, byte color, int weight); |
| 300 |
extern V_PlotPixelWu_f V_PlotPixelWu; |
| 301 |
|
| 302 |
void V_AllocScreen(screeninfo_t *scrn); |
| 303 |
void V_AllocScreens(); |
| 304 |
void V_FreeScreen(screeninfo_t *scrn); |
| 305 |
void V_FreeScreens(); |
| 306 |
|
| 307 |
const unsigned char* V_GetPlaypal(void); |
| 308 |
void V_FreePlaypal(void); |
| 309 |
|
| 310 |
// [XA] get number of palettes in the current playpal |
| 311 |
int V_GetPlaypalCount(void); |
| 312 |
|
| 313 |
SDL_Color V_GetPatchColor (int lumpnum); |
| 314 |
|
| 315 |
// e6y: wide-res |
| 316 |
void V_ClearBorder(void); |
| 317 |
|
| 318 |
void V_GetWideRect(int *x, int *y, int *w, int *h, enum patch_translation_e flags); |
| 319 |
|
| 320 |
int V_BestColor(const unsigned char *palette, int r, int g, int b); |
| 321 |
|
| 322 |
// [FG] colored blood and gibs |
| 323 |
int V_BloodColor(int blood); |
| 324 |
|
| 325 |
#include "gl_struct.h" |
| 326 |
|
| 327 |
void V_FillRectVPT(int scrn, int x, int y, int width, int height, byte color, enum patch_translation_e flags); |
| 328 |
int V_FillHeightVPT(int scrn, int y, int height, byte color, enum patch_translation_e flags); |
| 329 |
|
| 330 |
// heretic |
| 331 |
|
| 332 |
void V_DrawRawScreen(const char *lump_name); |
| 333 |
void V_DrawRawScreenSection(const char *lump_name, int source_offset, int dest_y_offset, int dest_y_limit); |
| 334 |
void V_DrawShadowedNumPatch(int x, int y, int lump); |
| 335 |
void V_DrawShadowedNamePatch(int x, int y, const char* name); |
| 336 |
void V_DrawTLNumPatch(int x, int y, int lump); |
| 337 |
void V_DrawTLNamePatch(int x, int y, const char* name); |
| 338 |
void V_DrawAltTLNumPatch(int x, int y, int lump); |
| 339 |
|
| 340 |
#endif |