| 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 |
* |
| 31 |
*--------------------------------------------------------------------- |
| 32 |
*/ |
| 33 |
|
| 34 |
#ifdef HAVE_CONFIG_H |
| 35 |
#include "config.h" |
| 36 |
#endif |
| 37 |
|
| 38 |
#include <SDL.h> |
| 39 |
|
| 40 |
#include <math.h> |
| 41 |
|
| 42 |
#include "doomstat.h" |
| 43 |
#include "lprintf.h" |
| 44 |
#include "v_video.h" |
| 45 |
#include "r_main.h" |
| 46 |
#include "gl_intern.h" |
| 47 |
#include "gl_opengl.h" |
| 48 |
#include "e6y.h" |
| 49 |
|
| 50 |
#include "dsda/configuration.h" |
| 51 |
|
| 52 |
dboolean gl_ui_lightmode_indexed = false; |
| 53 |
dboolean gl_automap_lightmode_indexed = false; |
| 54 |
dboolean gl_menu_lightmode_indexed = false; |
| 55 |
|
| 56 |
static float lighttable[5][256]; |
| 57 |
|
| 58 |
/* |
| 59 |
* lookuptable for lightvalues |
| 60 |
* calculated as follow: |
| 61 |
* floatlight=(1.0-exp((light^3)*gamma)) / (1.0-exp(1.0*gamma)); |
| 62 |
* gamma=-0,2;-2,0;-4,0;-6,0;-8,0 |
| 63 |
* light=0,0 .. 1,0 |
| 64 |
*/ |
| 65 |
void gld_InitLightTable(void) |
| 66 |
{ |
| 67 |
int i, g; |
| 68 |
float gamma[5] = {-0.2f, -2.0f, -4.0f, -6.0f, -8.0f}; |
| 69 |
|
| 70 |
for (g = 0; g < 5; g++) |
| 71 |
{ |
| 72 |
for (i = 0; i < 256; i++) |
| 73 |
{ |
| 74 |
lighttable[g][i] = (float)((1.0f - exp(pow(i / 255.0f, 3) * gamma[g])) / (1.0f - exp(1.0f * gamma[g]))); |
| 75 |
} |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
float gld_Calc2DLightLevel(int lightlevel) |
| 80 |
{ |
| 81 |
return lighttable[usegamma][BETWEEN(0, 255, lightlevel)]; |
| 82 |
} |
| 83 |
|
| 84 |
float gld_CalcLightLevel(int lightlevel) |
| 85 |
{ |
| 86 |
int light; |
| 87 |
|
| 88 |
light = BETWEEN(0, 255, lightlevel); |
| 89 |
|
| 90 |
return (float)light/255.0f; |
| 91 |
} |
| 92 |
|
| 93 |
void gld_StaticLightAlpha(float light, float alpha) |
| 94 |
{ |
| 95 |
player_t *player = &players[displayplayer]; |
| 96 |
|
| 97 |
glColor4f(1.0f, 1.0f, 1.0f, alpha); |
| 98 |
|
| 99 |
glsl_SetLightLevel((player->fixedcolormap ? 1.0f : light)); |
| 100 |
} |
| 101 |
|
| 102 |
// [XA] return amount of light to add from the player's gun flash. |
| 103 |
int gld_GetGunFlashLight(void) |
| 104 |
{ |
| 105 |
return (extralight << 4); |
| 106 |
} |