- removed the Polymost renderer.

This commit is contained in:
Christoph Oelckers 2022-08-03 15:50:27 +02:00
parent 7debab7ff4
commit 291726cc55
38 changed files with 45 additions and 6621 deletions

View file

@ -601,7 +601,6 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
# there's generally a new cpp for every header so this file will get changed # there's generally a new cpp for every header so this file will get changed
file( GLOB HEADER_FILES file( GLOB HEADER_FILES
build/include/*.h build/include/*.h
glbackend/*.h
core/*.h core/*.h
core/2d/*.h core/2d/*.h
core/utility/*.h core/utility/*.h
@ -681,9 +680,6 @@ set( NOT_COMPILED_SOURCE_FILES
zcc-parse.h zcc-parse.h
common/platform/win32/zutil.natvis common/platform/win32/zutil.natvis
common/rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.natvis common/rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.natvis
games/blood/src/_polymost.cpp
games/duke/src/_polymost.cpp
games/sw/src/_polymost.cpp
# Blood # Blood
games/blood/src/actor.cpp games/blood/src/actor.cpp
@ -998,16 +994,12 @@ set (PCH_SOURCES
common/thirdparty/richpresence.cpp common/thirdparty/richpresence.cpp
glbackend/glbackend.cpp
glbackend/gl_texture.cpp
thirdparty/src/md4.cpp thirdparty/src/md4.cpp
# Todo: Split out the license-safe code from this. # Todo: Split out the license-safe code from this.
build/src/clip.cpp build/src/clip.cpp
build/src/engine.cpp build/src/engine.cpp
build/src/mdsprite.cpp build/src/mdsprite.cpp
build/src/polymost.cpp
core/actorinfo.cpp core/actorinfo.cpp
core/zcc_compile_raze.cpp core/zcc_compile_raze.cpp
@ -1550,7 +1542,6 @@ source_group("Core\\DObject" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/co
source_group("Core\\Menu" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/core/menu/.+") source_group("Core\\Menu" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/core/menu/.+")
source_group("Core\\Rendering" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/core/rendering/.+") source_group("Core\\Rendering" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/core/rendering/.+")
source_group("Core\\Rendering\\Scene" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/core/rendering/scene/.+") source_group("Core\\Rendering\\Scene" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/core/rendering/scene/.+")
source_group("Rendering" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/glbackend/.+")
source_group("Platform" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/platform/.+") source_group("Platform" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/platform/.+")
source_group("Platform\\Win32" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/platform/win32/.+") source_group("Platform\\Win32" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/platform/win32/.+")
source_group("Platform\\POSIX" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/platform/posix/.+") source_group("Platform\\POSIX" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/platform/posix/.+")

View file

@ -142,9 +142,7 @@ EXTERN int32_t enginecompatibility_mode;
void engineInit(void); void engineInit(void);
void videoSetCorrectedAspect();
void videoSetViewableArea(int32_t x1, int32_t y1, int32_t x2, int32_t y2); void videoSetViewableArea(int32_t x1, int32_t y1, int32_t x2, int32_t y2);
void renderSetAspect(int32_t daxrange, int32_t daaspect);
FCanvasTexture *renderSetTarget(int16_t tilenume); FCanvasTexture *renderSetTarget(int16_t tilenume);
void renderRestoreTarget(); void renderRestoreTarget();
@ -264,8 +262,6 @@ EXTERN_CVAR(Bool, r_voxels)
extern int32_t mdtims, omdtims; extern int32_t mdtims, omdtims;
extern int32_t r_rortexture;
extern int32_t r_rortexturerange;
extern int32_t r_rorphase; extern int32_t r_rorphase;
// flags bitset: 1 = don't compress // flags bitset: 1 = don't compress
@ -318,12 +314,6 @@ int32_t md_definehud (int32_t modelid, int32_t tilex, FVector3 add,
int32_t md_undefinetile(int32_t tile); int32_t md_undefinetile(int32_t tile);
int32_t md_undefinemodel(int32_t modelid); int32_t md_undefinemodel(int32_t modelid);
#ifdef USE_OPENGL
# include "polymost.h"
#endif
extern int skiptile;
static vec2_t const zerovec = { 0, 0 }; static vec2_t const zerovec = { 0, 0 };
#define SET_AND_RETURN(Lval, Rval) \ #define SET_AND_RETURN(Lval, Rval) \

View file

@ -1,75 +0,0 @@
#ifndef polymost_h_
# define polymost_h_
#include "mdsprite.h"
extern tspritetype pm_tsprite[MAXSPRITESONSCREEN];
extern int pm_spritesortcnt;
extern int pm_smoothratio;
namespace Polymost
{
extern float gtang;
extern double gxyaspect;
extern float grhalfxdown10x;
extern float gcosang, gsinang, gcosang2, gsinang2;
//void phex(char v, char *s);
void polymost_drawsprite(int32_t snum);
void polymost_drawmaskwall(int32_t damaskwallcnt);
void polymost_dorotatespritemodel(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, int8_t dashade, uint8_t dapalnum, int32_t dastat, uint8_t daalpha, uint8_t dablend, int32_t uniqid);
void polymost_initosdfuncs(void);
void polymost_glreset(void);
void polymost_scansector(int32_t sectnum);
extern float curpolygonoffset;
}
void renderPrepareMirror(int32_t dax, int32_t day, int32_t daz, fixed_t daang, fixed_t dahoriz, int16_t dawall,
int32_t* tposx, int32_t* tposy, fixed_t* tang);
void renderCompleteMirror(void);
int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz, fixed_t daang, fixed_t dahoriz, int dacursectnum, bool fromoutside);
int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz, fixed_t daang, fixed_t dahoriz, sectortype* dacursect, bool fromoutside);
void renderDrawMasks(void);
// PLAG: line utility functions
typedef struct s_equation
{
float a, b, c;
} _equation;
void renderSetRollAngle(float rolla);
// these are defined in engine.cpp.
extern int16_t globalpicnum;
extern float fcosglobalang, fsinglobalang;
extern float fydimen, fviewingrange;
extern int32_t viewingrangerecip;
// Flags of the <dameth> argument of various functions
enum {
DAMETH_NOMASK = 0,
DAMETH_MASK = 1,
DAMETH_TRANS1 = 2,
DAMETH_TRANS2 = 3,
DAMETH_MASKPROPS = 3,
DAMETH_CLAMPED = 4,
DAMETH_MODEL = 8,
DAMETH_SKY = 16,
DAMETH_WALL = 32, // signals a texture for a wall (for r_npotwallmode)
// used internally by polymost_domost
DAMETH_BACKFACECULL = -1,
};
#endif

View file

@ -35,9 +35,7 @@
#ifdef USE_OPENGL #ifdef USE_OPENGL
# include "mdsprite.h" # include "mdsprite.h"
# include "polymost.h"
#include "v_video.h" #include "v_video.h"
#include "../../glbackend/glbackend.h"
#include "gl_renderer.h" #include "gl_renderer.h"
#endif #endif
@ -78,22 +76,6 @@ static void getclosestpointonwall_internal(vec2_t const p, int32_t const dawall,
*closest = { (int32_t)(w.X + ((d.X * i) >> 30)), (int32_t)(w.Y + ((d.Y * i) >> 30)) }; *closest = { (int32_t)(w.X + ((d.X * i) >> 30)), (int32_t)(w.Y + ((d.Y * i) >> 30)) };
} }
int32_t xdimen = -1, xdimenscale, xdimscale;
float fxdimen = -1.f;
int32_t ydimen;
int32_t globalposx, globalposy, globalposz;
fixed_t qglobalhoriz;
float fglobalposx, fglobalposy, fglobalposz;
int16_t globalang, globalcursectnum;
fixed_t qglobalang;
int32_t globalpal, globalfloorpal, cosglobalang, singlobalang;
int32_t cosviewingrangeglobalang, sinviewingrangeglobalang;
int32_t viewingrangerecip;
int32_t globalshade, globalorientation;
int16_t globalpicnum;
static int32_t globaly1, globalx2; static int32_t globaly1, globalx2;
@ -667,13 +649,6 @@ void videoSetViewableArea(int32_t x1, int32_t y1, int32_t x2, int32_t y2)
windowxy1.Y = y1; windowxy1.Y = y1;
windowxy2.X = x2; windowxy2.X = x2;
windowxy2.Y = y2; windowxy2.Y = y2;
xdimen = (x2-x1)+1;
ydimen = (y2-y1)+1;
fxdimen = (float) xdimen;
fydimen = (float) ydimen;
videoSetCorrectedAspect();
} }
@ -711,7 +686,6 @@ FCanvasTexture* renderSetTarget(int16_t tilenume)
xdim = ysiz; xdim = ysiz;
ydim = xsiz; ydim = xsiz;
videoSetViewableArea(0,0,ysiz-1,xsiz-1); videoSetViewableArea(0,0,ysiz-1,xsiz-1);
renderSetAspect(65536,65536);
return canvas; return canvas;
} }

View file

@ -13,21 +13,6 @@
#ifndef ENGINE_PRIV_H #ifndef ENGINE_PRIV_H
#define ENGINE_PRIV_H #define ENGINE_PRIV_H
extern int32_t globalpal, globalfloorpal;
extern int32_t xdimen, xdimenscale, xdimscale, ydimen;
extern float fxdimen;
extern int32_t globalposx, globalposy, globalposz;
extern fixed_t qglobalhoriz, qglobalang;
extern float fglobalposx, fglobalposy, fglobalposz;
extern int16_t globalang, globalcursectnum;
extern int32_t globalpal, cosglobalang, singlobalang;
extern int32_t cosviewingrangeglobalang, sinviewingrangeglobalang;
extern int32_t xyaspect;
extern int32_t globalshade;
extern int16_t globalpicnum;
extern int32_t globalorientation;
extern int32_t hitallsprites; extern int32_t hitallsprites;
int32_t animateoffs(int tilenum, int fakevar); int32_t animateoffs(int tilenum, int fakevar);

View file

@ -4,7 +4,6 @@
#include "build.h" #include "build.h"
#include "engine_priv.h" #include "engine_priv.h"
#include "polymost.h"
#include "mdsprite.h" #include "mdsprite.h"
#include "coreactor.h" #include "coreactor.h"
@ -17,7 +16,6 @@
#include "hw_renderstate.h" #include "hw_renderstate.h"
#include "printf.h" #include "printf.h"
#include "hw_voxels.h" #include "hw_voxels.h"
#include "../../glbackend/glbackend.h"
#ifdef _MSC_VER #ifdef _MSC_VER
// just make it shut up. Most of this file will go down the drain anyway soon. // just make it shut up. Most of this file will go down the drain anyway soon.
@ -29,9 +27,6 @@ static int32_t curextra=MAXTILES;
#define MIN_CACHETIME_PRINT 10 #define MIN_CACHETIME_PRINT 10
using namespace Polymost;
int32_t polymost_voxdraw(voxmodel_t* m, tspritetype* const tspr, bool rotate);
static int32_t addtileP(int32_t ,int32_t tile,int32_t pallet) static int32_t addtileP(int32_t ,int32_t tile,int32_t pallet)
{ {
// tile >= 0 && tile < MAXTILES // tile >= 0 && tile < MAXTILES
@ -1073,351 +1068,6 @@ static void md3postload_common(md3model_t *m)
} }
void md3_vox_calcmat_common(tspritetype* tspr, const FVector3 *a0, float f, float mat[16])
{
float k0, k1, k2, k3, k4, k5, k6, k7;
auto ownerActor = tspr->ownerActor;
k0 = ((float)(tspr->pos.X+ownerActor->sprext.position_offset.X-globalposx))*f*(1.f/1024.f);
k1 = ((float)(tspr->pos.Y+ownerActor->sprext.position_offset.Y-globalposy))*f*(1.f/1024.f);
k4 = -bsinf(tspr->ang+ownerActor->sprext.angoff, -14);
k5 = bcosf(tspr->ang+ownerActor->sprext.angoff, -14);
k2 = k0*(1-k4)+k1*k5;
k3 = k1*(1-k4)-k0*k5;
k6 = - gsinang;
k7 = gcosang;
mat[0] = k4*k6 + k5*k7; mat[4] = 0; mat[ 8] = k4*k7 - k5*k6; mat[12] = k2*k6 + k3*k7;
mat[1] = 0; mat[5] = 1; mat[ 9] = 0; mat[13] = 0;
k6 = gcosang2;
k7 = gsinang2;
mat[2] = k4*k6 + k5*k7;
mat[6] =0;
mat[10] = k4*k7 - k5*k6;
mat[14] = k2*k6 + k3*k7;
mat[12] = (mat[12] + a0->Y*mat[0]) + (a0->Z*mat[4] + a0->X*mat[ 8]);
mat[13] = (mat[13] + a0->Y*mat[1]) + (a0->Z*mat[5] + a0->X*mat[ 9]);
mat[14] = (mat[14] + a0->Y*mat[2]) + (a0->Z*mat[6] + a0->X*mat[10]);
}
static void md3draw_handle_triangles(const md3surf_t *s, uint16_t *indexhandle,
int32_t , const md3model_t *M)
{
int32_t i;
auto data = screen->mVertexData->AllocVertices(s->numtris * 3);
auto vt = data.first;
for (i=s->numtris-1; i>=0; i--)
{
uint16_t tri = M ? M->indexes[i] : i;
int32_t j;
for (j=0; j<3; j++, vt++)
{
int32_t k = s->tris[tri].i[j];
vt->SetTexCoord(s->uv[k].u, s->uv[k].v);
vt->SetVertex(vertlist[k].X, vertlist[k].Y, vertlist[k].Z);
}
}
GLInterface.Draw(DT_Triangles, data.second, s->numtris *3);
}
static int32_t polymost_md3draw(md3model_t *m, tspritetype* tspr)
{
FVector3 m0, m1, a0;
md3xyzn_t *v0, *v1;
int32_t i, surfi;
float f, g, k0, k1, k2=0, k3=0, mat[16]; // inits: compiler-happy
float pc[4];
// int32_t texunits = GL_TEXTURE0;
auto ownerActor = tspr->ownerActor;
const uint8_t lpal = ownerActor->spr.pal;
const int32_t sizyrep = tileHeight(tspr->picnum) * tspr->yrepeat;
updateanimation((md2model_t *)m, tspr, lpal);
//create current&next frame's vertex list from whole list
f = m->interpol; g = 1.f - f;
if (m->interpol < 0.f || m->interpol > 1.f ||
(unsigned)m->cframe >= (unsigned)m->numframes ||
(unsigned)m->nframe >= (unsigned)m->numframes)
{
#ifdef DEBUGGINGAIDS
Printf("%s: mdframe oob: c:%d n:%d total:%d interpol:%.02f\n",
m->head.nam, m->cframe, m->nframe, m->numframes, m->interpol);
#endif
m->interpol = clamp(m->interpol, 0.f, 1.f);
m->cframe = clamp(m->cframe, 0, m->numframes-1);
m->nframe = clamp(m->nframe, 0, m->numframes-1);
}
m0.Z = m0.Y = m0.X = g *= m->scale * (1.f/64.f);
m1.Z = m1.Y = m1.X = f *= m->scale * (1.f/64.f);
a0.X = a0.Y = 0;
a0.Z = m->zadd * m->scale;
// Parkar: Moved up to be able to use k0 for the y-flipping code
k0 = (float)tspr->pos.Z+ownerActor->sprext.position_offset.Z;
f = ((globalorientation & 8) && (ownerActor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) != CSTAT_SPRITE_ALIGNMENT_FACING) ? -4.f : 4.f;
k0 -= (tspr->yoffset*tspr->yrepeat)*f;
if ((globalorientation&128) && !((globalorientation & CSTAT_SPRITE_ALIGNMENT_MASK) == CSTAT_SPRITE_ALIGNMENT_FLOOR))
k0 += (float)(sizyrep<<1);
// Parkar: Changed to use the same method as centeroriented sprites
if (globalorientation&8) //y-flipping
{
m0.Z = -m0.Z; m1.Z = -m1.Z; a0.Z = -a0.Z;
k0 -= (float)(sizyrep<<2);
}
if (globalorientation&4) { m0.Y = -m0.Y; m1.Y = -m1.Y; a0.Y = -a0.Y; } //x-flipping
// yoffset differs from zadd in that it does not follow cstat & CSTAT_SPRITE_YFLIP y-flipping
a0.Z += m->yoffset*m->scale;
f = ((float)tspr->xrepeat) * (1.f/64.f) * m->bscale;
m0.X *= f; m0.Y *= -f;
m1.X *= f; m1.Y *= -f;
a0.X *= f; a0.Y *= -f;
f = ((float)tspr->yrepeat) * (1.f/64.f) * m->bscale;
m0.Z *= f; m1.Z *= f; a0.Z *= f;
// floor aligned
k1 = (float)tspr->pos.Y+ ownerActor->sprext.position_offset.Y;
if ((globalorientation & CSTAT_SPRITE_ALIGNMENT_MASK) == CSTAT_SPRITE_ALIGNMENT_FLOOR)
{
m0.Z = -m0.Z; m1.Z = -m1.Z; a0.Z = -a0.Z;
m0.Y = -m0.Y; m1.Y = -m1.Y; a0.Y = -a0.Y;
f = a0.X; a0.X = a0.Z; a0.Z = f;
k1 += (float)(sizyrep>>3);
}
// Note: These SCREEN_FACTORS will be neutralized in axes offset
// calculations below again, but are needed for the base offsets.
f = (65536.f*512.f)/(fxdimen*fviewingrange);
g = 32.f/(fxdimen*gxyaspect);
m0.Y *= f; m1.Y *= f; a0.Y = (((float)(tspr->pos.X+ ownerActor->sprext.position_offset.X-globalposx))* (1.f/1024.f) + a0.Y)*f;
m0.X *=-f; m1.X *=-f; a0.X = ((k1 -fglobalposy) * -(1.f/1024.f) + a0.X)*-f;
m0.Z *= g; m1.Z *= g; a0.Z = ((k0 -fglobalposz) * -(1.f/16384.f) + a0.Z)*g;
md3_vox_calcmat_common(tspr, &a0, f, mat);
// floor aligned
if ((globalorientation & CSTAT_SPRITE_ALIGNMENT_MASK) == CSTAT_SPRITE_ALIGNMENT_FLOOR)
{
f = mat[4]; mat[4] = mat[8]*16.f; mat[8] = -f*(1.f/16.f);
f = mat[5]; mat[5] = mat[9]*16.f; mat[9] = -f*(1.f/16.f);
f = mat[6]; mat[6] = mat[10]*16.f; mat[10] = -f*(1.f/16.f);
}
//Mirrors
if (grhalfxdown10x < 0) { mat[0] = -mat[0]; mat[4] = -mat[4]; mat[8] = -mat[8]; mat[12] = -mat[12]; }
//------------
// TSPR_FLAGS_MDHACK is an ugly hack in game.c:G_DoSpriteAnimations() telling md2sprite
// to use Z-buffer hacks to hide overdraw problems with the flat-tsprite-on-floor shadows,
// also disabling detail, glow, normal, and specular maps.
if (tspr->clipdist & TSPR_FLAGS_MDHACK)
{
// What once was here had been neutered in EDuke32 already.
GLInterface.SetDepthFunc(DF_LEqual);
}
int winding = ((grhalfxdown10x >= 0) ^((globalorientation&8) != 0) ^((globalorientation&4) != 0))? Winding_CW : Winding_CCW;
GLInterface.SetCull(Cull_Back, winding);
// tinting
pc[0] = pc[1] = pc[2] = ((float)numshades - min(max((globalshade * hw_shadescale) + m->shadeoff, 0.f), (float)numshades)) / (float)numshades;
pc[3] = (tspr->cstat & CSTAT_SPRITE_TRANSLUCENT) ? glblend[tspr->blend].def[!!(tspr->cstat & CSTAT_SPRITE_TRANS_FLIP)].alpha : 1.0f;
pc[3] *= 1.0f - ownerActor->sprext.alpha;
SetRenderStyleFromBlend(!!(tspr->cstat & CSTAT_SPRITE_TRANSLUCENT), tspr->blend, !!(tspr->cstat & CSTAT_SPRITE_TRANS_FLIP));
if (m->usesalpha) //Sprites with alpha in texture
{
// PLAG : default cutoff removed
GLInterface.EnableBlend(true);
GLInterface.EnableAlphaTest(true);
GLInterface.SetAlphaThreshold(TileFiles.tiledata[globalpicnum].texture->alphaThreshold);
}
else
{
if ((tspr->cstat & CSTAT_SPRITE_TRANSLUCENT) || ownerActor->sprext.alpha > 0.f || pc[3] < 1.0f)
GLInterface.EnableBlend(true); //else GLInterface.EnableBlend(false);
}
GLInterface.SetColor(pc[0],pc[1],pc[2],pc[3]);
//if (MFLAGS_NOCONV(m))
// GLInterface.SetColor(0.0f, 0.0f, 1.0f, 1.0f);
//------------
// PLAG: Cleaner model rotation code
if (ownerActor->sprext.pitch || ownerActor->sprext.roll)
{
float factor = 1.f/((fxdimen * fviewingrange) * (256.f/(65536.f*128.f)) * (m0.X+m1.X));
memset(&a0, 0, sizeof(a0));
if (ownerActor->sprext.pivot_offset.X)
a0.X = (float) ownerActor->sprext.pivot_offset.X * factor;
if (ownerActor->sprext.pivot_offset.Y) // Compare with SCREEN_FACTORS above
a0.Y = (float) ownerActor->sprext.pivot_offset.Y * factor;
if ((ownerActor->sprext.pivot_offset.Z) && !(tspr->clipdist & TSPR_FLAGS_MDHACK)) // Compare with SCREEN_FACTORS above
a0.Z = (float)ownerActor->sprext.pivot_offset.Z / (gxyaspect * fxdimen * (65536.f/128.f) * (m0.Z+m1.Z));
k0 = bcosf(ownerActor->sprext.pitch, -14);
k1 = bsinf(ownerActor->sprext.pitch, -14);
k2 = bcosf(ownerActor->sprext.roll, -14);
k3 = bsinf(ownerActor->sprext.roll, -14);
}
VSMatrix imat = 0;
imat.scale(1024, 1024, 1024);
GLInterface.SetMatrix(Matrix_Model, &imat);
for (surfi=0; surfi<m->head.numsurfs; surfi++)
{
//PLAG : sorting stuff
uint16_t *indexhandle;
FVector3 fp;
const md3surf_t *const s = &m->head.surfs[surfi];
v0 = &s->xyzn[m->cframe*s->numverts];
v1 = &s->xyzn[m->nframe*s->numverts];
if (ownerActor->sprext.pitch || ownerActor->sprext.roll)
{
FVector3 fp1, fp2;
for (i=s->numverts-1; i>=0; i--)
{
fp.Z = v0[i].x + a0.X;
fp.X = v0[i].y + a0.Y;
fp.Y = v0[i].z + a0.Z;
fp1.X = fp.X*k2 + fp.Y*k3;
fp1.Y = fp.X*k0*(-k3) + fp.Y*k0*k2 + fp.Z*(-k1);
fp1.Z = fp.X*k1*(-k3) + fp.Y*k1*k2 + fp.Z*k0;
fp.Z = v1[i].x + a0.X;
fp.X = v1[i].y + a0.Y;
fp.Y = v1[i].z + a0.Z;
fp2.X = fp.X*k2 + fp.Y*k3;
fp2.Y = fp.X*k0*(-k3) + fp.Y*k0*k2 + fp.Z*(-k1);
fp2.Z = fp.X*k1*(-k3) + fp.Y*k1*k2 + fp.Z*k0;
fp.Z = (fp1.Z - a0.X)*m0.X + (fp2.Z - a0.X)*m1.X;
fp.X = (fp1.X - a0.Y)*m0.Y + (fp2.X - a0.Y)*m1.Y;
fp.Y = (fp1.Y - a0.Z)*m0.Z + (fp2.Y - a0.Z)*m1.Z;
vertlist[i] = fp;
}
}
else
{
for (i=s->numverts-1; i>=0; i--)
{
fp.Z = v0[i].x*m0.X + v1[i].x*m1.X;
fp.Y = v0[i].z*m0.Z + v1[i].z*m1.Z;
fp.X = v0[i].y*m0.Y + v1[i].y*m1.Y;
vertlist[i] = fp;
}
}
//Let OpenGL (and perhaps hardware :) handle the matrix rotation
mat[3] = mat[7] = mat[11] = 0.f; mat[15] = 1.f;
for (int mm = 0; mm < 15; mm++) mat[mm] *= 1024.f;
GLInterface.SetMatrix(Matrix_Model, mat);
// PLAG: End
bool exact = false;
auto tex = mdloadskin((md2model_t *)m,tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum,globalpal,surfi, &exact);
if (!tex)
continue;
int palid = TRANSLATION(Translation_Remap + curbasepal, globalpal);
GLInterface.SetFade(tspr->sectp->floorpal);
GLInterface.SetTexture(tex, palid, CLAMP_XY);
if (tspr->clipdist & TSPR_FLAGS_MDHACK)
{
//POGOTODO: if we add support for palette indexing on model skins, the texture for the palswap could be setup here
indexhandle = m->vindexes;
//PLAG: delayed polygon-level sorted rendering
if (m->usesalpha)
{
for (i=0; i<=s->numtris-1; ++i)
{
FVector3 const vlt[3] = { vertlist[s->tris[i].i[0]], vertlist[s->tris[i].i[1]], vertlist[s->tris[i].i[2]] };
// Matrix multiplication - ugly but clear
FVector3 const fpmat[3] = { { (vlt[0].X * mat[0]) + (vlt[0].Y * mat[4]) + (vlt[0].Z * mat[8]) + mat[12],
(vlt[0].X * mat[1]) + (vlt[0].Y * mat[5]) + (vlt[0].Z * mat[9]) + mat[13],
(vlt[0].X * mat[2]) + (vlt[0].Y * mat[6]) + (vlt[0].Z * mat[10]) + mat[14] },
{ (vlt[1].X * mat[0]) + (vlt[1].Y * mat[4]) + (vlt[1].Z * mat[8]) + mat[12],
(vlt[1].X * mat[1]) + (vlt[1].Y * mat[5]) + (vlt[1].Z * mat[9]) + mat[13],
(vlt[1].X * mat[2]) + (vlt[1].Y * mat[6]) + (vlt[1].Z * mat[10]) + mat[14] },
{ (vlt[2].X * mat[0]) + (vlt[2].Y * mat[4]) + (vlt[2].Z * mat[8]) + mat[12],
(vlt[2].X * mat[1]) + (vlt[2].Y * mat[5]) + (vlt[2].Z * mat[9]) + mat[13],
(vlt[2].X * mat[2]) + (vlt[2].Y * mat[6]) + (vlt[2].Z * mat[10]) + mat[14] } };
f = (fpmat[0].X * fpmat[0].X) + (fpmat[0].Y * fpmat[0].Y) + (fpmat[0].Z * fpmat[0].Z);
g = (fpmat[1].X * fpmat[1].X) + (fpmat[1].Y * fpmat[1].Y) + (fpmat[1].Z * fpmat[1].Z);
if (f > g)
f = g;
g = (fpmat[2].X * fpmat[2].X) + (fpmat[2].Y * fpmat[2].Y) + (fpmat[2].Z * fpmat[2].Z);
if (f > g)
f = g;
m->maxdepths[i] = f;
m->indexes[i] = i;
}
// dichotomic recursive sorting - about 100x less iterations than bubblesort
quicksort(m->indexes, m->maxdepths, 0, s->numtris - 1);
}
md3draw_handle_triangles(s, indexhandle, 1, m->usesalpha ? m : NULL);
}
else
{
indexhandle = m->vindexes;
md3draw_handle_triangles(s, indexhandle, 1, NULL);
}
}
//------------
if (m->usesalpha) GLInterface.EnableAlphaTest(false);
GLInterface.SetCull(Cull_None);
GLInterface.SetIdentityMatrix(Matrix_Model);
globalnoeffect=0;
return 1;
}
static void md3free(md3model_t *m) static void md3free(md3model_t *m)
{ {
@ -1508,22 +1158,6 @@ static mdmodel_t *mdload(const char *filnam)
} }
int32_t polymost_mddraw(tspritetype* tspr)
{
if (maxmodelverts > allocmodelverts)
{
vertlist = (FVector3 *) M_Realloc(vertlist, sizeof(FVector3)*maxmodelverts);
allocmodelverts = maxmodelverts;
}
mdmodel_t *const vm = models[tile2model[Ptile2tile(tspr->picnum, tspr->ownerActor->spr.pal)].modelid];
if (vm->mdnum == 1)
return polymost_voxdraw((voxmodel_t *)vm,tspr, false); // can't access rotating info anymore
else if (vm->mdnum == 3)
return polymost_md3draw((md3model_t *)vm,tspr);
return 0;
}
void voxfree(voxmodel_t* m) void voxfree(voxmodel_t* m)
{ {
if (m) delete m; if (m) delete m;

File diff suppressed because it is too large Load diff

View file

@ -55,7 +55,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "v_text.h" #include "v_text.h"
#include "resourcefile.h" #include "resourcefile.h"
#include "c_dispatch.h" #include "c_dispatch.h"
#include "glbackend/glbackend.h"
#include "engineerrors.h" #include "engineerrors.h"
#include "gamestate.h" #include "gamestate.h"
#include "gstrings.h" #include "gstrings.h"
@ -82,6 +81,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "wipe.h" #include "wipe.h"
#include "findfile.h" #include "findfile.h"
#include "version.h" #include "version.h"
#include "hw_material.h"
void LoadHexFont(const char* filename); void LoadHexFont(const char* filename);
@ -1130,7 +1130,6 @@ int RunGame()
setVideoMode(); setVideoMode();
LoadVoxelModels(); LoadVoxelModels();
GLInterface.Init(screen->GetWidth());
screen->BeginFrame(); screen->BeginFrame();
screen->SetTextureFilterMode(); screen->SetTextureFilterMode();
setViewport(hud_size); setViewport(hud_size);

View file

@ -77,7 +77,6 @@
#include "c_console.h" #include "c_console.h"
#include "uiinput.h" #include "uiinput.h"
#include "v_video.h" #include "v_video.h"
#include "glbackend/glbackend.h"
#include "palette.h" #include "palette.h"
#include "build.h" #include "build.h"
#include "g_input.h" #include "g_input.h"
@ -397,7 +396,6 @@ void DrawOverlays()
// Display // Display
// //
//========================================================================== //==========================================================================
EXTERN_CVAR(Bool, vid_renderer);
void Display() void Display()
{ {
@ -442,7 +440,6 @@ void Display()
screen->SetSceneRenderTarget(gl_ssao != 0); screen->SetSceneRenderTarget(gl_ssao != 0);
updateModelInterpolation(); updateModelInterpolation();
gi->Render(); gi->Render();
if (vid_renderer == 0) videoShowFrame();
DrawFullscreenBlends(); DrawFullscreenBlends();
drawMapTitle(); drawMapTitle();
break; break;

View file

@ -45,7 +45,6 @@
#include "v_font.h" #include "v_font.h"
#include "printf.h" #include "printf.h"
#include "v_draw.h" #include "v_draw.h"
#include "../../glbackend/glbackend.h"
LookupTableInfo lookups; LookupTableInfo lookups;
int numshades; int numshades;
@ -419,6 +418,7 @@ void LookupTableInfo::setPaletteTint(int palnum, int r, int g, int b, int sr, in
#include "v_2ddrawer.h" #include "v_2ddrawer.h"
uint8_t curbasepal; uint8_t curbasepal;
int32_t r_scenebrightness;
PalEntry palfadergb; PalEntry palfadergb;
static int32_t tint_blood_r = 0, tint_blood_g = 0, tint_blood_b = 0; static int32_t tint_blood_r = 0, tint_blood_g = 0, tint_blood_b = 0;
glblend_t glblend[MAXBLENDTABS]; glblend_t glblend[MAXBLENDTABS];
@ -462,17 +462,6 @@ FRenderStyle GetRenderStyle(int blend, int def)
return rs; return rs;
} }
void SetRenderStyleFromBlend(uint8_t enable, uint8_t blend, uint8_t def)
{
if (!enable)
{
GLInterface.SetRenderStyle(LegacyRenderStyles[STYLE_Translucent]);
return;
}
auto rs = GetRenderStyle(blend, def);
GLInterface.SetRenderStyle(rs);
}
float GetAlphaFromBlend(uint32_t method, uint32_t blend) float GetAlphaFromBlend(uint32_t method, uint32_t blend)
{ {
return method == DAMETH_TRANS1 || method == DAMETH_TRANS2 ? glblend[blend].def[method - DAMETH_TRANS1].alpha : 1.f; return method == DAMETH_TRANS1 || method == DAMETH_TRANS2 ? glblend[blend].def[method - DAMETH_TRANS1].alpha : 1.f;

View file

@ -188,8 +188,12 @@ struct glblend_t
extern glblend_t const nullglblend, defaultglblend; extern glblend_t const nullglblend, defaultglblend;
extern glblend_t glblend[MAXBLENDTABS]; extern glblend_t glblend[MAXBLENDTABS];
enum {
DAMETH_TRANS1 = 2,
DAMETH_TRANS2 = 3,
};
FRenderStyle GetRenderStyle(int blend, int def); FRenderStyle GetRenderStyle(int blend, int def);
extern void SetRenderStyleFromBlend(uint8_t enable, uint8_t blend, uint8_t def);
float GetAlphaFromBlend(uint32_t maskprops, uint32_t blend); float GetAlphaFromBlend(uint32_t maskprops, uint32_t blend);
void DrawFullscreenBlends(); void DrawFullscreenBlends();

View file

@ -59,6 +59,15 @@ float GlobalFogDensity = 350.f;
TArray<PortalDesc> allPortals; TArray<PortalDesc> allPortals;
void Draw2D(F2DDrawer* drawer, FRenderState& state); void Draw2D(F2DDrawer* drawer, FRenderState& state);
CVARD(Bool, hw_hightile, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable hightile texture rendering")
bool hw_int_useindexedcolortextures;
CUSTOM_CVARD(Bool, hw_useindexedcolortextures, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable indexed color texture rendering")
{
if (screen) screen->SetTextureFilterMode();
}
CVARD(Bool, hw_models, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable model rendering")
#if 0 #if 0
void CollectLights(FLevelLocals* Level) void CollectLights(FLevelLocals* Level)
@ -230,15 +239,9 @@ bool writingsavepic;
FileWriter* savefile; FileWriter* savefile;
int savewidth, saveheight; int savewidth, saveheight;
void PM_WriteSavePic(FileWriter* file, int width, int height); void PM_WriteSavePic(FileWriter* file, int width, int height);
EXTERN_CVAR(Bool, vid_renderer);
void WriteSavePic(FileWriter* file, int width, int height) void WriteSavePic(FileWriter* file, int width, int height)
{ {
if (!vid_renderer)
{
PM_WriteSavePic(file, width, height);
return;
}
int oldx = xdim; int oldx = xdim;
int oldy = ydim; int oldy = ydim;
auto oldwindowxy1 = windowxy1; auto oldwindowxy1 = windowxy1;

View file

@ -27,7 +27,6 @@
#include "hw_drawinfo.h" #include "hw_drawinfo.h"
#include "hw_material.h" #include "hw_material.h"
#include "build.h" #include "build.h"
#include "polymost.h"
#include "gamefuncs.h" #include "gamefuncs.h"
EXTERN_CVAR(Bool, gl_seamless) EXTERN_CVAR(Bool, gl_seamless)

View file

@ -38,7 +38,6 @@
#include "v_video.h" #include "v_video.h"
#include "flatvertices.h" #include "flatvertices.h"
#include "glbackend/glbackend.h"
DCoreActor* wall_to_sprite_actors[8]; // gets updated each frame. Todo: Encapsulate this better without having to permanently store actors in the wall object. DCoreActor* wall_to_sprite_actors[8]; // gets updated each frame. Todo: Encapsulate this better without having to permanently store actors in the wall object.

View file

@ -41,8 +41,6 @@
#include "c_dispatch.h" #include "c_dispatch.h"
#include "v_video.h" #include "v_video.h"
#include "../../glbackend/glbackend.h"
EXTERN_CVAR(Float, png_gamma) EXTERN_CVAR(Float, png_gamma)
// //
// screencapture // screencapture

View file

@ -241,7 +241,7 @@ void ZCCRazeCompiler::DispatchProperty(FPropertyInfo *prop, ZCC_PropertyStmt *pr
const char * p = prop->params; const char * p = prop->params;
auto exp = property->Values; auto exp = property->Values;
FCompileContext ctx(OutNamespace, bag.Info->VMType, false); FCompileContext ctx(OutNamespace, bag.Info->VMType, false, mVersion);
while (true) while (true)
{ {
FPropParam conv; FPropParam conv;
@ -422,7 +422,7 @@ void ZCCRazeCompiler::DispatchScriptProperty(PProperty *prop, ZCC_PropertyStmt *
} }
auto exp = property->Values; auto exp = property->Values;
FCompileContext ctx(OutNamespace, bag.Info->VMType, false); FCompileContext ctx(OutNamespace, bag.Info->VMType, false, mVersion);
for (auto f : prop->Variables) for (auto f : prop->Variables)
{ {
void *addr; void *addr;

View file

@ -66,8 +66,6 @@
#include "src/warp.cpp" #include "src/warp.cpp"
#include "src/weapon.cpp" #include "src/weapon.cpp"
#include "src/_polymost.cpp"
// This includes the VM so it is last // This includes the VM so it is last
#include "src/d_menu.cpp" #include "src/d_menu.cpp"

View file

@ -1,358 +0,0 @@
#include "polymost.h"
BEGIN_BLD_NS
// leftover bits needed to keep Polymost running through the transition.
// This is mainly the game side part of the portal renderer.
void collectTSpritesForPortal(int x, int y, int i, int interpolation)
{
int nSector = mirror[i].link;
int nSector2 = mirror[i].wallnum;
BloodSectIterator it(nSector);
while (auto actor = it.Next())
{
if (actor == gView->actor)
continue;
int top, bottom;
GetActorExtents(actor, &top, &bottom);
int zCeil, zFloor;
getzsofslopeptr(&sector[nSector], actor->spr.pos.X, actor->spr.pos.Y, &zCeil, &zFloor);
if (actor->spr.statnum == kStatDude && (top < zCeil || bottom > zFloor))
{
int j = i;
if (mirror[i].type == 2)
j++;
else
j--;
int dx = mirror[j].dx;
int dy = mirror[j].dy;
int dz = mirror[j].dz;
if (pm_spritesortcnt < MAXSPRITESONSCREEN)
{
tspritetype* pTSprite = &pm_tsprite[pm_spritesortcnt++];
*pTSprite = {};
pTSprite->type = actor->spr.type;
pTSprite->sectp = &sector[nSector2];
pTSprite->pos.X = actor->spr.pos.X + dx;
pTSprite->pos.Y = actor->spr.pos.Y + dy;
pTSprite->pos.Z = actor->spr.pos.Z + dz;
pTSprite->ang = actor->spr.ang;
pTSprite->picnum = actor->spr.picnum;
pTSprite->shade = actor->spr.shade;
pTSprite->pal = actor->spr.pal;
pTSprite->xrepeat = actor->spr.xrepeat;
pTSprite->yrepeat = actor->spr.yrepeat;
pTSprite->xoffset = actor->spr.xoffset;
pTSprite->yoffset = actor->spr.yoffset;
pTSprite->cstat = actor->spr.cstat;
pTSprite->statnum = kStatDecoration;
pTSprite->ownerActor = actor;
pTSprite->flags = actor->spr.hitag | 0x200;
pTSprite->pos.X = dx + interpolatedvalue(actor->opos.X, actor->spr.pos.X, interpolation);
pTSprite->pos.Y = dy + interpolatedvalue(actor->opos.Y, actor->spr.pos.Y, interpolation);
pTSprite->pos.Z = dz + interpolatedvalue(actor->opos.Z, actor->spr.pos.Z, interpolation);
pTSprite->ang = actor->interpolatedang(interpolation);
int nAnim = 0;
switch (picanm[pTSprite->picnum].extra & 7)
{
case 1:
{
int dX = x - pTSprite->pos.X;
int dY = y - pTSprite->pos.Y;
RotateVector(&dX, &dY, 128 - pTSprite->ang);
nAnim = GetOctant(dX, dY);
if (nAnim <= 4)
{
pTSprite->cstat &= ~CSTAT_SPRITE_XFLIP;
}
else
{
nAnim = 8 - nAnim;
pTSprite->cstat |= CSTAT_SPRITE_XFLIP;
}
break;
}
case 2:
{
int dX = x - pTSprite->pos.X;
int dY = y - pTSprite->pos.Y;
RotateVector(&dX, &dY, 128 - pTSprite->ang);
nAnim = GetOctant(dX, dY);
break;
}
}
while (nAnim > 0)
{
pTSprite->picnum += picanm[pTSprite->picnum].num + 1;
nAnim--;
}
pm_spritesortcnt++;
}
}
}
}
void processSpritesOnOtherSideOfPortal(int x, int y, int interpolation)
{
if (pm_spritesortcnt == 0) return;
int nViewSprites = pm_spritesortcnt-1;
for (int nTSprite = nViewSprites; nTSprite >= 0; nTSprite--)
{
tspritetype *pTSprite = &pm_tsprite[nTSprite];
pTSprite->xrepeat = pTSprite->yrepeat = 0;
}
for (int i = mirrorcnt-1; i >= 0; i--)
{
int nTile = 4080+i;
if (testgotpic(nTile))
{
if (mirror[i].type == 1 || mirror[i].type == 2)
{
collectTSpritesForPortal(x, y, i, interpolation);
}
}
}
}
void render3DViewPolymost(int nSectnum, int cX, int cY, int cZ, binangle cA, fixedhoriz cH)
{
videoSetCorrectedAspect();
int v1 = xs_CRoundToInt(double(viewingrange) * tan(r_fov * (pi::pi() / 360.)));
renderSetAspect(v1, yxaspect);
RORHACK:
bool ror_status[16];
for (int i = 0; i < 16; i++)
ror_status[i] = testgotpic(4080 + i);
fixed_t deliriumPitchI = interpolatedvalue(IntToFixed(deliriumPitchO), IntToFixed(deliriumPitch), gInterpolate);
DrawMirrors(cX, cY, cZ, cA.asq16(), cH.asq16() + deliriumPitchI, int(gInterpolate), gViewIndex);
auto bakCstat = gView->actor->spr.cstat;
if (gViewPos == 0)
{
gView->actor->spr.cstat |= CSTAT_SPRITE_INVISIBLE;
}
else
{
gView->actor->spr.cstat |= CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP;
}
renderDrawRoomsQ16(cX, cY, cZ, cA.asq16(), cH.asq16() + deliriumPitchI, nSectnum, false);
viewProcessSprites(pm_tsprite, pm_spritesortcnt, cX, cY, cZ, cA.asbuild(), int(gInterpolate));
bool do_ror_hack = false;
for (int i = 0; i < 16; i++)
if (ror_status[i] != testgotpic(4080 + i))
do_ror_hack = true;
if (do_ror_hack)
{
gView->actor->spr.cstat = bakCstat;
pm_spritesortcnt = 0;
goto RORHACK;
}
setPortalFlags(1);
int nSpriteSortCnt = pm_spritesortcnt;
renderDrawMasks();
pm_spritesortcnt = nSpriteSortCnt;
setPortalFlags(0);
processSpritesOnOtherSideOfPortal(cX, cY, int(gInterpolate));
renderDrawMasks();
gView->actor->spr.cstat = bakCstat;
}
// hack the portal planes with the sky flag for rendering. Only Polymost needs this hack.
void setPortalFlags(int mode)
{
for (int i = mirrorcnt - 1; i >= 0; i--)
{
int nTile = 4080 + i;
if (testgotpic(nTile))
{
switch (mirror[i].type)
{
case 1:
if (mode)
sector[mirror[i].wallnum].ceilingstat |= CSTAT_SECTOR_SKY;
else
sector[mirror[i].wallnum].ceilingstat &= ~CSTAT_SECTOR_SKY;
break;
case 2:
if (mode)
sector[mirror[i].wallnum].floorstat |= CSTAT_SECTOR_SKY;
else
sector[mirror[i].wallnum].floorstat &= ~CSTAT_SECTOR_SKY;
break;
}
}
}
}
// Note: debug range checks on wall [] need to be disabled because this deliberately writes beyond the regular part.
void DrawMirrors(int x, int y, int z, fixed_t a, fixed_t horiz, int smooth, int viewPlayer)
{
auto wallarr = wall.Data(); // this disables the range checks for the wall TArray,
for (int i = mirrorcnt - 1; i >= 0; i--)
{
int nTile = 4080 + i;
if (testgotpic(nTile, true))
{
switch (mirror[i].type)
{
case 0:
{
// gross hack alert. Blood adds some dummy walls and sectors that must not be among the counted, but here they have to be valid.
wall.Reserve(4);
sector.Reserve(1);
int nWall = mirror[i].link;
walltype* pWall = &wall[nWall];
int nSector = pWall->sector;
int nNextWall = pWall->nextwall;
int nNextSector = pWall->nextsector;
pWall->nextwall = mirrorwall[0];
pWall->nextsector = mirrorsector;
wallarr[mirrorwall[0]].nextwall = nWall;
wallarr[mirrorwall[0]].nextsector = nSector;
wallarr[mirrorwall[0]].pos.X = pWall->point2Wall()->pos.X;
wallarr[mirrorwall[0]].pos.Y = pWall->point2Wall()->pos.Y;
wallarr[mirrorwall[1]].pos.X = pWall->pos.X;
wallarr[mirrorwall[1]].pos.Y = pWall->pos.Y;
wallarr[mirrorwall[2]].pos.X = wallarr[mirrorwall[1]].pos.X + (wallarr[mirrorwall[1]].pos.X - wallarr[mirrorwall[0]].pos.X) * 16;
wallarr[mirrorwall[2]].pos.Y = wallarr[mirrorwall[1]].pos.Y + (wallarr[mirrorwall[1]].pos.Y - wallarr[mirrorwall[0]].pos.Y) * 16;
wallarr[mirrorwall[3]].pos.X = wallarr[mirrorwall[0]].pos.X + (wallarr[mirrorwall[0]].pos.X - wallarr[mirrorwall[1]].pos.X) * 16;
wallarr[mirrorwall[3]].pos.Y = wallarr[mirrorwall[0]].pos.Y + (wallarr[mirrorwall[0]].pos.Y - wallarr[mirrorwall[1]].pos.Y) * 16;
sector.Data()[mirrorsector].setfloorz(sector[nSector].floorz, true);
sector.Data()[mirrorsector].setceilingz(sector[nSector].ceilingz, true);
int cx, cy, ca;
if (pWall->type == kWallStack)
{
cx = x - (wall[pWall->hitag].wall_int_pos().X - pWall->point2Wall()->wall_int_pos().X);
cy = y - (wall[pWall->hitag].wall_int_pos().Y - pWall->point2Wall()->wall_int_pos().Y);
ca = a;
}
else
{
renderPrepareMirror(x, y, z, a, horiz, nWall, &cx, &cy, &ca);
}
renderDrawRoomsQ16(cx, cy, z, ca, horiz, mirrorsector, true);
viewProcessSprites(pm_tsprite, pm_spritesortcnt, cx, cy, z, FixedToInt(ca), smooth);
renderDrawMasks();
if (pWall->type != kWallStack)
renderCompleteMirror();
pWall->nextwall = nNextWall;
pWall->nextsector = nNextSector;
wall.Clamp(wall.Size() - 4);
sector.Clamp(sector.Size() - 1);
return;
}
case 1:
{
r_rorphase = 1;
int nSector = mirror[i].link;
ESpriteFlags bakCstat = 0;
if (viewPlayer >= 0)
{
bakCstat = gPlayer[viewPlayer].actor->spr.cstat;
if (gViewPos == 0)
{
gPlayer[viewPlayer].actor->spr.cstat |= CSTAT_SPRITE_INVISIBLE;
}
else
{
gPlayer[viewPlayer].actor->spr.cstat |= CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP;
}
}
renderDrawRoomsQ16(x + mirror[i].dx, y + mirror[i].dy, z + mirror[i].dz, a, horiz, nSector, true);
viewProcessSprites(pm_tsprite, pm_spritesortcnt, x + mirror[i].dx, y + mirror[i].dy, z + mirror[i].dz, FixedToInt(a), smooth);
auto fstat = sector[nSector].floorstat;
sector[nSector].floorstat |= CSTAT_SECTOR_SKY;
renderDrawMasks();
sector[nSector].floorstat = fstat;
for (int ii = 0; ii < 16; ii++)
gotpic.Clear(4080 + ii);
if (viewPlayer >= 0)
{
gPlayer[viewPlayer].actor->spr.cstat = bakCstat;
}
r_rorphase = 0;
return;
}
case 2:
{
r_rorphase = 1;
int nSector = mirror[i].link;
ESpriteFlags bakCstat = 0;
if (viewPlayer >= 0)
{
bakCstat = gPlayer[viewPlayer].actor->spr.cstat;
if (gViewPos == 0)
{
gPlayer[viewPlayer].actor->spr.cstat |= CSTAT_SPRITE_INVISIBLE;
}
else
{
gPlayer[viewPlayer].actor->spr.cstat |= CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP;
}
}
renderDrawRoomsQ16(x + mirror[i].dx, y + mirror[i].dy, z + mirror[i].dz, a, horiz, nSector, true);
viewProcessSprites(pm_tsprite, pm_spritesortcnt, x + mirror[i].dx, y + mirror[i].dy, z + mirror[i].dz, FixedToInt(a), smooth);
auto cstat = sector[nSector].ceilingstat;
sector[nSector].ceilingstat |= CSTAT_SECTOR_SKY;
renderDrawMasks();
sector[nSector].ceilingstat = cstat;
for (int ii = 0; ii < 16; ii++)
gotpic.Clear(4080 + ii);
if (viewPlayer >= 0)
{
gPlayer[viewPlayer].actor->spr.cstat = bakCstat;
}
r_rorphase = 0;
return;
}
}
}
}
}
void InitPolymostMirrorHack()
{
mirrorsector = sector.Size();
for (int i = 0; i < 4; i++)
{
mirrorwall[i] = wall.Size() + i;
auto pWall = &(wall.Data()[mirrorwall[i]]);
pWall->picnum = 504;
pWall->overpicnum = 504;
pWall->cstat = 0;
pWall->nextsector = -1;
pWall->nextwall = -1;
pWall->point2 = wall.Size() + i + 1;
}
wall.Data()[mirrorwall[3]].point2 = mirrorwall[0];
sector.Data()[mirrorsector].ceilingpicnum = 504;
sector.Data()[mirrorsector].floorpicnum = 504;
sector.Data()[mirrorsector].wallptr = mirrorwall[0];
sector.Data()[mirrorsector].wallnum = 4;
}
void PolymostAllocFakeSector()
{
// these additional entries are needed by Blood's mirror code. We must get them upon map load to avoid a later occuring reallocation. Ugh...
// We do not want to actually increase the array size for this, though because it may screw with the savegame code.
// Before rendering this will temporarily be bumped up.
// Note that this depends on the resize operation not deleting and altering the new entries!
sector.Reserve(1);
wall.Reserve(4);
wall.Clamp(wall.Size() - 4);
sector.Clamp(sector.Size() - 1);
}
END_BLD_NS

View file

@ -38,7 +38,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "v_font.h" #include "v_font.h"
#include "hw_voxels.h" #include "hw_voxels.h"
#include "gamefuncs.h" #include "gamefuncs.h"
#include "glbackend/glbackend.h"
BEGIN_BLD_NS BEGIN_BLD_NS

View file

@ -96,12 +96,6 @@ struct MIRROR
extern MIRROR mirror[16]; extern MIRROR mirror[16];
extern int mirrorcnt, mirrorsector, mirrorwall[4]; extern int mirrorcnt, mirrorsector, mirrorwall[4];
//polymost needs to do some voodoo for mirrors.
void InitPolymostMirrorHack();
void PolymostAllocFakeSector();
inline bool DemoRecordStatus(void) inline bool DemoRecordStatus(void)
{ {
return false; return false;

View file

@ -218,9 +218,6 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, int*
} }
gMapRev = mapHeader.revision; gMapRev = mapHeader.revision;
allocateMapArrays(mapHeader.numwalls, mapHeader.numsectors, mapHeader.numsprites); allocateMapArrays(mapHeader.numwalls, mapHeader.numsectors, mapHeader.numsprites);
#if 1 // bad, bad hack, just for making Polymost happy...
PolymostAllocFakeSector();
#endif
*cursectnum = mapHeader.sect; *cursectnum = mapHeader.sect;
if (encrypted) if (encrypted)

View file

@ -43,9 +43,6 @@ MIRROR mirror[16]; // only needed by Polymost.
void InitMirrors(void) void InitMirrors(void)
{ {
r_rortexture = 4080;
r_rortexturerange = 16;
mirrorcnt = 0; mirrorcnt = 0;
tileDelete(504); tileDelete(504);
portalClear(); portalClear();
@ -154,7 +151,6 @@ void InitMirrors(void)
} }
mirrorsector = sector.Size(); mirrorsector = sector.Size();
mergePortals(); mergePortals();
InitPolymostMirrorHack();
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -198,14 +194,10 @@ void SerializeMirrors(FSerializer& arc)
tileDelete(504); tileDelete(504);
r_rortexture = 4080;
r_rortexturerange = 16;
for (int i = 0; i < 16; i++) for (int i = 0; i < 16; i++)
{ {
tileDelete(4080 + i); tileDelete(4080 + i);
} }
InitPolymostMirrorHack();
} }
} }

View file

@ -45,7 +45,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "razefont.h" #include "razefont.h"
EXTERN_CVAR(Bool, vid_renderer)
BEGIN_BLD_NS BEGIN_BLD_NS
VIEW gPrevView[kMaxPlayers]; VIEW gPrevView[kMaxPlayers];
@ -655,7 +654,6 @@ void viewDrawScreen(bool sceneonly)
gInterpolate = !cl_interpolate || cl_capfps ? MaxSmoothRatio : I_GetTimeFrac() * MaxSmoothRatio; gInterpolate = !cl_interpolate || cl_capfps ? MaxSmoothRatio : I_GetTimeFrac() * MaxSmoothRatio;
} }
else gInterpolate = MaxSmoothRatio; else gInterpolate = MaxSmoothRatio;
pm_smoothratio = (int)gInterpolate;
if (cl_interpolate) if (cl_interpolate)
{ {
@ -766,21 +764,12 @@ void viewDrawScreen(bool sceneonly)
} }
} }
if (vid_renderer) if (!sceneonly) hudDraw(gView, pSector, shakeX, shakeY, zDelta, basepal, gInterpolate);
{ fixedhoriz deliriumPitchI = q16horiz(interpolatedvalue(IntToFixed(deliriumPitchO), IntToFixed(deliriumPitch), gInterpolate));
if (!sceneonly) hudDraw(gView, pSector, shakeX, shakeY, zDelta, basepal, gInterpolate); auto bakCstat = gView->actor->spr.cstat;
fixedhoriz deliriumPitchI = q16horiz(interpolatedvalue(IntToFixed(deliriumPitchO), IntToFixed(deliriumPitch), gInterpolate)); gView->actor->spr.cstat |= (gViewPos == 0) ? CSTAT_SPRITE_INVISIBLE : CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP;
auto bakCstat = gView->actor->spr.cstat; render_drawrooms(gView->actor, { cX, cY, cZ }, sectnum(pSector), cA, cH + deliriumPitchI, rotscrnang, gInterpolate);
gView->actor->spr.cstat |= (gViewPos == 0) ? CSTAT_SPRITE_INVISIBLE : CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP; gView->actor->spr.cstat = bakCstat;
render_drawrooms(gView->actor, { cX, cY, cZ }, sectnum(pSector), cA, cH + deliriumPitchI, rotscrnang, gInterpolate);
gView->actor->spr.cstat = bakCstat;
}
else
{
renderSetRollAngle((float)rotscrnang.asbuildf());
render3DViewPolymost(sectnum(pSector), cX, cY, cZ, cA, cH);
if (!sceneonly) hudDraw(gView, pSector, shakeX, shakeY, zDelta, basepal, gInterpolate);
}
bDeliriumOld = bDelirium && gDeliriumBlur; bDeliriumOld = bDelirium && gDeliriumBlur;
int nClipDist = gView->actor->spr.clipdist << 2; int nClipDist = gView->actor->spr.clipdist << 2;

View file

@ -1,274 +0,0 @@
BEGIN_DUKE_NS
void SE40_Draw(int tag, spritetype *spr, int x, int y, int z, binangle a, fixedhoriz h, int smoothratio)
{
int i, k = 0;
int ok = 0, fofmode = 0;
int offx, offy;
spritetype* floor1, *floor2 = nullptr;
if (spr->ang != 512) return;
i = FOF; //Effect TILE
tileDelete(FOF);
if (!testgotpic(FOF, true)) return;
floor1 = spr;
if (spr->lotag == tag + 2) fofmode = tag + 0;
if (spr->lotag == tag + 3) fofmode = tag + 1;
if (spr->lotag == tag + 4) fofmode = tag + 0;
if (spr->lotag == tag + 5) fofmode = tag + 1;
ok++;
DukeStatIterator it(STAT_RAROR);
while (auto act = it.Next())
{
if (
act->spr.picnum == SECTOREFFECTOR &&
act->spr.lotag == fofmode &&
act->spr.hitag == floor1->hitag
)
{
floor1 = spr;
fofmode = act->spr.lotag;
ok++;
break;
}
}
// if(ok==1) { Message("no floor1",RED); return; }
if (fofmode == tag + 0) k = tag + 1; else k = tag + 0;
it.Reset(STAT_RAROR);
while (auto act = it.Next())
{
if (
act->spr.picnum == SECTOREFFECTOR &&
act->spr.lotag == k &&
act->spr.hitag == floor1->hitag
)
{
floor2 = spr;
ok++;
break;
}
}
// if(ok==2) { Message("no floor2",RED); return; }
it.Reset(STAT_RAROR);
while (auto act = it.Next())
{
if (act->spr.picnum == SECTOREFFECTOR &&
act->spr.lotag == k + 2 &&
act->spr.hitag == floor1->hitag
)
{
auto sect = act->sector();
// repurpose otherwise unused fields in sectortype as temporary storage.
if (k == tag + 0)
{
sect->Flag = sect->floorz;
sect->addfloorz((((z - sect->floorz) / 32768) + 1) * 32768, true);
sect->Damage = sect->floorpicnum;
sect->floorpicnum = 13;
}
if (k == tag + 1)
{
sect->Flag = sect->ceilingz;
sect->addceilingz((((z - sect->ceilingz) / 32768) - 1) * 32768, true);
sect->Damage = sect->ceilingpicnum;
sect->ceilingpicnum = 13;
}
}
}
offx = x - floor1->pos.X;
offy = y - floor1->pos.Y;
renderDrawRoomsQ16(floor2->pos.X + offx, floor2->pos.Y + offy, z, a.asq16(), h.asq16(), floor2->sectp, false);
fi.animatesprites(pm_tsprite, pm_spritesortcnt, offx + floor2->pos.X, offy + floor2->pos.Y, a.asbuild(), smoothratio);
renderDrawMasks();
it.Reset(STAT_RAROR);
while (auto act = it.Next())
{
if (act->spr.picnum == 1 &&
act->spr.lotag == k + 2 &&
act->spr.hitag == floor1->hitag
)
{
auto sect = act->sector();
if (k == tag + 0)
{
sect->setfloorz(sect->Flag, true);
sect->floorpicnum = sect->Damage;
}
if (k == tag + 1)
{
sect->setceilingz(sect->Flag, true);
sect->ceilingpicnum = sect->Damage;
}
}// end if
}// end for
} // end SE40
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void se40code(int x, int y, int z, binangle a, fixedhoriz h, int smoothratio)
{
int tag;
if (!isRR()) tag = 40;
else if (isRRRA()) tag = 150;
else return;
DukeStatIterator it(STAT_RAROR);
while (auto act = it.Next())
{
switch (act->spr.lotag - tag + 40)
{
//case 40:
//case 41:
// SE40_Draw(i,x,y,a,smoothratio);
// break;
case 42:
case 43:
case 44:
case 45:
if (ps[screenpeek].cursector == act->sector())
SE40_Draw(tag, &act->spr, x, y, z, a, h, smoothratio);
break;
}
}
}
//---------------------------------------------------------------------------
//
// split out so it can also be applied to camera views
//
//---------------------------------------------------------------------------
void renderMirror(int cposx, int cposy, int cposz, binangle cang, fixedhoriz choriz, int smoothratio)
{
if (mirrorcnt > 0 && testgotpic(TILE_MIRROR, true))
{
int dst = 0x7fffffff, i = 0;
for (int k = 0; k < mirrorcnt; k++)
{
int j = abs(mirrorwall[k]->wall_int_pos().X - cposx) + abs(mirrorwall[k]->wall_int_pos().Y - cposy);
if (j < dst) dst = j, i = k;
}
if (mirrorwall[i] && mirrorwall[i]->overpicnum == TILE_MIRROR)
{
int tposx, tposy;
fixed_t tang;
renderPrepareMirror(cposx, cposy, cposz, cang.asq16(), choriz.asq16(), wallnum(mirrorwall[i]), &tposx, &tposy, &tang);
int j = g_visibility;
g_visibility = (j >> 1) + (j >> 2);
renderDrawRoomsQ16(tposx, tposy, cposz, tang, choriz.asq16(), sectnum(mirrorsector[i]), true);
display_mirror = 1;
fi.animatesprites(pm_tsprite, pm_spritesortcnt, tposx, tposy, tang, smoothratio);
display_mirror = 0;
renderDrawMasks();
renderCompleteMirror(); //Reverse screen x-wise in this function
g_visibility = j;
}
}
}
//---------------------------------------------------------------------------
//
// used by RR to inject some external geometry into a scene.
//
//---------------------------------------------------------------------------
static void geometryEffect(int cposx, int cposy, int cposz, binangle cang, fixedhoriz choriz, int sect, int smoothratio)
{
auto sectp = &sector[sect];
int gs, geoid = 0;
sectortype* tgsect, *geosect;
renderDrawRoomsQ16(cposx, cposy, cposz, cang.asq16(), choriz.asq16(), sect, false);
fi.animatesprites(pm_tsprite, pm_spritesortcnt, cposx, cposy, cang.asbuild(), smoothratio);
renderDrawMasks();
for (gs = 0; gs < geocnt; gs++)
{
tgsect = geosector[gs];
DukeSectIterator it(tgsect);
while (auto act = it.Next())
{
ChangeActorSect(act, geosectorwarp[gs]);
SetActor(act, { act->spr.pos.X -= int(geox[gs] * worldtoint), act->spr.pos.Y -= int(geoy[gs] * worldtoint), act->spr.pos.Z });
}
if (geosector[gs] == sectp)
{
geosect = geosectorwarp[gs];
geoid = gs;
}
}
cposx -= int(geox[geoid] * worldtoint);
cposy -= int(geoy[geoid] * worldtoint);
renderDrawRoomsQ16(cposx, cposy, cposz, cang.asq16(), choriz.asq16(), sect, false);
cposx += int(geox[geoid] * worldtoint);
cposy += int(geoy[geoid] * worldtoint);
for (gs = 0; gs < geocnt; gs++)
{
tgsect = geosectorwarp[gs];
DukeSectIterator it(tgsect);
while (auto act = it.Next())
{
ChangeActorSect(act, geosector[gs]);
SetActor(act, { act->spr.pos.X += int(geox[gs] * worldtoint), act->spr.pos.Y += int(geoy[gs] * worldtoint), act->spr.pos.Z });
}
}
fi.animatesprites(pm_tsprite, pm_spritesortcnt, cposx, cposy, cang.asbuild(), smoothratio);
renderDrawMasks();
for (gs = 0; gs < geocnt; gs++)
{
tgsect = geosector[gs];
DukeSectIterator it(tgsect);
while (auto act = it.Next())
{
ChangeActorSect(act, geosectorwarp2[gs]);
SetActor(act, { act->spr.pos.X -= int(geox2[gs] * worldtoint), act->spr.pos.Y -= int(geoy2[gs] * worldtoint), act->spr.pos.Z });
}
if (geosector[gs] == sectp)
{
geosect = geosectorwarp2[gs];
geoid = gs;
}
}
cposx -= int(geox2[geoid] * worldtoint);
cposy -= int(geoy2[geoid] * worldtoint);
renderDrawRoomsQ16(cposx, cposy, cposz, cang.asq16(), choriz.asq16(), sect, false);
cposx += int(geox2[geoid] * worldtoint);
cposy += int(geoy2[geoid] * worldtoint);
for (gs = 0; gs < geocnt; gs++)
{
tgsect = geosectorwarp2[gs];
DukeSectIterator it(tgsect);
while (auto act = it.Next())
{
ChangeActorSect(act, geosector[gs]);
SetActor(act, { act->spr.pos.X += int(geox2[gs] * worldtoint), act->spr.pos.Y += int(geoy2[gs] * worldtoint), act->spr.pos.Z });
}
}
fi.animatesprites(pm_tsprite, pm_spritesortcnt, cposx, cposy, cang.asbuild(), smoothratio);
renderDrawMasks();
}
END_DUKE_NS

View file

@ -2,7 +2,6 @@
#include "build.h" #include "build.h"
#include "polymost.h"
#include "gamecvars.h" #include "gamecvars.h"
#include "razemenu.h" #include "razemenu.h"
#include "gamecontrol.h" #include "gamecontrol.h"

View file

@ -283,7 +283,7 @@ static void setupbackdrop()
static void initTiles() static void initTiles()
{ {
tileDelete(TILE_MIRROR); tileDelete(TILE_MIRROR);
skiptile = TILE_W_FORCEFIELD + 1; //skiptile = TILE_W_FORCEFIELD + 1;
if (isRR()) if (isRR())
tileDelete(0); tileDelete(0);

View file

@ -34,16 +34,11 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
#include "dukeactor.h" #include "dukeactor.h"
#include "interpolate.h" #include "interpolate.h"
#include "render.h" #include "render.h"
#include "glbackend/glbackend.h"
#include "_polymost.cpp"
// temporary hack to pass along RRRA's global fog. Needs to be done better later. // temporary hack to pass along RRRA's global fog. Needs to be done better later.
extern PalEntry GlobalMapFog; extern PalEntry GlobalMapFog;
extern float GlobalFogDensity; extern float GlobalFogDensity;
EXTERN_CVAR(Bool, vid_renderer)
BEGIN_DUKE_NS BEGIN_DUKE_NS
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -66,23 +61,8 @@ BEGIN_DUKE_NS
void renderView(DDukeActor* playersprite, sectortype* sect, int x, int y, int z, binangle a, fixedhoriz h, binangle rotscrnang, double smoothratio, bool sceneonly) void renderView(DDukeActor* playersprite, sectortype* sect, int x, int y, int z, binangle a, fixedhoriz h, binangle rotscrnang, double smoothratio, bool sceneonly)
{ {
if (!vid_renderer) if (!sceneonly) drawweapon(smoothratio);
{ render_drawrooms(playersprite, { x, y, z }, sectnum(sect), a, h, rotscrnang, smoothratio);
// do screen rotation.
renderSetRollAngle((float)rotscrnang.asbuildf());
se40code(x, y, z, a, h, smoothratio);
renderMirror(x, y, z, a, h, smoothratio);
renderDrawRoomsQ16(x, y, z, a.asq16(), h.asq16(), sect, false);
fi.animatesprites(pm_tsprite, pm_spritesortcnt, x, y, a.asbuild(), smoothratio);
if (!sceneonly) drawweapon(smoothratio);
renderDrawMasks();
}
else
{
if (!sceneonly) drawweapon(smoothratio);
render_drawrooms(playersprite, { x, y, z }, sectnum(sect), a, h, rotscrnang, smoothratio);
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -114,20 +94,10 @@ void GameInterface::UpdateCameras(double smoothratio)
auto camera = camsprite->GetOwner(); auto camera = camsprite->GetOwner();
auto ang = buildang(camera->interpolatedang(smoothratio)); auto ang = buildang(camera->interpolatedang(smoothratio));
display_mirror = 1; // should really be 'display external view'. display_mirror = 1; // should really be 'display external view'.
if (!vid_renderer) auto cstat = camera->spr.cstat;
{ camera->spr.cstat = CSTAT_SPRITE_INVISIBLE;
// Note: no ROR or camera here - Polymost has no means to detect these things before rendering the scene itself. render_camtex(camera, camera->spr.pos, camera->sector(), ang, buildhoriz(camera->spr.shade), buildang(0), tex, rect, smoothratio);
renderDrawRoomsQ16(camera->spr.pos.X, camera->spr.pos.Y, camera->spr.pos.Z, ang.asq16(), IntToFixed(camera->spr.shade), camera->sector(), false); // why 'shade'...? camera->spr.cstat = cstat;
fi.animatesprites(pm_tsprite, pm_spritesortcnt, camera->spr.pos.X, camera->spr.pos.Y, ang.asbuild(), (int)smoothratio);
renderDrawMasks();
}
else
{
auto cstat = camera->spr.cstat;
camera->spr.cstat = CSTAT_SPRITE_INVISIBLE;
render_camtex(camera, camera->spr.pos, camera->sector(), ang, buildhoriz(camera->spr.shade), buildang(0), tex, rect, smoothratio);
camera->spr.cstat = cstat;
}
display_mirror = 0; display_mirror = 0;
}); });
renderRestoreTarget(); renderRestoreTarget();
@ -260,7 +230,6 @@ void displayrooms(int snum, double smoothratio, bool sceneonly)
struct player_struct* p; struct player_struct* p;
p = &ps[snum]; p = &ps[snum];
pm_smoothratio = (int)smoothratio;
if (automapMode == am_full || !p->insector()) if (automapMode == am_full || !p->insector())
return; return;
@ -274,17 +243,13 @@ void displayrooms(int snum, double smoothratio, bool sceneonly)
g_visibility = ud.const_visibility; g_visibility = ud.const_visibility;
g_relvisibility = p->visibility - ud.const_visibility; g_relvisibility = p->visibility - ud.const_visibility;
videoSetCorrectedAspect();
auto sect = p->cursector; auto sect = p->cursector;
GlobalMapFog = fogactive ? 0x999999 : 0; GlobalMapFog = fogactive ? 0x999999 : 0;
GlobalFogDensity = fogactive ? 350.f : 0.f; GlobalFogDensity = fogactive ? 350.f : 0.f;
GLInterface.SetMapFog(fogactive != 0);
DoInterpolations(smoothratio / 65536.); DoInterpolations(smoothratio / 65536.);
setgamepalette(BASEPAL); setgamepalette(BASEPAL);
if (!vid_renderer) gi->UpdateCameras(smoothratio); // Only Polymost does this here. The new renderer calls this internally.
if (ud.cameraactor) if (ud.cameraactor)
{ {
@ -307,7 +272,7 @@ void displayrooms(int snum, double smoothratio, bool sceneonly)
// Fixme: This should get the aspect ratio from the backend, not the current viewport size. // Fixme: This should get the aspect ratio from the backend, not the current viewport size.
int i = DivScale(1, isRR() ? 64 : p->GetActor()->spr.yrepeat + 28, 22); int i = DivScale(1, isRR() ? 64 : p->GetActor()->spr.yrepeat + 28, 22);
int viewingaspect = !isRRRA() || !p->DrugMode ? xs_CRoundToInt(double(i) * tan(r_fov * (pi::pi() / 360.))) : getdrugmode(p, i); int viewingaspect = !isRRRA() || !p->DrugMode ? xs_CRoundToInt(double(i) * tan(r_fov * (pi::pi() / 360.))) : getdrugmode(p, i);
renderSetAspect(MulScale(viewingaspect, viewingrange, 16), yxaspect); // todo: transform this mess into something sane to feed to the renderer.
// The camera texture must be rendered with the base palette, so this is the only place where the current global palette can be set. // The camera texture must be rendered with the base palette, so this is the only place where the current global palette can be set.
// The setting here will be carried over to the rendering of the weapon sprites, but other 2D content will always default to the main palette. // The setting here will be carried over to the rendering of the weapon sprites, but other 2D content will always default to the main palette.
@ -415,15 +380,7 @@ void displayrooms(int snum, double smoothratio, bool sceneonly)
auto cstat = viewer->spr.cstat; auto cstat = viewer->spr.cstat;
if (camview) viewer->spr.cstat = CSTAT_SPRITE_INVISIBLE; if (camview) viewer->spr.cstat = CSTAT_SPRITE_INVISIBLE;
if (isRR() && sect->lotag == 848 && !vid_renderer) renderView(viewer, sect, cposx, cposy, cposz, cang, choriz, rotscrnang, smoothratio, sceneonly);
{
renderSetRollAngle((float)rotscrnang.asbuildf());
geometryEffect(cposx, cposy, cposz, cang, choriz, sectnum(sect), (int)smoothratio);
}
else
{
renderView(viewer, sect, cposx, cposy, cposz, cang, choriz, rotscrnang, smoothratio, sceneonly);
}
viewer->spr.cstat = cstat; viewer->spr.cstat = cstat;
} }
//GLInterface.SetMapFog(false); //GLInterface.SetMapFog(false);

View file

@ -1303,17 +1303,9 @@ void moveclouds(double smoothratio)
cloudy += (float)ps[screenpeek].angle.ang.fsin() * 0.5f; cloudy += (float)ps[screenpeek].angle.ang.fsin() * 0.5f;
for (int i = 0; i < numclouds; i++) for (int i = 0; i < numclouds; i++)
{ {
if (!vid_renderer) // no clamping here!
{ clouds[i]->ceilingxpan_ = cloudx;
clouds[i]->setceilingxpan(cloudx); clouds[i]->ceilingypan_ = cloudy;
clouds[i]->setceilingypan(cloudy);
}
else
{
// no clamping here!
clouds[i]->ceilingxpan_ = cloudx;
clouds[i]->ceilingypan_ = cloudy;
}
clouds[i]->exflags |= SECTOREX_CLOUDSCROLL; clouds[i]->exflags |= SECTOREX_CLOUDSCROLL;
} }
} }

View file

@ -32,8 +32,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "render.h" #include "render.h"
#include <string.h> #include <string.h>
EXTERN_CVAR(Bool, vid_renderer)
BEGIN_PS_NS BEGIN_PS_NS
bool bSubTitles = true; bool bSubTitles = true;
@ -207,7 +205,6 @@ void DrawView(double smoothRatio, bool sceneonly)
zbob = bsin(2 * bobangle, -3); zbob = bsin(2 * bobangle, -3);
DoInterpolations(smoothRatio / 65536.); DoInterpolations(smoothRatio / 65536.);
pm_smoothratio = (int)smoothRatio;
auto pPlayerActor = PlayerList[nLocalPlayer].pActor; auto pPlayerActor = PlayerList[nLocalPlayer].pActor;
auto nPlayerOldCstat = pPlayerActor->spr.cstat; auto nPlayerOldCstat = pPlayerActor->spr.cstat;
@ -354,25 +351,9 @@ void DrawView(double smoothRatio, bool sceneonly)
} }
} }
if (!vid_renderer) if (!nFreeze && !sceneonly)
{ DrawWeapons(smoothRatio);
// this little block of code is Exhumed's entire interface to Polymost. render_drawrooms(nullptr, { nCamerax, nCameray, viewz }, sectnum(pSector), nCameraa, nCamerapan, rotscrnang, smoothRatio);
int const vr = xs_CRoundToInt(65536. * tan(r_fov * (pi::pi() / 360.)));
videoSetCorrectedAspect();
renderSetAspect(MulScale(vr, viewingrange, 16), yxaspect);
renderSetRollAngle((float)rotscrnang.asbuildf());
renderDrawRoomsQ16(nCamerax, nCameray, viewz, nCameraa.asq16(), nCamerapan.asq16(), sectnum(pSector), false);
analyzesprites(pm_tsprite, pm_spritesortcnt, nCamerax, nCameray, viewz, smoothRatio);
renderDrawMasks();
if (!nFreeze && !sceneonly)
DrawWeapons(smoothRatio);
}
else
{
if (!nFreeze && !sceneonly)
DrawWeapons(smoothRatio);
render_drawrooms(nullptr, { nCamerax, nCameray, viewz }, sectnum(pSector), nCameraa, nCamerapan, rotscrnang, smoothRatio);
}
if (HavePLURemap()) if (HavePLURemap())
{ {

View file

@ -59,5 +59,3 @@
#include "src/zilla.cpp" #include "src/zilla.cpp"
#include "src/zombie.cpp" #include "src/zombie.cpp"
#include "src/d_menu.cpp" #include "src/d_menu.cpp"
#include "src/_polymost.cpp"

View file

@ -1,379 +0,0 @@
BEGIN_SW_NS
bool FindCeilingView(int match, int* x, int* y, int z, sectortype** sect);
bool FindFloorView(int match, int* x, int* y, int z, sectortype** sect);
int ViewSectorInScene(sectortype* cursect, int level)
{
SWStatIterator it(STAT_FAF);
while (auto actor = it.Next())
{
if (actor->spr.hitag == level)
{
if (cursect == actor->sector())
{
// ignore case if sprite is pointing up
if (actor->spr.ang == 1536)
continue;
// only gets to here is sprite is pointing down
// found a potential match
int match = actor->spr.lotag;
if (!testgotpic(FAF_MIRROR_PIC, true))
return -1;
return match;
}
}
}
return -1;
}
void DrawOverlapRoom(int tx, int ty, int tz, fixed_t tq16ang, fixed_t tq16horiz, sectortype* tsect)
{
save.zcount = 0;
int match = ViewSectorInScene(tsect, VIEW_LEVEL1);
if (match != -1)
{
FindCeilingView(match, &tx, &ty, tz, &tsect);
if (tsect == nullptr)
return;
renderDrawRoomsQ16(tx, ty, tz, tq16ang, tq16horiz, sectnum(tsect), false);
// reset Z's
for (int i = 0; i < save.zcount; i++)
{
save.sect[i]->setfloorz(save.zval[i], true);
save.sect[i]->floorpicnum = save.pic[i];
save.sect[i]->setfloorslope(save.slope[i]);
}
analyzesprites(pm_tsprite, pm_spritesortcnt, tx, ty, tz, false);
post_analyzesprites(pm_tsprite, pm_spritesortcnt);
renderDrawMasks();
}
else
{
match = ViewSectorInScene(tsect, VIEW_LEVEL2);
if (match != -1)
{
FindFloorView(match, &tx, &ty, tz, &tsect);
if (tsect == nullptr)
return;
renderDrawRoomsQ16(tx, ty, tz, tq16ang, tq16horiz, sectnum(tsect), false);
// reset Z's
for (int i = 0; i < save.zcount; i++)
{
save.sect[i]->setceilingz(save.zval[i], true);
save.sect[i]->ceilingpicnum = save.pic[i];
save.sect[i]->setceilingslope(save.slope[i]);
}
analyzesprites(pm_tsprite, pm_spritesortcnt, tx, ty, tz, false);
post_analyzesprites(pm_tsprite, pm_spritesortcnt);
renderDrawMasks();
}
}
}
void FAF_DrawRooms(int x, int y, int z, fixed_t q16ang, fixed_t q16horiz, int sectnum)
{
SWStatIterator it(STAT_CEILING_FLOOR_PIC_OVERRIDE);
while (auto actor = it.Next())
{
if (SP_TAG3(actor) == 0)
{
// back up ceilingpicnum and ceilingstat
SP_TAG5(actor) = actor->sector()->ceilingpicnum;
actor->sector()->ceilingpicnum = SP_TAG2(actor);
SP_TAG4(actor) = actor->sector()->ceilingstat;
actor->sector()->ceilingstat |= (ESectorFlags::FromInt(SP_TAG6(actor)));
actor->sector()->ceilingstat &= ~(CSTAT_SECTOR_SKY);
}
else if (SP_TAG3(actor) == 1)
{
SP_TAG5(actor) = actor->sector()->floorpicnum;
actor->sector()->floorpicnum = SP_TAG2(actor);
SP_TAG4(actor) = actor->sector()->floorstat;
actor->sector()->floorstat |= (ESectorFlags::FromInt(SP_TAG6(actor)));
actor->sector()->floorstat &= ~(CSTAT_SECTOR_SKY);
}
}
renderDrawRoomsQ16(x,y,z,q16ang,q16horiz,sectnum, false);
it.Reset(STAT_CEILING_FLOOR_PIC_OVERRIDE);
while (auto actor = it.Next())
{
// manually set gotpic
if (gotsector[actor->sectno()])
{
gotpic.Set(FAF_MIRROR_PIC);
}
if (SP_TAG3(actor) == 0)
{
// restore ceilingpicnum and ceilingstat
actor->sector()->ceilingpicnum = SP_TAG5(actor);
actor->sector()->ceilingstat = ESectorFlags::FromInt(SP_TAG4(actor));
actor->sector()->ceilingstat &= ~(CSTAT_SECTOR_SKY);
}
else if (SP_TAG3(actor) == 1)
{
actor->sector()->floorpicnum = SP_TAG5(actor);
actor->sector()->floorstat = ESectorFlags::FromInt(SP_TAG4(actor));
actor->sector()->floorstat &= ~(CSTAT_SECTOR_SKY);
}
}
}
void polymost_drawscreen(PLAYER* pp, int tx, int ty, int tz, binangle tang, fixedhoriz thoriz, sectortype* tsect)
{
videoSetCorrectedAspect();
renderSetAspect(xs_CRoundToInt(double(viewingrange) * tan(r_fov * (pi::pi() / 360.))), yxaspect);
OverlapDraw = true;
DrawOverlapRoom(tx, ty, tz, tang.asq16(), thoriz.asq16(), tsect);
OverlapDraw = false;
if (automapMode != am_full)
{
// TEST this! Changed to camerapp
//JS_DrawMirrors(camerapp, tx, ty, tz, tang.asq16(), thoriz.asq16());
JS_DrawMirrors(pp, tx, ty, tz, tang.asq16(), thoriz.asq16());
}
// TODO: This call is redundant if the tiled overhead map is shown, but the
// HUD elements should be properly outputted with hardware rendering first.
if (!FAF_DebugView)
FAF_DrawRooms(tx, ty, tz, tang.asq16(), thoriz.asq16(), sectnum(tsect));
analyzesprites(pm_tsprite, pm_spritesortcnt, tx, ty, tz, tang.asbuild());
post_analyzesprites(pm_tsprite, pm_spritesortcnt);
renderDrawMasks();
}
void JS_DrawMirrors(PLAYER* pp, int tx, int ty, int tz, fixed_t tpq16ang, fixed_t tpq16horiz)
{
int j, cnt;
int dist;
int tposx, tposy; // Camera
int *longptr;
fixed_t tang;
// int tx, ty, tz, tpang; // Interpolate so mirror doesn't
// drift!
bool bIsWallMirror = false;
{
for (cnt = mirrorcnt - 1; cnt >= 0; cnt--)
//if (testgotpic(cnt + MIRRORLABEL) || testgotpic(cnt + CAMSPRITE))
if (testgotpic(cnt + MIRRORLABEL) || ((unsigned)mirror[cnt].campic < MAXTILES && testgotpic(mirror[cnt].campic)))
{
bIsWallMirror = false;
if (testgotpic(cnt + MIRRORLABEL, true))
{
bIsWallMirror = true;
}
else if ((unsigned)mirror[cnt].campic < MAXTILES && testgotpic(mirror[cnt].campic))
{
gotpic.Clear(mirror[cnt].campic);
}
mirrorinview = true;
// tx = interpolatedvalue(pp->oposx, pp->posx, smoothratio);
// ty = interpolatedvalue(pp->oposy, pp->posy, smoothratio);
// tz = interpolatedvalue(pp->oposz, pp->posz, smoothratio);
// tpq16ang = pp->angle.ang.asq16();
dist = 0x7fffffff;
if (bIsWallMirror)
{
j = abs(mirror[cnt].mirrorWall->wall_int_pos().X - tx);
j += abs(mirror[cnt].mirrorWall->wall_int_pos().Y - ty);
if (j < dist)
dist = j;
}
else if (mirror[cnt].camspriteActor)
{
auto pos = mirror[cnt].camspriteActor->spr.pos;
j = abs(pos.X - tx);
j += abs(pos.Y - ty);
if (j < dist)
dist = j;
}
if (mirror[cnt].ismagic)
{
int camhoriz;
int w;
int dx, dy, dz, tdx, tdy, tdz, midx, midy;
auto actor = mirror[cnt].cameraActor;
ASSERT(actor != nullptr);
// Calculate the angle of the mirror wall
auto wal = mirror[cnt].mirrorWall;
// Get wall midpoint for offset in mirror view
midx = (wal->wall_int_pos().X + wal->point2Wall()->wall_int_pos().X) / 2;
midy = (wal->wall_int_pos().Y + wal->point2Wall()->wall_int_pos().Y) / 2;
// Finish finding offsets
tdx = abs(midx - tx);
tdy = abs(midy - ty);
if (midx >= tx)
dx = actor->spr.pos.X - tdx;
else
dx = actor->spr.pos.X + tdx;
if (midy >= ty)
dy = actor->spr.pos.Y - tdy;
else
dy = actor->spr.pos.Y + tdy;
tdz = abs(tz - actor->spr.pos.Z);
if (tz >= actor->spr.pos.Z)
dz = actor->spr.pos.Z + tdz;
else
dz = actor->spr.pos.Z - tdz;
// Is it a TV cam or a teleporter that shows destination?
// true = It's a TV cam
mirror[cnt].mstate = m_normal;
if (TEST_BOOL1(actor))
mirror[cnt].mstate = m_viewon;
// Show teleport destination
// NOTE: Adding true lets you draw a room, even if
// you are outside of it!
if (mirror[cnt].mstate != m_viewon)
{
tileDelete(MIRROR);
// Set TV camera sprite size to 0 to show mirror
// behind in this case!
if (mirror[cnt].campic != -1)
tileDelete(mirror[cnt].campic);
renderDrawRoomsQ16(dx, dy, dz, tpq16ang, tpq16horiz, actor->sector(), true);
analyzesprites(pm_tsprite, pm_spritesortcnt, dx, dy, dz, false);
renderDrawMasks();
}
}
else if (mirror[cnt].mirrorWall)
{
// It's just a mirror
// Prepare drawrooms for drawing mirror and calculate
// reflected
// position into tposx, tposy, and tang (tposz == cposz)
// Must call preparemirror before drawrooms and
// completemirror after drawrooms
display_mirror = true;
renderPrepareMirror(tx, ty, tz, tpq16ang, tpq16horiz,
wallnum(mirror[cnt].mirrorWall), /*mirror[cnt].mirrorsector,*/ &tposx, &tposy, &tang);
renderDrawRoomsQ16(tposx, tposy, tz, (tang), tpq16horiz, sectnum(mirror[cnt].mirrorSector), true);
analyzesprites(pm_tsprite, pm_spritesortcnt, tposx, tposy, tz, tang >> 16);
renderDrawMasks();
renderCompleteMirror(); // Reverse screen x-wise in this
display_mirror = false;
}
// Clean up anything that the camera view might have done
tileDelete(MIRROR);
mirror[cnt].mirrorWall->overpicnum = MIRRORLABEL + cnt;
}
else
mirrorinview = false;
}
}
void SW_FloorPortalHack(DSWActor* actor, int z, int match)
{
// move ceiling multiple of 128 so that the wall tile will line up
int pix_diff = labs(z - actor->sector()->ceilingz) >> 8;
int newz = actor->sector()->ceilingz - ((pix_diff / 128) + 1) * Z(128);
SWStatIterator it(STAT_FAF);
while ((actor = it.Next()))
{
if (actor->spr.lotag == match)
{
// move upper levels floors down for the correct view
if (actor->spr.hitag == VIEW_LEVEL1)
{
// save it off
save.sect[save.zcount] = actor->sector();
save.zval[save.zcount] = actor->sector()->ceilingz;
save.pic[save.zcount] = actor->sector()->ceilingpicnum;
save.slope[save.zcount] = actor->sector()->ceilingheinum;
actor->sector()->setceilingz(newz, true);
// don't change FAF_MIRROR_PIC - ConnectArea
if (actor->sector()->ceilingpicnum != FAF_MIRROR_PIC)
actor->sector()->ceilingpicnum = FAF_MIRROR_PIC + 1;
actor->sector()->setceilingslope(0);
save.zcount++;
PRODUCTION_ASSERT(save.zcount < ZMAX);
}
}
}
}
void SW_CeilingPortalHack(DSWActor* actor, int z, int match)
{
int pix_diff = labs(z - actor->sector()->floorz) >> 8;
int newz = actor->sector()->floorz + ((pix_diff / 128) + 1) * Z(128);
SWStatIterator it(STAT_FAF);
while ((actor = it.Next()))
{
if (actor->spr.lotag == match)
{
// move lower levels ceilings up for the correct view
if (actor->spr.hitag == VIEW_LEVEL2)
{
// save it off
save.sect[save.zcount] = actor->sector();
save.zval[save.zcount] = actor->sector()->floorz;
save.pic[save.zcount] = actor->sector()->floorpicnum;
save.slope[save.zcount] = actor->sector()->floorheinum;
actor->sector()->setfloorz(newz, true);
// don't change FAF_MIRROR_PIC - ConnectArea
if (actor->sector()->floorpicnum != FAF_MIRROR_PIC)
actor->sector()->floorpicnum = FAF_MIRROR_PIC + 1;
actor->sector()->setfloorslope(0);
save.zcount++;
PRODUCTION_ASSERT(save.zcount < ZMAX);
}
}
}
}
END_SW_NS

View file

@ -56,7 +56,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
#include "v_draw.h" #include "v_draw.h"
#include "render.h" #include "render.h"
#include "razefont.h" #include "razefont.h"
EXTERN_CVAR(Bool, vid_renderer)
extern DCoreActor* wall_to_sprite_actors[8]; extern DCoreActor* wall_to_sprite_actors[8];
@ -1382,7 +1381,6 @@ void drawscreen(PLAYER* pp, double smoothratio, bool sceneonly)
PreUpdatePanel(smoothratio); PreUpdatePanel(smoothratio);
int sr = (int)smoothratio; int sr = (int)smoothratio;
pm_smoothratio = sr;
if (!sceneonly) if (!sceneonly)
{ {
@ -1493,23 +1491,13 @@ void drawscreen(PLAYER* pp, double smoothratio, bool sceneonly)
if (automapMode != am_full) if (automapMode != am_full)
{ {
// Cameras must be done before the main loop. // Cameras must be done before the main loop.
if (!vid_renderer) JS_DrawCameras(pp, tx, ty, tz, smoothratio); JS_CameraParms(pp, tx, ty, tz);
else JS_CameraParms(pp, tx, ty, tz);
} }
if (!vid_renderer) if (!sceneonly) UpdatePanel(smoothratio);
{ UpdateWallPortalState();
renderSetRollAngle((float)trotscrnang.asbuildf()); render_drawrooms(pp->actor, { tx, ty, tz }, sectnum(tsect), tang, thoriz, trotscrnang, smoothratio);
polymost_drawscreen(pp, tx, ty, tz, tang, thoriz, tsect); RestorePortalState();
if (!sceneonly) UpdatePanel(smoothratio);
}
else
{
if (!sceneonly) UpdatePanel(smoothratio);
UpdateWallPortalState();
render_drawrooms(pp->actor, { tx, ty, tz }, sectnum(tsect), tang, thoriz, trotscrnang, smoothratio);
RestorePortalState();
}
if (sceneonly) if (sceneonly)
{ {

View file

@ -46,8 +46,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
#include "v_video.h" #include "v_video.h"
#include "render.h" #include "render.h"
EXTERN_CVAR(Bool, vid_renderer)
BEGIN_SW_NS BEGIN_SW_NS
@ -412,16 +410,7 @@ void drawroomstotile(int daposx, int daposy, int daposz,
screen->RenderTextureView(canvas, [=](IntRect& rect) screen->RenderTextureView(canvas, [=](IntRect& rect)
{ {
if (!vid_renderer) render_camtex(nullptr, { daposx, daposy, daposz }, dacursect, ang, horiz, buildang(0), tileGetTexture(tilenume), rect, smoothratio);
{
renderDrawRoomsQ16(daposx, daposy, daposz, ang.asq16(), horiz.asq16(), dacursect, false);
analyzesprites(pm_tsprite, pm_spritesortcnt, daposx, daposy, daposz, ang.asbuild());
renderDrawMasks();
}
else
{
render_camtex(nullptr, { daposx, daposy, daposz }, dacursect, ang, horiz, buildang(0), tileGetTexture(tilenume), rect, smoothratio);
}
}); });
renderRestoreTarget(); renderRestoreTarget();

View file

@ -709,10 +709,6 @@ bool FindCeilingView(int match, int* x, int* y, int z, sectortype** sect)
} }
if (!vid_renderer)
{
SW_CeilingPortalHack(actor, z, match);
}
return true; return true;
} }
@ -770,10 +766,6 @@ bool FindFloorView(int match, int* x, int* y, int z, sectortype** sect)
return false; return false;
} }
if (!vid_renderer)
{
SW_FloorPortalHack(actor, z, match);
}
return true; return true;
} }
@ -815,8 +807,6 @@ struct PortalGroup
// This is very messy because some portals are linked outside the actual portal sectors, so we have to use the complicated original linking logic to find the connection. :? // This is very messy because some portals are linked outside the actual portal sectors, so we have to use the complicated original linking logic to find the connection. :?
void CollectPortals() void CollectPortals()
{ {
int t = vid_renderer;
vid_renderer = true;
TArray<PortalGroup> floorportals; TArray<PortalGroup> floorportals;
TArray<PortalGroup> ceilingportals; TArray<PortalGroup> ceilingportals;
BitArray floordone(sector.Size()), ceilingdone(sector.Size()); BitArray floordone(sector.Size()), ceilingdone(sector.Size());
@ -981,7 +971,6 @@ void CollectPortals()
} }
} }
} }
vid_renderer = t;
} }

View file

@ -1,88 +0,0 @@
/*
** gl_texture.cpp
** high level GL texture interface
**
**---------------------------------------------------------------------------
** Copyright 2019 Christoph Oelckers
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
**
*/
#include "palette.h"
#include "build.h"
#include "polymost.h"
#include "textures.h"
#include "bitmap.h"
#include "v_font.h"
#include "palettecontainer.h"
#include "../../glbackend/glbackend.h"
#include "texturemanager.h"
#include "v_video.h"
#include "printf.h"
//===========================================================================
//
// Retrieve the texture to be used.
//
//===========================================================================
// Test CVARs.
#ifdef _DEBUG
CVAR(Int, fixpalette, -1, 0)
CVAR(Int, fixpalswap, -1, 0)
#endif
bool GLInstance::SetTexture(FGameTexture* tex, int paletteid, int sampler, bool notindexed)
{
if (!tex->isValid())
{
return false;
}
#ifdef _DEBUG
int basepal = GetTranslationType(paletteid) - Translation_Remap;
int translation = GetTranslationIndex(paletteid);
int usepalette = fixpalette >= 0 ? fixpalette : basepal;
int usepalswap = fixpalswap >= 0 ? fixpalswap : translation;
paletteid = TRANSLATION(Translation_Remap + usepalette, usepalswap);
#endif
SetPalswap(GetTranslationIndex(paletteid));
auto &mat = renderState.mMaterial;
assert(tex->isValid());
mat.mTexture = tex;
mat.uFlags = UF_Texture;
mat.mScaleFlags = 0;
mat.mClampMode = sampler;
mat.mTranslation = paletteid;
mat.mOverrideShader = -1;
mat.mChanged = true;
GLInterface.SetAlphaThreshold(tex->alphaThreshold);
return true;
}

View file

@ -1,435 +0,0 @@
/*
** glbackend.cpp
**
** OpenGL API abstraction
**
**---------------------------------------------------------------------------
** Copyright 2019 Christoph Oelckers
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
#include <memory>
#include <assert.h>
#include "glbackend.h"
#include "textures.h"
#include "palette.h"
#include "gamecontrol.h"
#include "v_2ddrawer.h"
#include "v_video.h"
#include "flatvertices.h"
#include "build.h"
#include "v_draw.h"
#include "v_font.h"
#include "hw_viewpointuniforms.h"
#include "hw_viewpointbuffer.h"
#include "hw_renderstate.h"
#include "hw_cvars.h"
#include "gamestruct.h"
#include "hw_models.h"
#include "gamefuncs.h"
#include "gamehud.h"
CVARD(Bool, hw_hightile, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable hightile texture rendering")
bool hw_int_useindexedcolortextures;
CUSTOM_CVARD(Bool, hw_useindexedcolortextures, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable indexed color texture rendering")
{
if (screen) screen->SetTextureFilterMode();
}
EXTERN_CVAR(Bool, gl_texture)
static int BufferLock = 0;
TArray<VSMatrix> matrixArray;
GLInstance GLInterface;
GLInstance::GLInstance()
{
VSMatrix mat(0);
matrixArray.Push(mat);
}
void GLInstance::Init(int ydim)
{
new(&renderState) PolymostRenderState; // reset to defaults.
}
void GLInstance::Draw(EDrawType type, size_t start, size_t count)
{
assert (BufferLock > 0);
applyMapFog();
renderState.vindex = (int)start;
renderState.vcount = (int)count;
renderState.primtype = type;
rendercommands.Push(renderState);
clearMapFog();
renderState.StateFlags &= ~(STF_CLEARCOLOR | STF_CLEARDEPTH | STF_VIEWPORTSET | STF_SCISSORSET);
}
void GLInstance::DoDraw()
{
GLState lastState;
if (rendercommands.Size() > 0)
{
if (!useMapFog) hw_int_useindexedcolortextures = hw_useindexedcolortextures;
lastState.Flags = ~rendercommands[0].StateFlags; // Force ALL flags to be considered 'changed'.
lastState.DepthFunc = INT_MIN; // Something totally invalid.
screen->RenderState()->EnableMultisampling(true);
auto& state = *screen->RenderState();
for (auto& rs : rendercommands)
{
if (rs.Apply(state, lastState))
{
if (!rs.model)
{
state.Draw(rs.primtype, rs.vindex, rs.vcount);
}
else
{
FHWModelRenderer mr(*screen->RenderState(), -1);
state.SetDepthFunc(DF_LEqual);
state.EnableTexture(true);
rs.model->BuildVertexBuffer(&mr);
mr.SetupFrame(rs.model, rs.mframes[0], rs.mframes[1], 0);
rs.model->RenderFrame(&mr, rs.mMaterial.mTexture, rs.mframes[0], rs.mframes[1], 0.f, rs.mMaterial.mTranslation, nullptr);
state.SetDepthFunc(DF_Less);
state.SetVertexBuffer(screen->mVertexData);
}
}
}
state.SetNpotEmulation(0, 0); // make sure we do not leave this in an undefined state.
renderState.Apply(*screen->RenderState(), lastState); // apply any pending change before returning.
rendercommands.Clear();
hw_int_useindexedcolortextures = false;
}
matrixArray.Resize(1);
}
int GLInstance::SetMatrix(int num, const VSMatrix *mat)
{
int r = renderState.matrixIndex[num];
renderState.matrixIndex[num] = matrixArray.Size();
matrixArray.Push(*mat);
return r;
}
void GLInstance::SetIdentityMatrix(int num)
{
renderState.matrixIndex[num] = -1;
}
void GLInstance::SetPalswap(int index)
{
renderState.ShadeDiv = lookups.tables[index].ShadeFactor;
}
void GLInstance::SetFade(int index)
{
renderState.FogColor = lookups.getFade(index);
}
extern int globalpal;
void GLInstance::SetShade(int32_t shade, int numshades)
{
// Ugh... This particular palette does not fade to black. Should be handled better.
// It's really too bad that everything runs through here without being able to identify it anymore.
renderState.drawblack = (!(g_gameType & GAMEFLAG_PSEXHUMED) || globalpal != 4) ? shade > numshades : false;
renderState.Shade = min(shade, numshades - 1);
}
bool PolymostRenderState::Apply(FRenderState& state, GLState& oldState)
{
// Fog must be done before the texture so that the texture selector can override it.
bool foggy = (GLInterface.useMapFog || (FogColor & 0xffffff));
// Disable brightmaps if non-black fog is used.
if (!(Flags & RF_FogDisabled) && ShadeDiv >= 1 / 1000.f && foggy)
{
state.EnableFog(1);
float density = GLInterface.useMapFog ? 350.f : 350.f - Scale(numshades - Shade, 150, numshades);
state.SetFog((GLInterface.useMapFog) ? PalEntry(0x999999) : FogColor, density);
state.SetSoftLightLevel(255);
state.SetLightParms(128.f, 1 / 1000.f);
}
else
{
state.EnableFog(0);
state.SetFog(0, 0);
state.SetSoftLightLevel(ShadeDiv >= 1 / 1000.f ? 255 - Scale(Shade, 255, numshades) : 255);
state.SetLightParms(VisFactor, ShadeDiv / (numshades - 2));
}
if (Flags & RF_ColorOnly)
{
state.EnableTexture(false);
}
else
{
if (!mMaterial.mTexture) return false; // Oh no! Something passed an invalid tile!
state.EnableTexture(gl_texture);
state.SetMaterial(mMaterial.mTexture, mMaterial.uFlags, mMaterial.mScaleFlags, mMaterial.mClampMode, mMaterial.mTranslation, mMaterial.mOverrideShader);
}
if (!drawblack) state.SetColor(Color[0], Color[1], Color[2], Color[3]);
else state.SetColor(0, 0, 0, Color[3]);
if (StateFlags != oldState.Flags)
{
state.EnableDepthTest(StateFlags & STF_DEPTHTEST);
if ((StateFlags ^ oldState.Flags) & (STF_STENCILTEST | STF_STENCILWRITE))
{
if (StateFlags & STF_STENCILWRITE)
{
state.EnableStencil(true);
state.SetEffect(EFF_STENCIL);
state.SetStencil(0, SOP_Increment, SF_ColorMaskOff);
}
else if (StateFlags & STF_STENCILTEST)
{
state.EnableStencil(true);
state.SetEffect(EFF_NONE);
state.SetStencil(1, SOP_Keep, SF_DepthMaskOff);
}
else
{
state.EnableStencil(false);
state.SetEffect(EFF_NONE);
}
}
if ((StateFlags ^ oldState.Flags) & (STF_CULLCW | STF_CULLCCW))
{
int cull = Cull_None;
if (StateFlags & STF_CULLCCW) cull = Cull_CCW;
else if (StateFlags & STF_CULLCW) cull = Cull_CW;
state.SetCulling(cull);
}
state.SetColorMask(StateFlags & STF_COLORMASK);
state.SetDepthMask(StateFlags & STF_DEPTHMASK);
if (StateFlags & (STF_CLEARCOLOR | STF_CLEARDEPTH))
{
int clear = 0;
if (StateFlags & STF_CLEARCOLOR) clear |= CT_Color;
if (StateFlags & STF_CLEARDEPTH) clear |= CT_Depth;
state.Clear(clear);
}
if (StateFlags & STF_VIEWPORTSET)
{
state.SetViewport(vp_x, vp_y, vp_w, vp_h);
}
if (StateFlags & STF_SCISSORSET)
{
state.SetScissor(sc_x, sc_y, sc_w, sc_h);
}
state.SetDepthBias(mBias.mFactor, mBias.mUnits);
StateFlags &= ~(STF_CLEARCOLOR | STF_CLEARDEPTH | STF_VIEWPORTSET | STF_SCISSORSET);
oldState.Flags = StateFlags;
}
state.SetRenderStyle(Style);
if (DepthFunc != oldState.DepthFunc)
{
state.SetDepthFunc(DepthFunc);
oldState.DepthFunc = DepthFunc;
}
state.SetTextureMode(TextureMode);
state.SetNpotEmulation(NPOTEmulation.Y, NPOTEmulation.X);
state.AlphaFunc(Alpha_Greater, AlphaTest ? AlphaThreshold : -1.f);
if (matrixIndex[Matrix_Model] != -1)
{
state.EnableModelMatrix(true);
state.mModelMatrix = matrixArray[matrixIndex[Matrix_Model]];
}
else state.EnableModelMatrix(false);
memset(matrixIndex, -1, sizeof(matrixIndex));
return true;
}
static void PM_DoWriteSavePic(FileWriter* file, ESSType ssformat, uint8_t* scr, int width, int height, bool upsidedown)
{
int pixelsize = 3;
int pitch = width * pixelsize;
if (upsidedown)
{
scr += ((height - 1) * width * pixelsize);
pitch *= -1;
}
M_CreatePNG(file, scr, nullptr, ssformat, width, height, pitch, vid_gamma);
}
//===========================================================================
//
// Render the view to a savegame picture
//
//===========================================================================
void PM_WriteSavePic(FileWriter* file, int width, int height)
{
IntRect bounds;
bounds.left = 0;
bounds.top = 0;
bounds.width = width;
bounds.height = height;
auto& RenderState = *screen->RenderState();
// we must be sure the GPU finished reading from the buffer before we fill it with new data.
screen->WaitForCommands(false);
screen->mVertexData->Reset();
// Switch to render buffers dimensioned for the savepic
screen->SetSaveBuffers(true);
screen->ImageTransitionScene(true);
RenderState.SetVertexBuffer(screen->mVertexData);
screen->mVertexData->Reset();
//screen->mLights->Clear();
screen->mViewpoints->Clear();
int oldx = xdim;
int oldy = ydim;
auto oldwindowxy1 = windowxy1;
auto oldwindowxy2 = windowxy2;
xdim = width;
ydim = height;
videoSetViewableArea(0, 0, width - 1, height - 1);
renderSetAspect(65536, 65536);
screen->SetSceneRenderTarget(false);
RenderState.SetPassType(NORMAL_PASS);
RenderState.EnableDrawBuffers(1, true);
screen->SetViewportRects(&bounds);
twodpsp.Clear();
/*bool didit =*/ gi->GenerateSavePic();
float Brightness = 8.f / (r_scenebrightness + 8.f);
screen->PostProcessScene(false, 0, Brightness, []() {
Draw2D(&twodpsp, *screen->RenderState()); // draws the weapon sprites
});
xdim = oldx;
ydim = oldy;
videoSetViewableArea(oldwindowxy1.X, oldwindowxy1.Y, oldwindowxy2.X, oldwindowxy2.Y);
// The 2D drawers can contain some garbage from the dirty render setup. Get rid of that first.
twod->Clear();
twodpsp.Clear();
int numpixels = width * height;
uint8_t* scr = (uint8_t*)M_Malloc(numpixels * 3);
screen->CopyScreenToBuffer(width, height, scr);
PM_DoWriteSavePic(file, SS_RGB, scr, width, height, screen->FlipSavePic());
M_Free(scr);
// Switch back the screen render buffers
screen->SetViewportRects(nullptr);
screen->SetSaveBuffers(false);
}
static HWViewpointUniforms vp;
void renderSetProjectionMatrix(const float* p)
{
if (p)
{
vp.mProjectionMatrix.loadMatrix(p);
GLInterface.mProjectionM5 = p[5];
}
else vp.mProjectionMatrix.loadIdentity();
}
void renderSetViewMatrix(const float* p)
{
if (p) vp.mViewMatrix.loadMatrix(p);
else vp.mViewMatrix.loadIdentity();
}
void renderSetVisibility(float vis)
{
vp.mGlobVis = vis;
}
void renderSetViewpoint(float x, float y, float z)
{
vp.mCameraPos = {x, z, y, 0};
}
void renderBeginScene()
{
assert(BufferLock == 0);
vp.mPalLightLevels = numshades | (static_cast<int>(gl_fogmode) << 8) | ((int)5 << 16);
screen->mViewpoints->SetViewpoint(*screen->RenderState(), &vp);
if (BufferLock++ == 0)
{
screen->mVertexData->Map();
}
}
void renderFinishScene()
{
assert(BufferLock == 1);
if (--BufferLock == 0)
{
screen->mVertexData->Unmap();
GLInterface.DoDraw();
}
}
int32_t r_scenebrightness = 0;
void videoShowFrame()
{
int oldssao = gl_ssao;
// These two features do not really work with Polymost because the rendered scene does not provide it
gl_ssao = 0;
float Brightness = 8.f / (r_scenebrightness + 8.f);
screen->PostProcessScene(false, 0, Brightness, []() {
Draw2D(&twodpsp, *screen->RenderState()); // draws the weapon sprites
});
screen->mVertexData->Reset();
screen->mViewpoints->Clear();
gl_ssao = oldssao;
}

View file

@ -1,313 +0,0 @@
#pragma once
#include <limits.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
#include <map>
#include "c_cvars.h"
#include "gl_samplers.h"
#include "gl_hwtexture.h"
#include "matrix.h"
#include "palentry.h"
#include "renderstyle.h"
#include "hw_material.h"
#include "hw_renderstate.h"
#include "pm_renderstate.h"
class FShader;
class FGameTexture;
class GLInstance;
class F2DDrawer;
struct palette_t;
extern int xdim, ydim;
struct glinfo_t {
float maxanisotropy;
};
enum ECullSide
{
Cull_Front,
Cull_Back
};
enum EWinding
{
Winding_CCW,
Winding_CW
};
struct ImDrawData;
struct palette_t;
enum
{
MAX_TEXTURES = 4, /*15*/ // slot 15 is used internally and not available. - The renderer uses only 5, though.
};
struct GLState
{
int Flags;
int DepthFunc;
};
class GLInstance
{
friend IHardwareTexture* setpalettelayer(int layer, int translation);
public:
TArray<PolymostRenderState> rendercommands;
FGameTexture* currentTexture = nullptr;
int MatrixChange = 0;
PolymostRenderState renderState;
public:
float mProjectionM5 = 1.0f; // needed by ssao
glinfo_t glinfo;
void Init(int y);
static int GetTexDimension(int value)
{
//if (value > gl.max_texturesize) return gl.max_texturesize;
return value;
}
GLInstance();
void Draw(EDrawType type, size_t start, size_t count);
void DoDraw();
float GetProjectionM5() { return mProjectionM5; }
int SetMatrix(int num, const VSMatrix *mat );
int SetMatrix(int num, const float *mat)
{
return SetMatrix(num, reinterpret_cast<const VSMatrix*>(mat));
}
void SetIdentityMatrix(int num);
void RestoreMatrix(int num, int index)
{
renderState.matrixIndex[num] = index;
}
void SetTextureMode(int m)
{
renderState.TextureMode = m;
}
void SetDepthBias(float a, float b)
{
renderState.mBias.mFactor = a;
renderState.mBias.mUnits = b;
renderState.mBias.mChanged = true;
}
void ClearDepthBias()
{
renderState.mBias.mFactor = 0;
renderState.mBias.mUnits = 0;
renderState.mBias.mChanged = true;
}
void SetPalswap(int index);
void SetFade(int palette);
void SetShade(int32_t shade, int numshades);
void SetVisibility(float visibility)
{
renderState.VisFactor = visibility;
}
void EnableBlend(bool on)
{
if (on) renderState.StateFlags |= STF_BLEND;
else renderState.StateFlags &= ~STF_BLEND;
}
void EnableDepthTest(bool on)
{
if (on) renderState.StateFlags |= STF_DEPTHTEST;
else renderState.StateFlags &= ~STF_DEPTHTEST;
}
void EnableStencilWrite(int value)
{
renderState.StateFlags |= STF_STENCILWRITE;
renderState.StateFlags &= ~STF_STENCILTEST;
}
void EnableStencilTest(int value)
{
renderState.StateFlags &= ~STF_STENCILWRITE;
renderState.StateFlags |= STF_STENCILTEST;
}
void DisableStencil()
{
renderState.StateFlags &= ~(STF_STENCILWRITE | STF_STENCILTEST);
}
void SetCull(int type, int winding = Winding_CW)
{
renderState.StateFlags &= ~(STF_CULLCCW | STF_CULLCW);
if (type != Cull_None)
{
if (winding == Winding_CW) renderState.StateFlags |= STF_CULLCW;
else renderState.StateFlags |= STF_CULLCCW;
}
}
void SetColorMask(bool on)
{
if (on) renderState.StateFlags |= STF_COLORMASK;
else renderState.StateFlags &= ~STF_COLORMASK;
}
void SetDepthMask(bool on)
{
if (on) renderState.StateFlags |= STF_DEPTHMASK;
else renderState.StateFlags &= ~STF_DEPTHMASK;
}
void ClearScreen(PalEntry pe, bool depth)
{
renderState.ClearColor = pe;
renderState.StateFlags |= STF_CLEARCOLOR;
if (depth) renderState.StateFlags |= STF_CLEARDEPTH;
}
void SetViewport(int x, int y, int w, int h)
{
renderState.vp_x = (short)x;
renderState.vp_y = (short)y;
renderState.vp_w = (short)w;
renderState.vp_h = (short)h;
renderState.StateFlags |= STF_VIEWPORTSET;
}
void SetScissor(int x1, int y1, int x2, int y2)
{
renderState.sc_x = (short)x1;
renderState.sc_y = (short)y1;
renderState.sc_w = (short)x2;
renderState.sc_h = (short)y2;
renderState.StateFlags |= STF_SCISSORSET;
}
void DisableScissor()
{
renderState.sc_x = SHRT_MIN;
renderState.StateFlags |= STF_SCISSORSET;
}
void SetDepthFunc(int func)
{
renderState.DepthFunc = func;
}
void ClearScreen(PalEntry pe)
{
//twod->Clear();
SetViewport(0, 0, xdim, ydim);
ClearScreen(pe, true);
}
void ClearDepth()
{
renderState.StateFlags |= STF_CLEARDEPTH;
}
void SetRenderStyle(FRenderStyle style)
{
renderState.Style = style;
}
void SetColor(float r, float g, float b, float a = 1.f)
{
renderState.Color[0] = r;
renderState.Color[1] = g;
renderState.Color[2] = b;
renderState.Color[3] = a;
}
void SetColorub(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255)
{
SetColor(r * (1 / 255.f), g * (1 / 255.f), b * (1 / 255.f), a * (1 / 255.f));
}
void SetMaterial(FGameTexture* tex, EUpscaleFlags upscalemask, int scaleflags, int clampmode, int translation, int overrideshader)
{
assert(tex);
renderState.mMaterial.mTexture = tex;
renderState.mMaterial.uFlags = upscalemask;
renderState.mMaterial.mScaleFlags = scaleflags;
renderState.mMaterial.mClampMode = clampmode;
renderState.mMaterial.mTranslation = translation;
renderState.mMaterial.mOverrideShader = overrideshader;
renderState.mMaterial.mChanged = true;
}
void UseColorOnly(bool yes)
{
if (yes) renderState.Flags |= RF_ColorOnly;
else renderState.Flags &= ~RF_ColorOnly;
}
void SetNpotEmulation(float factor, float xOffset)
{
renderState.NPOTEmulation.Y = factor;
renderState.NPOTEmulation.X = xOffset;
}
// Hack...
bool useMapFog = false;
void SetMapFog(bool yes)
{
useMapFog = yes;
}
void applyMapFog()
{
if (useMapFog) renderState.Flags |= RF_MapFog;
else renderState.Flags &= ~RF_MapFog;
}
void clearMapFog()
{
renderState.Flags &= ~RF_MapFog;
}
void EnableAlphaTest(bool on)
{
renderState.AlphaTest = on;
}
void SetAlphaThreshold(float al)
{
renderState.AlphaThreshold = al;
}
bool SetTexture(FGameTexture* tex, int palette, int sampleroverride, bool notindexed = false);
void SetModel(FModel* model, int frame1, int frame2, float factor)
{
renderState.model = model;
renderState.mframes[0] = frame1;
renderState.mframes[1] = frame2;
renderState.mfactor = factor;
}
};
extern GLInstance GLInterface;
void renderSetProjectionMatrix(const float* p);
void renderSetViewMatrix(const float* p);
void renderSetVisibility(float v);
void renderSetViewpoint(float x, float y, float z);
void renderBeginScene();
void renderFinishScene();
void videoShowFrame();

View file

@ -1,99 +0,0 @@
#pragma once
#include <limits.h>
#include "palentry.h"
#include "gl_buffers.h"
#include "renderstyle.h"
struct GLState;
class FMaterial;
class FModel;
enum EMatrixType
{
Matrix_Model,
// These are the only ones being used.
NUMMATRICES
};
enum PRSFlags
{
RF_ColorOnly = 1,
RF_FogDisabled = 128,
RF_MapFog = 256, // RRRA E2L1.
RF_TINT_Grayscale = 0x10000,
RF_TINT_Invert = 0x20000,
RF_TINT_Colorize = 0x40000,
RF_TINT_BLEND_Screen = 0x80000,
RF_TINT_BLEND_Overlay = 0x100000,
RF_TINT_BLEND_Hardlight = 0x200000,
RF_TINT_BLENDMASK = RF_TINT_BLEND_Screen | RF_TINT_BLEND_Overlay | RF_TINT_BLEND_Hardlight,
RF_TINT_MASK = 0x3f0000,
STF_BLEND = 1,
STF_COLORMASK = 2,
STF_DEPTHMASK = 4,
STF_DEPTHTEST = 8,
STF_STENCILWRITE = 32,
STF_STENCILTEST = 64,
STF_CULLCW = 128,
STF_CULLCCW = 256,
STF_CLEARCOLOR = 1024,
STF_CLEARDEPTH = 2048,
STF_VIEWPORTSET = 4096,
STF_SCISSORSET = 8192,
};
struct PolymostTextureState
{
FGameTexture* mTexture = nullptr;
EUpscaleFlags uFlags;
int mScaleFlags;
int mClampMode;
int mTranslation;
int mOverrideShader;
bool mChanged;
void Reset()
{
mTexture = nullptr;
uFlags = UF_None;
mScaleFlags = 0;
mTranslation = 0;
mClampMode = CLAMP_NONE;
mOverrideShader = -1;
mChanged = false;
}
};
struct PolymostRenderState
{
int vindex, vcount, primtype;
int Shade;
int drawblack = false;
float ShadeDiv = 62.f;
float VisFactor = 128.f;
int Flags = 0;
int TextureMode = TM_NORMAL;
FVector2 NPOTEmulation = { 0.f, 0.f };
float AlphaThreshold = 0.5f;
bool AlphaTest = true;
float Color[4] = { 1,1,1,1 };
short matrixIndex[NUMMATRICES] = { -1 };
FDepthBiasState mBias{ };
PolymostTextureState mMaterial;
FModel* model = nullptr;
int mframes[2] = { 0,0 };
float mfactor = 0;
int StateFlags = STF_COLORMASK|STF_DEPTHMASK;
FRenderStyle Style{};
int DepthFunc = 1;
PalEntry ClearColor = 0;
short vp_x, vp_y, vp_w, vp_h;
short sc_x = SHRT_MIN, sc_y, sc_w, sc_h;
PalEntry FogColor;
bool Apply(FRenderState & state, GLState& oldState);
};