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:
terminx 2014-09-30 04:06:32 +00:00
parent 105bc3f413
commit d279344697
7 changed files with 78 additions and 69 deletions

View file

@ -188,13 +188,13 @@ void showframe(int32_t);
int32_t setpalette(int32_t start, int32_t num); int32_t setpalette(int32_t start, int32_t num);
//int32_t getpalette(int32_t start, int32_t num, char *dapal); //int32_t getpalette(int32_t start, int32_t num, char *dapal);
int32_t setgamma(void); 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_GAMMA 1.0f
#define DEFAULT_CONTRAST 1.0 #define DEFAULT_CONTRAST 1.0f
#define DEFAULT_BRIGHTNESS 0.0 #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 //int32_t switchrendermethod(int32_t,int32_t); // 0 = software, 1 = opengl | bool = reinit

View file

@ -177,6 +177,14 @@ static inline long lround(double num)
#define nearbyintf rintf #define nearbyintf rintf
#endif #endif
#if defined(__arm__)
#define Bsqrt __sqrt
#define Bsqrtf __sqrtf
#else
#define Bsqrt sqrt
#define Bsqrtf sqrtf
#endif
#ifndef NULL #ifndef NULL
# define NULL ((void *)0) # define NULL ((void *)0)
#endif #endif

View file

@ -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 }, { "r_tror_nomaskpass", "enable/disable additional pass in TROR software rendering", (void *)&r_tror_nomaskpass, CVAR_BOOL, 0, 1 },
#endif #endif
{ "r_windowpositioning", "enable/disable window position memory", (void *) &windowpos, CVAR_BOOL, 0, 1 }, { "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_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_DOUBLE|CVAR_FUNCPTR, 0, 10 }, { "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_DOUBLE|CVAR_FUNCPTR, 0, 10 }, { "vid_brightness","adjusts brightness component of gamma ramp",(void *) &vid_brightness, CVAR_FLOAT|CVAR_FUNCPTR, 0.f, 10.f },
#ifdef DEBUGGINGAIDS #ifdef DEBUGGINGAIDS
{ "debug1","debug counter",(void *) &debug1, CVAR_FLOAT, -100000, 100000 }, { "debug1","debug counter",(void *) &debug1, CVAR_FLOAT, -100000, 100000 },
{ "debug2","debug counter",(void *) &debug2, CVAR_FLOAT, -100000, 100000 }, { "debug2","debug counter",(void *) &debug2, CVAR_FLOAT, -100000, 100000 },

View file

@ -91,7 +91,7 @@ int32_t synctics = 0, lockclock = 0;
// those ones save the respective 3d video vars while in 2d mode // those ones save the respective 3d video vars while in 2d mode
// so that exiting from mapster32 in 2d mode saves the correct ones // 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 xdim2d = 640, ydim2d = 480, xdimgame = 640, ydimgame = 480, bppgame = 8;
int32_t forcesetup = 1; int32_t forcesetup = 1;

View file

@ -59,7 +59,10 @@ L_State g_engState;
# define CLASSIC_NONPOW2_YSIZE_WALLS # define CLASSIC_NONPOW2_YSIZE_WALLS
#endif #endif
#if !defined(__arm__) && !defined(GEKKO)
#define HIGH_PRECISION_SPRITE #define HIGH_PRECISION_SPRITE
#endif
#define MULTI_COLUMN_VLINE #define MULTI_COLUMN_VLINE
//#define DEBUG_TILESIZY_512 //#define DEBUG_TILESIZY_512
//#define DEBUG_TILEOFFSETS //#define DEBUG_TILEOFFSETS
@ -156,9 +159,9 @@ uint32_t r_screenxy = 0;
int32_t curbrightness = 0, gammabrightness = 0; int32_t curbrightness = 0, gammabrightness = 0;
double vid_gamma = DEFAULT_GAMMA; float vid_gamma = DEFAULT_GAMMA;
double vid_contrast = DEFAULT_CONTRAST; float vid_contrast = DEFAULT_CONTRAST;
double vid_brightness = DEFAULT_BRIGHTNESS; float vid_brightness = DEFAULT_BRIGHTNESS;
//Textured Map variables //Textured Map variables
static char globalpolytype; 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 bakwindowx1[4], bakwindowy1[4];
static int32_t bakwindowx2[4], bakwindowy2[4]; static int32_t bakwindowx2[4], bakwindowy2[4];
#ifdef USE_OPENGL #ifdef USE_OPENGL
static int32_t bakrendmode,baktile; static int32_t bakrendmode;
#endif #endif
static int32_t baktile;
char apptitle[256] = "Build Engine"; char apptitle[256] = "Build Engine";
@ -2512,9 +2516,7 @@ int32_t engine_addtsprite(int16_t z, int16_t sectnum)
} }
} }
else else
#ifdef YAX_ENABLE
if (yax_nomaskpass==0) if (yax_nomaskpass==0)
#endif
{ {
sortcnt = &yax_spritesortcnt[yax_globallev]; sortcnt = &yax_spritesortcnt[yax_globallev];
if (*sortcnt >= MAXSPRITESONSCREEN) if (*sortcnt >= MAXSPRITESONSCREEN)
@ -5579,32 +5581,6 @@ static void setup_globals_sprite1(const spritetype *tspr, const sectortype *sec,
// //
// drawsprite (internal) // 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) 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) static void drawsprite(int32_t snum)
{ {
if (getrendermode() >= REND_POLYMOST) switch (getrendermode())
drawsprite_opengl(snum); {
else case REND_CLASSIC:
drawsprite_classic(snum); 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; int32_t k, x, xinc;
no_radarang2 = 0; no_radarang2 = 0;
oxdimen = xdimen;
oviewingrange = viewingrange; oviewingrange = viewingrange;
oxdimen = xdimen;
xinc = mulscale32(viewingrange*320,xdimenrecip); xinc = mulscale32(viewingrange*320,xdimenrecip);
x = (640<<16)-mulscale1(xinc,xdimen); 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; distrecip[i] = (xdimen * i)>>20;
} }
@ -8862,7 +8855,7 @@ int32_t initengine(void)
return 1; return 1;
#ifdef USE_OPENGL #ifdef USE_OPENGL
if (!hicfirstinit) hicinit(); if (!hicinitcounter) hicinit();
if (!mdinited) mdinit(); if (!mdinited) mdinit();
#endif #endif
@ -9357,10 +9350,10 @@ static inline int32_t sameside(const _equation *eq, const _point2d *p1,
if (sign1 > 0) if (sign1 > 0)
{ {
//OSD_Printf("SAME SIDE !\n"); //OSD_Printf("SAME SIDE !\n");
return (1); return 1;
} }
//OSD_Printf("OPPOSITE SIDE !\n"); //OSD_Printf("OPPOSITE SIDE !\n");
return (0); return 0;
} }
// x1, y1: in/out // x1, y1: in/out
@ -9409,6 +9402,7 @@ void drawmasks(void)
#ifdef USE_OPENGL #ifdef USE_OPENGL
const int32_t modelp = (usemodels && tile2model[tspriteptr[i]->picnum].modelid >= 0); const int32_t modelp = (usemodels && tile2model[tspriteptr[i]->picnum].modelid >= 0);
#endif #endif
if (yp > (4<<8)) if (yp > (4<<8))
{ {
const int32_t xp = dmulscale6(ys,cosglobalang,-xs,singlobalang); 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]; bakframeplace[setviewcnt] = frameplace; frameplace = waloff[tilenume];
bakwindowx1[setviewcnt] = windowx1; bakwindowy1[setviewcnt] = windowy1; bakwindowx1[setviewcnt] = windowx1; bakwindowy1[setviewcnt] = windowy1;
bakwindowx2[setviewcnt] = windowx2; bakwindowy2[setviewcnt] = windowy2; bakwindowx2[setviewcnt] = windowx2; bakwindowy2[setviewcnt] = windowy2;
#ifdef USE_OPENGL
if (setviewcnt == 0) if (setviewcnt == 0)
{ {
#ifdef USE_OPENGL
bakrendmode = rendmode; bakrendmode = rendmode;
#endif
baktile = tilenume; baktile = tilenume;
} }
rendmode = REND_CLASSIC;//2;
#ifdef USE_OPENGL
rendmode = REND_CLASSIC;
#endif #endif
copybufbyte(&startumost[windowx1],&bakumost[windowx1],(windowx2-windowx1+1)*sizeof(bakumost[0])); copybufbyte(&startumost[windowx1],&bakumost[windowx1],(windowx2-windowx1+1)*sizeof(bakumost[0]));
copybufbyte(&startdmost[windowx1],&bakdmost[windowx1],(windowx2-windowx1+1)*sizeof(bakdmost[0])); copybufbyte(&startdmost[windowx1],&bakdmost[windowx1],(windowx2-windowx1+1)*sizeof(bakdmost[0]));
setviewcnt++; setviewcnt++;
@ -17628,7 +17627,7 @@ static inline uint32_t hash_getcode(const char *s)
return h; 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; hashitem_t *cur, *prev=NULL;
int32_t code; int32_t code;
@ -17708,7 +17707,7 @@ void hash_delete(hashtable_t *t, const char *s)
while ((cur = cur->next)); 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; hashitem_t *cur;
@ -17728,7 +17727,7 @@ int32_t hash_find(const hashtable_t *t, const char *s)
return -1; 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; hashitem_t *cur;

View file

@ -72,7 +72,7 @@ extern int16_t numscans, numbunches;
#ifdef USE_OPENGL #ifdef USE_OPENGL
// For GL_EXP2 fog: // For GL_EXP2 fog:
#define FOGSCALE 0.0000768 #define FOGSCALE 0.0000768f
extern palette_t palookupfog[MAXPALOOKUPS]; extern palette_t palookupfog[MAXPALOOKUPS];
void calc_and_apply_fog(int32_t tile, int32_t shade, int32_t vis, int32_t pal); void calc_and_apply_fog(int32_t tile, int32_t shade, int32_t vis, int32_t pal);

View file

@ -2142,16 +2142,16 @@ int32_t getpalette(int32_t start, int32_t num, char *dapal)
// //
int32_t setgamma(void) int32_t setgamma(void)
{ {
//return 0; //return 0;
int32_t i; int32_t i;
uint16_t gammaTable[768]; uint16_t gammaTable[768];
float gamma = max(0.1f,min(4.f,vid_gamma)); float gamma = max(0.1f, min(4.f, vid_gamma));
float contrast = max(0.1f,min(3.f,vid_contrast)); float contrast = max(0.1f, min(3.f, vid_contrast));
float bright = max(-0.8f,min(0.8f,vid_brightness)); float bright = max(-0.8f, min(0.8f, vid_brightness));
double invgamma = 1 / gamma; float invgamma = 1.f / gamma;
double norm = pow(255., invgamma - 1); float norm = powf(255.f, invgamma - 1.f);
if (novideo) return 0; if (novideo) return 0;
@ -2162,21 +2162,23 @@ int32_t setgamma(void)
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
{ {
double val = i * contrast - (contrast - 1) * 127; float val = i * contrast - (contrast - 1.f) * 127.f;
if (gamma != 1) val = pow(val, invgamma) / norm; if (gamma != 1.f)
val += bright * 128; 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 #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) if (i != -1)
#else #else
i = INT32_MIN; i = INT32_MIN;
if (sdl_window) if (sdl_window)
i = SDL_SetWindowGammaRamp( i = SDL_SetWindowGammaRamp(sdl_window, &gammaTable[0], &gammaTable[256], &gammaTable[512]);
sdl_window,&gammaTable[0],&gammaTable[256],&gammaTable[512]);
if (i < 0) if (i < 0)
{ {