- merged in the changes RedNukem made to the Build code.

This commit is contained in:
Christoph Oelckers 2019-09-19 00:19:02 +02:00
parent 3a90d21661
commit 51dc82b6a6
7 changed files with 77 additions and 15 deletions

View file

@ -17,6 +17,8 @@
extern "C" {
#endif
extern bool playing_rr;
//// TYPES
struct strllist
{
@ -108,6 +110,12 @@ static inline int32_t sepldist(const int32_t dx, const int32_t dy)
{
vec2_t d = { klabs(dx), klabs(dy) };
if (playing_rr)
{
if (!d.y) return d.x;
if (!d.x) return d.y;
}
if (d.x < d.y)
swaplong(&d.x, &d.y);

View file

@ -7,9 +7,9 @@
#pragma once
#ifdef _WIN32
# include "windows_inc.h"
#endif
#ifdef _WIN32
# include "windows_inc.h"
#endif
////////// Compiler detection //////////
@ -1084,7 +1084,7 @@ CONSTEXPR size_t logbasenegative(T n)
return n > static_cast<T>(-(native_t)base) ? 1 : 1 + logbase<base>(n / static_cast<T>(-(native_t)base));
}
#define isPow2OrZero(v) (((v) & ((v) - 1)) == 0)
#define isPow2OrZero(v) (((v) & ((v) - 1)) == 0)
#define isPow2(v) (isPow2OrZero(v) && (v))
#endif

View file

@ -17,6 +17,7 @@ extern "C" {
typedef struct { uint8_t r, g, b, a; } coltype;
typedef struct { float r, g, b, a; } coltypef;
extern bool playing_rr;
extern int32_t rendmode;
extern float gtang;
extern float glox1, gloy1;
@ -83,6 +84,7 @@ extern uint8_t alphahackarray[MAXTILES];
extern int32_t r_usenewshading;
extern int32_t r_usetileshades;
extern int32_t r_npotwallmode;
extern int32_t r_brightnesshack;
extern int16_t globalpicnum;
@ -146,7 +148,7 @@ static FORCE_INLINE int polymost_is_npotmode(void)
#ifdef NEW_MAP_FORMAT
g_loadedMapVersion < 10 &&
#endif
r_npotwallmode;
(playing_rr? r_npotwallmode == 1 : r_npotwallmode != 0); // I have no idea which one is more correct...
}
static inline float polymost_invsqrt_approximation(float x)

View file

@ -9068,7 +9068,11 @@ static int32_t engineFinishLoadBoard(const vec3_t *dapos, int16_t *dacursectnum,
int32_t removeit = 0;
if ((sprite[i].cstat & 48) == 48)
sprite[i].cstat &= ~48;
{
// If I understand this correctly, both of these essentially do the same thing...
if (!playing_rr) sprite[i].cstat &= ~48;
else sprite[i].cstat |= 32768;
}
if (sprite[i].statnum == MAXSTATUS)
{

View file

@ -719,7 +719,7 @@ void videoSetPalette(char dabrightness, uint8_t dapalid, uint8_t flags)
}
videoSetGamma();
j = !gammabrightness ? curbrightness : 0;
j = (!gammabrightness || (flags&32) != 0) ? curbrightness : 0;
for (i=0; i<256; i++)
{
@ -736,6 +736,13 @@ void videoSetPalette(char dabrightness, uint8_t dapalid, uint8_t flags)
curpalettefaded[i].f = 0;
}
#ifdef USE_OPENGL
if ((flags&32) != 0 && videoGetRenderMode() == REND_POLYMOST)
r_brightnesshack = j;
else
r_brightnesshack = 0;
#endif
if ((flags&16) && palfadedelta) // keep the fade
paletteSetFade(palfadedelta>>2);

View file

@ -30,6 +30,8 @@ Ken Silverman's official web site: http://www.advsys.net/ken
extern char textfont[2048], smalltextfont[2048];
bool playing_rr;
int32_t rendmode=0;
int32_t usemodels=1;
int32_t usehightile=1;
@ -120,6 +122,7 @@ int32_t r_vbocount = 64;
int32_t r_animsmoothing = 1;
int32_t r_downsize = 0;
int32_t r_downsizevar = -1;
int32_t r_brightnesshack = 0;
// used for fogcalc
static float fogresult, fogresult2;
@ -188,6 +191,8 @@ static GLint polymost1NPOTEmulationFactorLoc = -1;
static float polymost1NPOTEmulationFactor = 1.f;
static GLint polymost1NPOTEmulationXOffsetLoc = -1;
static float polymost1NPOTEmulationXOffset = 0.f;
static GLint polymost1BrightnessLoc = -1;
static float polymost1Brightness = 1.f;
static GLint polymost1RotMatrixLoc = -1;
static float polymost1RotMatrix[16] = { 1.f, 0.f, 0.f, 0.f,
0.f, 1.f, 0.f, 0.f,
@ -502,6 +507,7 @@ static void polymost_setCurrentShaderProgram(uint32_t programID)
polymost1NPOTEmulationLoc = glGetUniformLocation(polymost1CurrentShaderProgramID, "u_npotEmulation");
polymost1NPOTEmulationFactorLoc = glGetUniformLocation(polymost1CurrentShaderProgramID, "u_npotEmulationFactor");
polymost1NPOTEmulationXOffsetLoc = glGetUniformLocation(polymost1CurrentShaderProgramID, "u_npotEmulationXOffset");
polymost1BrightnessLoc = glGetUniformLocation(polymost1CurrentShaderProgramID, "u_brightness");
polymost1RotMatrixLoc = glGetUniformLocation(polymost1CurrentShaderProgramID, "u_rotMatrix");
//set the uniforms to the current values
@ -520,6 +526,7 @@ static void polymost_setCurrentShaderProgram(uint32_t programID)
glUniform1f(polymost1NPOTEmulationLoc, polymost1NPOTEmulation);
glUniform1f(polymost1NPOTEmulationFactorLoc, polymost1NPOTEmulationFactor);
glUniform1f(polymost1NPOTEmulationXOffsetLoc, polymost1NPOTEmulationXOffset);
glUniform1f(polymost1BrightnessLoc, polymost1Brightness);
glUniformMatrix4fv(polymost1RotMatrixLoc, 1, false, polymost1RotMatrix);
}
@ -671,6 +678,16 @@ void polymost_npotEmulation(char npotEmulation, float factor, float xOffset)
glUniform1f(polymost1NPOTEmulationXOffsetLoc, polymost1NPOTEmulationXOffset);
}
void polymost_setBrightness(int brightness)
{
if (currentShaderProgramID == polymost1CurrentShaderProgramID)
{
polymost1Brightness = 8.f / (brightness+8.f);
glUniform1f(polymost1BrightnessLoc, polymost1Brightness);
}
}
static void polymost_bindPth(pthtyp const * const pPth, int sampler)
{
Bassert(pPth);
@ -862,6 +879,7 @@ void polymost_glinit()
uniform float u_npotEmulation;\n\
uniform float u_npotEmulationFactor;\n\
uniform float u_npotEmulationXOffset;\n\
uniform float u_brightness;\n\
\n\
varying vec4 v_color;\n\
varying float v_distance;\n\
@ -915,6 +933,8 @@ void polymost_glinit()
\n\
color.a *= v_color.a;\n\
\n\
color.rgb = pow(color.rgb, vec3(u_brightness));\n\
\n\
gl_FragColor = color;\n\
}\n";
const char* const POLYMOST1_EXTENDED_FRAGMENT_SHADER_CODE =
@ -946,6 +966,7 @@ void polymost_glinit()
uniform float u_npotEmulation;\n\
uniform float u_npotEmulationFactor;\n\
uniform float u_npotEmulationXOffset;\n\
uniform float u_brightness;\n\
\n\
uniform float u_useDetailMapping;\n\
uniform float u_useGlowMapping;\n\
@ -1009,6 +1030,8 @@ void polymost_glinit()
\n\
color.a *= v_color.a;\n\
\n\
color.rgb = pow(color.rgb, vec3(u_brightness));\n\
\n\
gl_FragColor = color;\n\
}\n";
@ -4030,7 +4053,7 @@ static void polymost_drawalls(int32_t const bunch)
int i = (1<<(picsiz[globalpicnum]>>4)); if (i != tilesiz[globalpicnum].y) i += i;
vec3f_t o;
if ((tilesiz[globalpicnum].y * daptileyscale * (1.f/65536.f)) > 256)
if (playing_rr || ((tilesiz[globalpicnum].y * daptileyscale * (1.f/65536.f)) > 256))
{
//Hack to draw black rectangle below sky when looking down...
xtex.d = xtex.u = xtex.v = 0;
@ -4090,7 +4113,14 @@ static void polymost_drawalls(int32_t const bunch)
do
{
globalpicnum = dapskyoff[y&((1<<dapskybits)-1)]+i;
otex.u = otex.d*(t*((float)(fglobalang-(y<<(11-dapskybits)))) * (1.f/2048.f) + (float)((r_parallaxskypanning)?sec->floorxpanning:0)) - xtex.u*ghalfx;
if (!playing_rr)
otex.u = otex.d*(t*((float)(fglobalang-(y<<(11-dapskybits)))) * (1.f/2048.f) + (float)((r_parallaxskypanning)?sec->floorxpanning:0)) - xtex.u*ghalfx;
else
{
int32_t picbits = picsiz[globalpicnum]&15;
int32_t np2 = tilesiz[globalpicnum].x != (1<<picbits);
otex.u = otex.d*(t*((float)(fglobalang-(np2 ? 0 : (y<<(11-dapskybits))))) * (1.f/2048.f) + (float)((r_parallaxskypanning)?sec->floorxpanning:0)) - xtex.u*ghalfx;
}
y++;
o.x = fx; fx = ((float)((y<<(11-dapskybits))-fglobalang))*o.z+ghalfx;
if (fx > x1) { fx = x1; i = -1; }
@ -4346,7 +4376,7 @@ static void polymost_drawalls(int32_t const bunch)
int i = (1<<(picsiz[globalpicnum]>>4)); if (i != tilesiz[globalpicnum].y) i += i;
vec3f_t o;
if ((tilesiz[globalpicnum].y * daptileyscale * (1.f/65536.f)) > 256)
if (playing_rr || ((tilesiz[globalpicnum].y * daptileyscale * (1.f/65536.f)) > 256))
{
@ -4407,7 +4437,14 @@ static void polymost_drawalls(int32_t const bunch)
do
{
globalpicnum = dapskyoff[y&((1<<dapskybits)-1)]+i;
otex.u = otex.d*(t*((float)(fglobalang-(y<<(11-dapskybits)))) * (1.f/2048.f) + (float)((r_parallaxskypanning)?sec->ceilingxpanning:0)) - xtex.u*ghalfx;
if (!playing_rr)
otex.u = otex.d*(t*((float)(fglobalang-(y<<(11-dapskybits)))) * (1.f/2048.f) + (float)((r_parallaxskypanning)?sec->ceilingxpanning:0)) - xtex.u*ghalfx;
else
{
int32_t picbits = picsiz[globalpicnum]&15;
int32_t np2 = tilesiz[globalpicnum].x != (1<<picbits);
otex.u = otex.d*(t*((float)(fglobalang-(np2 ? 0 : (y<<(11-dapskybits))))) * (1.f/2048.f) + (float)((r_parallaxskypanning)?sec->ceilingxpanning:0)) - xtex.u*ghalfx;
}
y++;
o.x = fx; fx = (((float) (y<<(11-dapskybits))-fglobalang))*o.z+ghalfx;
if (fx > x1) { fx = x1; i = -1; }
@ -4815,14 +4852,14 @@ static void polymost_drawalls(int32_t const bunch)
static int32_t polymost_bunchfront(const int32_t b1, const int32_t b2)
{
int b1f = bunchfirst[b1];
const float x2b2 = dxb2[bunchlast[b2]];
const float x1b1 = dxb1[b1f];
const double x2b2 = dxb2[bunchlast[b2]];
const double x1b1 = dxb1[b1f];
if (nexttowardf(x1b1, x2b2) >= x2b2)
return -1;
int b2f = bunchfirst[b2];
const float x1b2 = dxb1[b2f];
const double x1b2 = dxb1[b2f];
if (nexttowardf(x1b2, dxb2[bunchlast[b1]]) >= dxb2[bunchlast[b1]])
return -1;
@ -5082,6 +5119,8 @@ void polymost_drawrooms()
glDepthFunc(GL_ALWAYS); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS
// glDepthRange(0.0, 1.0); //<- this is more widely supported than glPolygonOffset
polymost_setBrightness(r_brightnesshack);
//Polymost supports true look up/down :) Here, we convert horizon to angle.
//gchang&gshang are cos&sin of this angle (respectively)
gyxscale = ((float)xdimenscale)*(1.0f/131072.f);
@ -5404,7 +5443,7 @@ void polymost_drawmaskwall(int32_t damaskwallcnt)
// | /
// fsy1/
vec2f_t dpxy[8] = { { x0, csy[1] }, { x1, csy[3] }, { x1, fsy[3] }, { x0, fsy[1] } };
vec2f_t dpxy[16] = { { x0, csy[1] }, { x1, csy[3] }, { x1, fsy[3] }, { x0, fsy[1] } };
//Clip to (x0,csy[0])-(x1,csy[2])

View file

@ -845,6 +845,8 @@ void tileCopySection(int32_t tilenume1, int32_t sx1, int32_t sy1, int32_t xsiz,
x1++; if (x1 >= xsiz1) x1 = 0;
}
}
if (playing_rr)
tileInvalidate(tilenume2, -1, -1);
}
void Buninitart(void)