mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 14:52:01 +00:00
- route everything through the full backend, now completely bypassing the intermediate GLInstance layer.
This commit is contained in:
parent
4cf2493cfd
commit
547ed4e415
12 changed files with 78 additions and 102 deletions
|
@ -981,8 +981,8 @@ int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz,
|
|||
else
|
||||
{
|
||||
vec3_t pos = { daposx, daposy, daposz };
|
||||
if (!testnewinterface) render_drawrooms_(pos, globalcursectnum, daang, dahoriz, rollang, r_fov, false, false);
|
||||
else render_drawrooms(pos, globalcursectnum, daang, dahoriz, rollang, false, false);
|
||||
//if (!testnewinterface) render_drawrooms_(pos, globalcursectnum, daang, dahoriz, rollang, r_fov, false, false);
|
||||
/*else*/ render_drawrooms(pos, globalcursectnum, daang, dahoriz, rollang, false, false);
|
||||
}
|
||||
|
||||
return inpreparemirror;
|
||||
|
|
|
@ -190,7 +190,6 @@ int32_t polymost_voxdraw(voxmodel_t* m, tspriteptr_t const tspr)
|
|||
GLInterface.SetDepthFunc(DF_Less);
|
||||
}
|
||||
GLInterface.SetIdentityMatrix(Matrix_Model);
|
||||
GLInterface.SetFadeDisable(false);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,10 @@ EXTERN_CVAR(Bool, cl_capfps)
|
|||
bool NoInterpolateView;
|
||||
|
||||
|
||||
PalEntry GlobalMapFog;
|
||||
float GlobalFogDensity;
|
||||
|
||||
|
||||
#if 0
|
||||
void CollectLights(FLevelLocals* Level)
|
||||
{
|
||||
|
@ -267,7 +271,6 @@ static void CheckTimer(FRenderState &state, uint64_t ShaderStartTime)
|
|||
|
||||
void render_drawrooms(vec3_t& position, int sectnum, fixed_t q16angle, fixed_t q16horizon, float rollang, bool mirror, bool planemirror)
|
||||
{
|
||||
int retsec = 0;
|
||||
auto RenderState = screen->RenderState();
|
||||
RenderState->SetVertexBuffer(screen->mVertexData);
|
||||
screen->mVertexData->Reset();
|
||||
|
@ -311,7 +314,7 @@ void render_drawrooms(vec3_t& position, int sectnum, fixed_t q16angle, fixed_t q
|
|||
|
||||
// now render the main view
|
||||
float fovratio;
|
||||
float ratio = ActiveRatio(windowxy2.x - windowxy1.x + 1, windowxy2.y - windowxy1.y);
|
||||
float ratio = ActiveRatio(windowxy2.x - windowxy1.x + 1, windowxy2.y - windowxy1.y + 1);
|
||||
if (ratio >= 1.33f)
|
||||
{
|
||||
fovratio = 1.33f;
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void BunchDrawer::Init(FDrawInfo *_di, Clipper* c, vec2_t& view)
|
||||
void BunchDrawer::Init(HWDrawInfo *_di, Clipper* c, vec2_t& view)
|
||||
{
|
||||
di = _di;
|
||||
clipper = c;
|
||||
|
@ -230,7 +230,7 @@ void BunchDrawer::ProcessBunch(int bnch)
|
|||
|
||||
HWWall hwwall;
|
||||
//Printf("Rendering wall %d\n", i);
|
||||
hwwall.Process(nullptr, &wall[i], §or[bunch->sectnum], wall[i].nextsector<0? nullptr : §or[wall[i].nextsector]);
|
||||
hwwall.Process(di, &wall[i], §or[bunch->sectnum], wall[i].nextsector<0? nullptr : §or[wall[i].nextsector]);
|
||||
rendered_lines++;
|
||||
|
||||
SetupWall.Unclock();
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "tarray.h"
|
||||
#include "basics.h"
|
||||
|
||||
class FDrawInfo;
|
||||
struct HWDrawInfo;
|
||||
class Clipper;
|
||||
|
||||
struct FBunch
|
||||
|
@ -17,7 +17,7 @@ struct FBunch
|
|||
|
||||
class BunchDrawer
|
||||
{
|
||||
FDrawInfo *di;
|
||||
HWDrawInfo *di;
|
||||
Clipper *clipper;
|
||||
int LastBunch;
|
||||
int StartTime;
|
||||
|
@ -49,6 +49,6 @@ private:
|
|||
void ProcessSector(int sectnum);
|
||||
|
||||
public:
|
||||
void Init(FDrawInfo* _di, Clipper* c, vec2_t& view);
|
||||
void Init(HWDrawInfo* _di, Clipper* c, vec2_t& view);
|
||||
void RenderScene(int viewsector);
|
||||
};
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "hw_vrmodes.h"
|
||||
#include "hw_clipper.h"
|
||||
#include "v_draw.h"
|
||||
#include "gamecvars.h"
|
||||
|
||||
EXTERN_CVAR(Float, r_visibility)
|
||||
CVAR(Bool, gl_bandedswlight, false, CVAR_ARCHIVE)
|
||||
|
@ -136,7 +137,7 @@ void HWDrawInfo::StartScene(FRenderViewpoint &parentvp, HWViewpointUniforms *uni
|
|||
VPUniforms.mViewMatrix.loadIdentity();
|
||||
VPUniforms.mNormalViewMatrix.loadIdentity();
|
||||
//VPUniforms.mViewHeight = viewheight;
|
||||
VPUniforms.mGlobVis = 1 / 64.f;
|
||||
VPUniforms.mGlobVis = (2 / 65536.f) * g_visibility / r_ambientlight;
|
||||
VPUniforms.mPalLightLevels = numshades | (static_cast<int>(gl_fogmode) << 8) | (5 << 16);
|
||||
|
||||
VPUniforms.mClipLine.X = -10000000.0f;
|
||||
|
@ -184,15 +185,9 @@ HWDrawInfo *HWDrawInfo::EndDrawInfo()
|
|||
|
||||
void HWDrawInfo::ClearBuffers()
|
||||
{
|
||||
HandledSubsectors.Clear();
|
||||
spriteindex = 0;
|
||||
|
||||
sector_renderflags.Resize(numsectors);
|
||||
memset(§or_renderflags[0], 0, numsectors * sizeof(sector_renderflags[0]));
|
||||
|
||||
Decals[0].Clear();
|
||||
Decals[1].Clear();
|
||||
|
||||
mClipPortal = nullptr;
|
||||
mCurrentPortal = nullptr;
|
||||
}
|
||||
|
@ -296,7 +291,7 @@ HWDecal* HWDrawInfo::AddDecal(bool onmirror)
|
|||
|
||||
void HWDrawInfo::CreateScene()
|
||||
{
|
||||
const auto &vp = Viewpoint;
|
||||
const auto& vp = Viewpoint;
|
||||
|
||||
angle_t a1 = FrustumAngle();
|
||||
mClipper->SafeAddClipRangeRealAngles(vp.RotAngle + a1, vp.RotAngle - a1);
|
||||
|
@ -312,7 +307,9 @@ void HWDrawInfo::CreateScene()
|
|||
screen->mVertexData->Map();
|
||||
screen->mLights->Map();
|
||||
|
||||
//RenderBSP(Level->HeadNode(), drawpsprites);
|
||||
vec2_t view = { int(vp.Pos.X * 16), int(vp.Pos.Y * -16) };
|
||||
mDrawer.Init(this, mClipper, view);
|
||||
mDrawer.RenderScene(vp.SectNum);
|
||||
|
||||
// And now the crappy hacks that have to be done to avoid rendering anomalies.
|
||||
// These cannot be multithreaded when the time comes because all these depend
|
||||
|
|
|
@ -105,10 +105,6 @@ struct HWDrawInfo
|
|||
TArray<HWPortal *> Portals;
|
||||
TArray<HWDecal *> Decals[2]; // the second slot is for mirrors which get rendered in a separate pass.
|
||||
|
||||
TArray<sectortype *> HandledSubsectors;
|
||||
|
||||
TArray<uint8_t> sector_renderflags;
|
||||
|
||||
// This is needed by the BSP traverser.
|
||||
fixed_t viewx, viewy; // since the nodes are still fixed point, keeping the view position also fixed point for node traversal is faster.
|
||||
bool multithread;
|
||||
|
@ -128,12 +124,6 @@ private:
|
|||
//void RenderThings(sectortype * sub, sectortype * sector);
|
||||
//void RenderParticles(sectortype *sub, sectortype *front);
|
||||
void SetColor(FRenderState &state, int sectorlightlevel, int rellight, bool fullbright, const FColormap &cm, float alpha, bool weapon = false);
|
||||
void SetFog(FRenderState &state, int lightlevel, int rellight, bool fullbright, const FColormap *cmap, bool isadditive);
|
||||
void SetShaderLight(FRenderState &state, float level, float olight);
|
||||
int CalcLightLevel(int lightlevel, int rellight, bool weapon, int blendfactor);
|
||||
PalEntry CalcLightColor(int light, PalEntry pe, int blendfactor);
|
||||
float GetFogDensity(int lightlevel, PalEntry fogcolor, int sectorfogdensity, int blendfactor);
|
||||
bool CheckFog(sectortype *frontsector, sectortype *backsector);
|
||||
public:
|
||||
|
||||
void SetCameraPos(const DVector3 &pos)
|
||||
|
|
|
@ -40,7 +40,6 @@ EXTERN_CVAR(Bool, gl_seamless)
|
|||
|
||||
void HWDrawInfo::AddWall(HWWall *wall)
|
||||
{
|
||||
#if 0
|
||||
if (wall->flags & HWWall::HWF_TRANSLUCENT)
|
||||
{
|
||||
auto newwall = drawlists[GLDL_TRANSLUCENT].NewWall();
|
||||
|
@ -48,7 +47,7 @@ void HWDrawInfo::AddWall(HWWall *wall)
|
|||
}
|
||||
else
|
||||
{
|
||||
bool masked = HWWall::passflag[wall->type] == 1 ? false : (wall->texture && wall->texture->isMasked());
|
||||
bool masked = wall->type != RENDERWALL_M2S ? false : (wall->texture && wall->texture->isMasked());
|
||||
int list;
|
||||
|
||||
if (wall->flags & HWWall::HWF_SKYHACK && wall->type == RENDERWALL_M2S)
|
||||
|
@ -62,7 +61,6 @@ void HWDrawInfo::AddWall(HWWall *wall)
|
|||
auto newwall = drawlists[list].NewWall();
|
||||
*newwall = *wall;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -154,7 +154,9 @@ public:
|
|||
|
||||
float ViewDistance;
|
||||
float visibility;
|
||||
short shade, palette, floorpal;
|
||||
short shade, palette;
|
||||
|
||||
PalEntry fade;
|
||||
|
||||
uint16_t flags;
|
||||
uint8_t type;
|
||||
|
|
|
@ -26,8 +26,7 @@
|
|||
#include "hw_cvars.h"
|
||||
#include "hw_clock.h"
|
||||
//#include "hw_lighting.h"
|
||||
//#include "hwrenderer/scene/hw_drawinfo.h"
|
||||
//#include "hwrenderer/scene/hw_drawstructs.h"
|
||||
#include "hw_drawinfo.h"
|
||||
//#include "hwrenderer/scene/hw_portal.h"
|
||||
#include "hw_lightbuffer.h"
|
||||
#include "hw_renderstate.h"
|
||||
|
@ -40,6 +39,8 @@
|
|||
#include "flatvertices.h"
|
||||
#include "glbackend/glbackend.h"
|
||||
|
||||
extern PalEntry GlobalMapFog;
|
||||
extern float GlobalFogDensity;
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
@ -171,12 +172,10 @@ void HWWall::RenderMirrorSurface(HWDrawInfo *di, FRenderState &state)
|
|||
|
||||
void HWWall::RenderTexturedWall(HWDrawInfo *di, FRenderState &state, int rflags)
|
||||
{
|
||||
#if 0
|
||||
int tmode = state.GetTextureMode();
|
||||
//int tmode = state.GetTextureMode();
|
||||
|
||||
state.SetMaterial(texture, UF_Texture, 0, flags & 3, 0, -1);
|
||||
state.SetMaterial(texture, UF_Texture, 0, 0/*flags & 3*/, TRANSLATION(Translation_Remap + curbasepal, palette), -1);
|
||||
|
||||
|
||||
int32_t size = xs_CRoundToInt(texture->GetDisplayHeight());
|
||||
int32_t size2;
|
||||
for (size2 = 1; size2 < size; size2 += size2) {}
|
||||
|
@ -188,13 +187,48 @@ void HWWall::RenderTexturedWall(HWDrawInfo *di, FRenderState &state, int rflags)
|
|||
state.SetNpotEmulation((1.f * size2) / size, xOffset);
|
||||
}
|
||||
|
||||
|
||||
float absalpha = fabsf(alpha);
|
||||
if (type != RENDERWALL_M2SNF) di->SetFog(state, lightlevel, rel, di->isFullbrightScene(), &Colormap, RenderStyle == STYLE_Add);
|
||||
di->SetColor(state, lightlevel, rel, di->isFullbrightScene(), Colormap, absalpha);
|
||||
|
||||
// Fog must be done before the texture so that the texture selector can override it.
|
||||
bool foggy = (GlobalMapFog || (fade & 0xffffff));
|
||||
auto ShadeDiv = lookups.tables[palette].ShadeFactor;
|
||||
// Disable brightmaps if non-black fog is used.
|
||||
if (ShadeDiv >= 1 / 1000.f && foggy)
|
||||
{
|
||||
state.EnableFog(1);
|
||||
float density = GlobalMapFog ? GlobalFogDensity : 350.f - Scale(numshades - shade, 150, numshades);
|
||||
state.SetFog((GlobalMapFog) ? GlobalMapFog : fade, 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(visibility, ShadeDiv / (numshades - 2));
|
||||
}
|
||||
|
||||
// The shade rgb from the tint is ignored here.
|
||||
state.SetColor(PalEntry(255, globalr, globalg, globalb));
|
||||
|
||||
int h = texture->GetTexelHeight();
|
||||
int h2 = 1 << sizeToBits(h);
|
||||
if (h2 < h) h2 *= 2;
|
||||
if (h != h2)
|
||||
{
|
||||
float xOffset = 1.f / texture->GetTexelWidth();
|
||||
state.SetNpotEmulation(float(h2) / h, xOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
state.SetNpotEmulation(0.f, 0.f);
|
||||
}
|
||||
|
||||
RenderWall(di, state, rflags);
|
||||
|
||||
state.SetNpotEmulation(0.f, 0.f);
|
||||
/* none of these functions is in use.
|
||||
state.SetObjectColor(0xffffffff);
|
||||
state.SetObjectColor2(0);
|
||||
state.SetAddColor(0);
|
||||
|
@ -202,7 +236,7 @@ void HWWall::RenderTexturedWall(HWDrawInfo *di, FRenderState &state, int rflags)
|
|||
state.EnableGlow(false);
|
||||
state.EnableGradient(false);
|
||||
state.ApplyTextureManipulation(nullptr);
|
||||
#endif
|
||||
*/
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -229,16 +263,16 @@ void HWWall::RenderTranslucentWall(HWDrawInfo *di, FRenderState &state)
|
|||
//==========================================================================
|
||||
void HWWall::DrawWall(HWDrawInfo *di, FRenderState &state, bool translucent)
|
||||
{
|
||||
/*
|
||||
if (screen->BuffersArePersistent())
|
||||
{
|
||||
/*
|
||||
if (di->Level->HasDynamicLights && !di->isFullbrightScene() && texture != nullptr)
|
||||
{
|
||||
SetupLights(di, lightdata);
|
||||
}
|
||||
*/
|
||||
MakeVertices(di, !!(flags & HWWall::HWF_TRANSLUCENT));
|
||||
}
|
||||
*/
|
||||
|
||||
state.SetNormal(glseg.Normal());
|
||||
if (!translucent)
|
||||
|
@ -379,16 +413,18 @@ void HWWall::PutWall(HWDrawInfo *di, bool translucent)
|
|||
//ViewDistance = (di->Viewpoint.Pos - (seg->linedef->v1->fPos() + seg->linedef->Delta() / 2)).XY().LengthSquared();
|
||||
}
|
||||
|
||||
/*
|
||||
if (!screen->BuffersArePersistent())
|
||||
{
|
||||
/*
|
||||
if (di->Level->HasDynamicLights && !di->isFullbrightScene() && texture != nullptr)
|
||||
{
|
||||
SetupLights(di, lightdata);
|
||||
}
|
||||
*/
|
||||
MakeVertices(di, translucent);
|
||||
}
|
||||
|
||||
/*
|
||||
bool hasDecals = type != RENDERWALL_M2S && seg->sidedef->AttachedDecals;
|
||||
if (hasDecals)
|
||||
{
|
||||
|
@ -404,56 +440,7 @@ void HWWall::PutWall(HWDrawInfo *di, bool translucent)
|
|||
}
|
||||
*/
|
||||
|
||||
#if 0
|
||||
di->AddWall(this);
|
||||
#else
|
||||
// route it through the GLInterface for now for easier testing
|
||||
int palid = TRANSLATION(Translation_Remap + curbasepal, globalpal);
|
||||
GLInterface.SetFade(globalfloorpal);
|
||||
GLInterface.SetTexture(texture, TRANSLATION(Translation_Remap + curbasepal, palette), 0);
|
||||
|
||||
GLInterface.SetShade(shade, numshades);
|
||||
|
||||
int h = texture->GetTexelHeight();
|
||||
int h2 = 1 << sizeToBits(h);
|
||||
if (h2 < h) h2 *= 2;
|
||||
if (h != h2)
|
||||
{
|
||||
float xOffset = 1.f / texture->GetTexelWidth();
|
||||
GLInterface.SetNpotEmulation(float(h2) / h, xOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
GLInterface.SetNpotEmulation(0.f, 0.f);
|
||||
}
|
||||
GLInterface.SetTextureMode(TM_OPAQUE);
|
||||
GLInterface.SetVisibility(visibility);
|
||||
|
||||
// The shade rgb from the tint is ignored here.
|
||||
float pc[4];
|
||||
pc[0] = (float)globalr * (1.f / 255.f);
|
||||
pc[1] = (float)globalg * (1.f / 255.f);
|
||||
pc[2] = (float)globalb * (1.f / 255.f);
|
||||
pc[3] = alpha;
|
||||
GLInterface.SetColor(pc[0], pc[1], pc[2], pc[3]);
|
||||
|
||||
auto data = screen->mVertexData->AllocVertices(4);
|
||||
auto vt = data.first;
|
||||
vt[0].SetTexCoord(tcs[LOLFT].u, tcs[LOLFT].v);
|
||||
vt[0].SetVertex(glseg.x1, zbottom[0], glseg.y1);
|
||||
vt[1].SetTexCoord(tcs[UPLFT].u, tcs[UPLFT].v);
|
||||
vt[1].SetVertex(glseg.x1, ztop[0], glseg.y1);
|
||||
vt[2].SetTexCoord(tcs[UPRGT].u, tcs[UPRGT].v);
|
||||
vt[2].SetVertex(glseg.x2, ztop[1], glseg.y2);
|
||||
vt[3].SetTexCoord(tcs[LORGT].u, tcs[LORGT].v);
|
||||
vt[3].SetVertex(glseg.x2, zbottom[1], glseg.y2);
|
||||
|
||||
GLInterface.Draw(DT_TriangleFan, data.second, 4);
|
||||
|
||||
GLInterface.SetNpotEmulation(0.f, 0.f);
|
||||
GLInterface.SetTextureMode(TM_NORMAL);
|
||||
|
||||
#endif
|
||||
// make sure that following parts of the same linedef do not get this one's vertex and lighting info.
|
||||
vertcount = 0;
|
||||
dynlightindex = -1;
|
||||
|
@ -1000,7 +987,7 @@ void HWWall::Process(HWDrawInfo *di, walltype *wal, sectortype* frontsector, sec
|
|||
dynlightindex = -1;
|
||||
shade = wal->shade;
|
||||
palette = wal->pal;
|
||||
floorpal = frontsector->floorpal;
|
||||
fade = lookups.getFade(frontsector->floorpal); // fog is per sector.
|
||||
visibility = sectorVisibility(frontsector);
|
||||
|
||||
alpha = 1.0f;
|
||||
|
|
|
@ -34,6 +34,10 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
|
|||
#include "dukeactor.h"
|
||||
#include "interpolate.h"
|
||||
|
||||
// temporary hack to pass along RRRA's global fog. Needs to be done better later.
|
||||
extern PalEntry GlobalMapFog;
|
||||
extern float GlobalFogDensity;
|
||||
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
|
@ -491,6 +495,8 @@ void displayrooms(int snum, double smoothratio)
|
|||
sect = p->cursectnum;
|
||||
if (sect < 0 || sect >= MAXSECTORS) return;
|
||||
|
||||
GlobalMapFog = fogactive ? 0x999999 : 0;
|
||||
GlobalFogDensity = fogactive ? 350.f : 0.f;
|
||||
GLInterface.SetMapFog(fogactive != 0);
|
||||
DoInterpolations(smoothratio / 65536.);
|
||||
|
||||
|
|
|
@ -287,12 +287,6 @@ public:
|
|||
renderState.NPOTEmulation.X = xOffset;
|
||||
}
|
||||
|
||||
void SetFadeDisable(bool yes)
|
||||
{
|
||||
if (yes) renderState.Flags |= RF_FogDisabled;
|
||||
else renderState.Flags &= ~RF_FogDisabled;
|
||||
}
|
||||
|
||||
// Hack...
|
||||
bool useMapFog = false;
|
||||
|
||||
|
|
Loading…
Reference in a new issue