mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 17:01:51 +00:00
Extra files to support previous commits. Change hashing stuff to intptr_t so it can be used as a dictionary of pointers, change brightness/gamma/contrast to float instead of double, other misc changes. None of these commits build on their own so don't even bother.
git-svn-id: https://svn.eduke32.com/eduke32@4606 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
105bc3f413
commit
d279344697
7 changed files with 78 additions and 69 deletions
|
@ -188,13 +188,13 @@ void showframe(int32_t);
|
|||
int32_t setpalette(int32_t start, int32_t num);
|
||||
//int32_t getpalette(int32_t start, int32_t num, char *dapal);
|
||||
int32_t setgamma(void);
|
||||
extern double vid_gamma, vid_contrast, vid_brightness;
|
||||
extern float vid_gamma, vid_contrast, vid_brightness;
|
||||
|
||||
#define DEFAULT_GAMMA 1.0
|
||||
#define DEFAULT_CONTRAST 1.0
|
||||
#define DEFAULT_BRIGHTNESS 0.0
|
||||
#define DEFAULT_GAMMA 1.0f
|
||||
#define DEFAULT_CONTRAST 1.0f
|
||||
#define DEFAULT_BRIGHTNESS 0.0f
|
||||
|
||||
#define GAMMA_CALC ((int32_t)(min(max((double)((vid_gamma-1.0)*10.0),0),15)))
|
||||
#define GAMMA_CALC ((int32_t)(min(max((float)((vid_gamma-1.0f)*10.0f),0.f),15.f)))
|
||||
|
||||
//int32_t switchrendermethod(int32_t,int32_t); // 0 = software, 1 = opengl | bool = reinit
|
||||
|
||||
|
|
|
@ -177,6 +177,14 @@ static inline long lround(double num)
|
|||
#define nearbyintf rintf
|
||||
#endif
|
||||
|
||||
#if defined(__arm__)
|
||||
#define Bsqrt __sqrt
|
||||
#define Bsqrtf __sqrtf
|
||||
#else
|
||||
#define Bsqrt sqrt
|
||||
#define Bsqrtf sqrtf
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
# define NULL ((void *)0)
|
||||
#endif
|
||||
|
|
|
@ -422,9 +422,9 @@ int32_t baselayer_init(void)
|
|||
{ "r_tror_nomaskpass", "enable/disable additional pass in TROR software rendering", (void *)&r_tror_nomaskpass, CVAR_BOOL, 0, 1 },
|
||||
#endif
|
||||
{ "r_windowpositioning", "enable/disable window position memory", (void *) &windowpos, CVAR_BOOL, 0, 1 },
|
||||
{ "vid_gamma","adjusts gamma component of gamma ramp",(void *) &vid_gamma, CVAR_DOUBLE|CVAR_FUNCPTR, 0, 10 },
|
||||
{ "vid_contrast","adjusts contrast component of gamma ramp",(void *) &vid_contrast, CVAR_DOUBLE|CVAR_FUNCPTR, 0, 10 },
|
||||
{ "vid_brightness","adjusts brightness component of gamma ramp",(void *) &vid_brightness, CVAR_DOUBLE|CVAR_FUNCPTR, 0, 10 },
|
||||
{ "vid_gamma","adjusts gamma component of gamma ramp",(void *) &vid_gamma, CVAR_FLOAT|CVAR_FUNCPTR, 0.f, 10.f },
|
||||
{ "vid_contrast","adjusts contrast component of gamma ramp",(void *) &vid_contrast, CVAR_FLOAT|CVAR_FUNCPTR, 0.f, 10.f },
|
||||
{ "vid_brightness","adjusts brightness component of gamma ramp",(void *) &vid_brightness, CVAR_FLOAT|CVAR_FUNCPTR, 0.f, 10.f },
|
||||
#ifdef DEBUGGINGAIDS
|
||||
{ "debug1","debug counter",(void *) &debug1, CVAR_FLOAT, -100000, 100000 },
|
||||
{ "debug2","debug counter",(void *) &debug2, CVAR_FLOAT, -100000, 100000 },
|
||||
|
|
|
@ -91,7 +91,7 @@ int32_t synctics = 0, lockclock = 0;
|
|||
|
||||
// those ones save the respective 3d video vars while in 2d mode
|
||||
// so that exiting from mapster32 in 2d mode saves the correct ones
|
||||
double vid_gamma_3d=-1, vid_contrast_3d=-1, vid_brightness_3d=-1;
|
||||
float vid_gamma_3d=-1, vid_contrast_3d=-1, vid_brightness_3d=-1;
|
||||
|
||||
int32_t xdim2d = 640, ydim2d = 480, xdimgame = 640, ydimgame = 480, bppgame = 8;
|
||||
int32_t forcesetup = 1;
|
||||
|
|
|
@ -59,7 +59,10 @@ L_State g_engState;
|
|||
# define CLASSIC_NONPOW2_YSIZE_WALLS
|
||||
#endif
|
||||
|
||||
#if !defined(__arm__) && !defined(GEKKO)
|
||||
#define HIGH_PRECISION_SPRITE
|
||||
#endif
|
||||
|
||||
#define MULTI_COLUMN_VLINE
|
||||
//#define DEBUG_TILESIZY_512
|
||||
//#define DEBUG_TILEOFFSETS
|
||||
|
@ -156,9 +159,9 @@ uint32_t r_screenxy = 0;
|
|||
|
||||
int32_t curbrightness = 0, gammabrightness = 0;
|
||||
|
||||
double vid_gamma = DEFAULT_GAMMA;
|
||||
double vid_contrast = DEFAULT_CONTRAST;
|
||||
double vid_brightness = DEFAULT_BRIGHTNESS;
|
||||
float vid_gamma = DEFAULT_GAMMA;
|
||||
float vid_contrast = DEFAULT_CONTRAST;
|
||||
float vid_brightness = DEFAULT_BRIGHTNESS;
|
||||
|
||||
//Textured Map variables
|
||||
static char globalpolytype;
|
||||
|
@ -2428,8 +2431,9 @@ static int32_t bakframeplace[4], bakxsiz[4], bakysiz[4];
|
|||
static int32_t bakwindowx1[4], bakwindowy1[4];
|
||||
static int32_t bakwindowx2[4], bakwindowy2[4];
|
||||
#ifdef USE_OPENGL
|
||||
static int32_t bakrendmode,baktile;
|
||||
static int32_t bakrendmode;
|
||||
#endif
|
||||
static int32_t baktile;
|
||||
|
||||
char apptitle[256] = "Build Engine";
|
||||
|
||||
|
@ -2512,9 +2516,7 @@ int32_t engine_addtsprite(int16_t z, int16_t sectnum)
|
|||
}
|
||||
}
|
||||
else
|
||||
#ifdef YAX_ENABLE
|
||||
if (yax_nomaskpass==0)
|
||||
#endif
|
||||
{
|
||||
sortcnt = &yax_spritesortcnt[yax_globallev];
|
||||
if (*sortcnt >= MAXSPRITESONSCREEN)
|
||||
|
@ -5579,32 +5581,6 @@ static void setup_globals_sprite1(const spritetype *tspr, const sectortype *sec,
|
|||
//
|
||||
// drawsprite (internal)
|
||||
//
|
||||
static void drawsprite_opengl(int32_t snum)
|
||||
{
|
||||
//============================================================================= //POLYMOST BEGINS
|
||||
#ifdef USE_OPENGL
|
||||
if (getrendermode() == REND_POLYMOST)
|
||||
{
|
||||
polymost_drawsprite(snum);
|
||||
bglDisable(GL_POLYGON_OFFSET_FILL);
|
||||
}
|
||||
# ifdef POLYMER
|
||||
else if (getrendermode() == REND_POLYMER)
|
||||
{
|
||||
bglEnable(GL_ALPHA_TEST);
|
||||
bglEnable(GL_BLEND);
|
||||
|
||||
polymer_drawsprite(snum);
|
||||
|
||||
bglDisable(GL_BLEND);
|
||||
bglDisable(GL_ALPHA_TEST);
|
||||
}
|
||||
# endif
|
||||
#else
|
||||
UNREFERENCED_PARAMETER(snum);
|
||||
#endif
|
||||
//============================================================================= //POLYMOST ENDS
|
||||
}
|
||||
|
||||
|
||||
static uint8_t falpha_to_blend(float alpha, int32_t *cstatptr, int32_t transbit1, int32_t transbit2)
|
||||
|
@ -6614,10 +6590,27 @@ draw_as_face_sprite:
|
|||
|
||||
static void drawsprite(int32_t snum)
|
||||
{
|
||||
if (getrendermode() >= REND_POLYMOST)
|
||||
drawsprite_opengl(snum);
|
||||
else
|
||||
switch (getrendermode())
|
||||
{
|
||||
case REND_CLASSIC:
|
||||
drawsprite_classic(snum);
|
||||
return;
|
||||
#ifdef USE_OPENGL
|
||||
case REND_POLYMOST:
|
||||
polymost_drawsprite(snum);
|
||||
bglDisable(GL_POLYGON_OFFSET_FILL);
|
||||
return;
|
||||
# ifdef POLYMER
|
||||
case REND_POLYMER:
|
||||
bglEnable(GL_ALPHA_TEST);
|
||||
bglEnable(GL_BLEND);
|
||||
polymer_drawsprite(snum);
|
||||
bglDisable(GL_BLEND);
|
||||
bglDisable(GL_ALPHA_TEST);
|
||||
return;
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -7851,8 +7844,8 @@ static void dosetaspect(void)
|
|||
int32_t k, x, xinc;
|
||||
|
||||
no_radarang2 = 0;
|
||||
oxdimen = xdimen;
|
||||
oviewingrange = viewingrange;
|
||||
oxdimen = xdimen;
|
||||
|
||||
xinc = mulscale32(viewingrange*320,xdimenrecip);
|
||||
x = (640<<16)-mulscale1(xinc,xdimen);
|
||||
|
@ -7877,9 +7870,9 @@ static void dosetaspect(void)
|
|||
}
|
||||
|
||||
{
|
||||
EDUKE32_STATIC_ASSERT((uint64_t)MAXXDIM*(ARRAY_SIZE(distrecip)-1) <= INT32_MAX);
|
||||
EDUKE32_STATIC_ASSERT((uint64_t) MAXXDIM*(ARRAY_SIZE(distrecip)-1) <= INT32_MAX);
|
||||
|
||||
for (i=1; i<(int32_t)ARRAY_SIZE(distrecip); i++)
|
||||
for (i=1; i<(int32_t) ARRAY_SIZE(distrecip); i++)
|
||||
distrecip[i] = (xdimen * i)>>20;
|
||||
}
|
||||
|
||||
|
@ -8862,7 +8855,7 @@ int32_t initengine(void)
|
|||
return 1;
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
if (!hicfirstinit) hicinit();
|
||||
if (!hicinitcounter) hicinit();
|
||||
if (!mdinited) mdinit();
|
||||
#endif
|
||||
|
||||
|
@ -9357,10 +9350,10 @@ static inline int32_t sameside(const _equation *eq, const _point2d *p1,
|
|||
if (sign1 > 0)
|
||||
{
|
||||
//OSD_Printf("SAME SIDE !\n");
|
||||
return (1);
|
||||
return 1;
|
||||
}
|
||||
//OSD_Printf("OPPOSITE SIDE !\n");
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// x1, y1: in/out
|
||||
|
@ -9409,6 +9402,7 @@ void drawmasks(void)
|
|||
#ifdef USE_OPENGL
|
||||
const int32_t modelp = (usemodels && tile2model[tspriteptr[i]->picnum].modelid >= 0);
|
||||
#endif
|
||||
|
||||
if (yp > (4<<8))
|
||||
{
|
||||
const int32_t xp = dmulscale6(ys,cosglobalang,-xs,singlobalang);
|
||||
|
@ -15265,14 +15259,19 @@ void setviewtotile(int16_t tilenume, int32_t xsiz, int32_t ysiz)
|
|||
bakframeplace[setviewcnt] = frameplace; frameplace = waloff[tilenume];
|
||||
bakwindowx1[setviewcnt] = windowx1; bakwindowy1[setviewcnt] = windowy1;
|
||||
bakwindowx2[setviewcnt] = windowx2; bakwindowy2[setviewcnt] = windowy2;
|
||||
#ifdef USE_OPENGL
|
||||
|
||||
if (setviewcnt == 0)
|
||||
{
|
||||
#ifdef USE_OPENGL
|
||||
bakrendmode = rendmode;
|
||||
#endif
|
||||
baktile = tilenume;
|
||||
}
|
||||
rendmode = REND_CLASSIC;//2;
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
rendmode = REND_CLASSIC;
|
||||
#endif
|
||||
|
||||
copybufbyte(&startumost[windowx1],&bakumost[windowx1],(windowx2-windowx1+1)*sizeof(bakumost[0]));
|
||||
copybufbyte(&startdmost[windowx1],&bakdmost[windowx1],(windowx2-windowx1+1)*sizeof(bakdmost[0]));
|
||||
setviewcnt++;
|
||||
|
@ -17628,7 +17627,7 @@ static inline uint32_t hash_getcode(const char *s)
|
|||
return h;
|
||||
}
|
||||
|
||||
void hash_add(hashtable_t *t, const char *s, int32_t key, int32_t replace)
|
||||
void hash_add(hashtable_t *t, const char *s, intptr_t key, int32_t replace)
|
||||
{
|
||||
hashitem_t *cur, *prev=NULL;
|
||||
int32_t code;
|
||||
|
@ -17708,7 +17707,7 @@ void hash_delete(hashtable_t *t, const char *s)
|
|||
while ((cur = cur->next));
|
||||
}
|
||||
|
||||
int32_t hash_find(const hashtable_t *t, const char *s)
|
||||
intptr_t hash_find(const hashtable_t *t, const char *s)
|
||||
{
|
||||
hashitem_t *cur;
|
||||
|
||||
|
@ -17728,7 +17727,7 @@ int32_t hash_find(const hashtable_t *t, const char *s)
|
|||
return -1;
|
||||
}
|
||||
|
||||
int32_t hash_findcase(const hashtable_t *t, const char *s)
|
||||
intptr_t hash_findcase(const hashtable_t *t, const char *s)
|
||||
{
|
||||
hashitem_t *cur;
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ extern int16_t numscans, numbunches;
|
|||
#ifdef USE_OPENGL
|
||||
|
||||
// For GL_EXP2 fog:
|
||||
#define FOGSCALE 0.0000768
|
||||
#define FOGSCALE 0.0000768f
|
||||
|
||||
extern palette_t palookupfog[MAXPALOOKUPS];
|
||||
void calc_and_apply_fog(int32_t tile, int32_t shade, int32_t vis, int32_t pal);
|
||||
|
|
|
@ -2142,16 +2142,16 @@ int32_t getpalette(int32_t start, int32_t num, char *dapal)
|
|||
//
|
||||
int32_t setgamma(void)
|
||||
{
|
||||
//return 0;
|
||||
//return 0;
|
||||
|
||||
int32_t i;
|
||||
uint16_t gammaTable[768];
|
||||
float gamma = max(0.1f,min(4.f,vid_gamma));
|
||||
float contrast = max(0.1f,min(3.f,vid_contrast));
|
||||
float bright = max(-0.8f,min(0.8f,vid_brightness));
|
||||
float gamma = max(0.1f, min(4.f, vid_gamma));
|
||||
float contrast = max(0.1f, min(3.f, vid_contrast));
|
||||
float bright = max(-0.8f, min(0.8f, vid_brightness));
|
||||
|
||||
double invgamma = 1 / gamma;
|
||||
double norm = pow(255., invgamma - 1);
|
||||
float invgamma = 1.f / gamma;
|
||||
float norm = powf(255.f, invgamma - 1.f);
|
||||
|
||||
if (novideo) return 0;
|
||||
|
||||
|
@ -2162,21 +2162,23 @@ int32_t setgamma(void)
|
|||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
double val = i * contrast - (contrast - 1) * 127;
|
||||
if (gamma != 1) val = pow(val, invgamma) / norm;
|
||||
val += bright * 128;
|
||||
float val = i * contrast - (contrast - 1.f) * 127.f;
|
||||
if (gamma != 1.f)
|
||||
val = powf(val, invgamma) / norm;
|
||||
|
||||
gammaTable[i] = gammaTable[i + 256] = gammaTable[i + 512] = (uint16_t)max(0.f,(double)min(0xffff,val*256));
|
||||
val += bright * 128.f;
|
||||
|
||||
gammaTable[i] = gammaTable[i + 256] = gammaTable[i + 512] = (uint16_t) max(0.f, min(65535.f, val*256.f));
|
||||
}
|
||||
|
||||
#if SDL_MAJOR_VERSION==1
|
||||
i = SDL_SetGammaRamp(&gammaTable[0],&gammaTable[256],&gammaTable[512]);
|
||||
i = SDL_SetGammaRamp(&gammaTable[0], &gammaTable[256], &gammaTable[512]);
|
||||
if (i != -1)
|
||||
#else
|
||||
i = INT32_MIN;
|
||||
|
||||
if (sdl_window)
|
||||
i = SDL_SetWindowGammaRamp(
|
||||
sdl_window,&gammaTable[0],&gammaTable[256],&gammaTable[512]);
|
||||
i = SDL_SetWindowGammaRamp(sdl_window, &gammaTable[0], &gammaTable[256], &gammaTable[512]);
|
||||
|
||||
if (i < 0)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue