Permalink
Browse files

- everything compiles again.

As a bonus this already fixes several bugs caused by the botched texture scaling implementation the original texture manager came with.
System cursors are currently disabled because they rely on functionality that needs to be moved to different classes.
  • Loading branch information...
coelckers committed Dec 6, 2018
1 parent 6eab4a8 commit a4d61e6fb13cfe89327222d6fcfbace35f6f0dd0
Showing with 268 additions and 197 deletions.
  1. +1 −3 src/gl/renderer/gl_renderstate.cpp
  2. +0 −2 src/gl/textures/gl_hwtexture.cpp
  3. +39 −34 src/swrenderer/line/r_line.cpp
  4. +1 −1 src/swrenderer/line/r_line.h
  5. +47 −32 src/swrenderer/line/r_renderdrawsegment.cpp
  6. +1 −1 src/swrenderer/line/r_renderdrawsegment.h
  7. +8 −8 src/swrenderer/line/r_walldraw.cpp
  8. +3 −3 src/swrenderer/line/r_walldraw.h
  9. +1 −1 src/swrenderer/plane/r_flatplane.cpp
  10. +1 −1 src/swrenderer/plane/r_flatplane.h
  11. +19 −11 src/swrenderer/plane/r_skyplane.cpp
  12. +2 −2 src/swrenderer/plane/r_skyplane.h
  13. +1 −1 src/swrenderer/plane/r_slopeplane.cpp
  14. +1 −1 src/swrenderer/plane/r_slopeplane.h
  15. +6 −5 src/swrenderer/plane/r_visibleplane.cpp
  16. +1 −1 src/swrenderer/r_renderthread.cpp
  17. +1 −1 src/swrenderer/r_renderthread.h
  18. +5 −2 src/swrenderer/r_swrenderer.cpp
  19. +7 −7 src/swrenderer/r_swscene.cpp
  20. +4 −4 src/swrenderer/scene/r_opaque_pass.cpp
  21. +4 −3 src/swrenderer/things/r_decal.cpp
  22. +1 −1 src/swrenderer/things/r_decal.h
  23. +3 −3 src/swrenderer/things/r_model.cpp
  24. +12 −11 src/swrenderer/things/r_playersprite.cpp
  25. +1 −1 src/swrenderer/things/r_playersprite.h
  26. +6 −5 src/swrenderer/things/r_sprite.cpp
  27. +1 −1 src/swrenderer/things/r_visiblesprite.h
  28. +4 −3 src/swrenderer/things/r_wallsprite.cpp
  29. +1 −1 src/swrenderer/things/r_wallsprite.h
  30. +2 −2 src/swrenderer/viewport/r_skydrawer.cpp
  31. +2 −2 src/swrenderer/viewport/r_skydrawer.h
  32. +3 −3 src/swrenderer/viewport/r_spandrawer.cpp
  33. +1 −1 src/swrenderer/viewport/r_spandrawer.h
  34. +2 −2 src/swrenderer/viewport/r_spritedrawer.cpp
  35. +2 −2 src/swrenderer/viewport/r_spritedrawer.h
  36. +3 −3 src/textures/formats/brightmaptexture.cpp
  37. +7 −7 src/textures/texturemanager.cpp
  38. +33 −5 src/textures/textures.h
  39. +13 −13 src/v_font.cpp
  40. +7 −7 src/wi_stuff.cpp
  41. +11 −0 src/win32/i_system.cpp
@@ -303,7 +303,6 @@ void FGLRenderState::Apply()
void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translation, int overrideshader)
{
#if 0
if (mat->tex->isHardwareCanvas())
{
mTempTM = TM_OPAQUE;
@@ -318,7 +317,7 @@ void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translatio
auto tex = mat->tex;
if (tex->UseType == ETextureType::SWCanvas) clampmode = CLAMP_NOFILTER;
if (tex->sHardwareCanvas()) clampmode = CLAMP_CAMTEX;
if (tex->isHardwareCanvas()) clampmode = CLAMP_CAMTEX;
else if ((tex->isWarped() || tex->shaderindex >= FIRST_USER_SHADER) && clampmode <= CLAMP_XY) clampmode = CLAMP_NONE;
// avoid rebinding the same texture multiple times.
@@ -351,7 +350,6 @@ void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translatio
FHardwareTexture::Unbind(i);
maxBoundMaterial = maxbound;
}
#endif
}
//==========================================================================
@@ -422,7 +422,6 @@ void FHardwareTexture::BindToFrameBuffer(int width, int height)
bool FHardwareTexture::BindOrCreate(FTexture *tex, int texunit, int clampmode, int translation, int flags)
{
#if 0
int usebright = false;
if (translation <= 0)
@@ -465,7 +464,6 @@ bool FHardwareTexture::BindOrCreate(FTexture *tex, int texunit, int clampmode, i
}
if (tex->isHardwareCanvas()) static_cast<FCanvasTexture*>(tex)->NeedUpdate();
GLRenderer->mSamplerManager->Bind(texunit, clampmode, 255);
#endif
return true;
}
@@ -425,7 +425,7 @@ namespace swrenderer
if (!onlyUpdatePlaneClip)
// allocate space for masked texture tables, if needed
// [RH] Don't just allocate the space; fill it in too.
if ((TexMan(sidedef->GetTexture(side_t::mid), true)->UseType != ETextureType::Null || draw_segment->Has3DFloorWalls() || IsFogBoundary(mFrontSector, mBackSector)) &&
if ((sidedef->GetTexture(side_t::mid).isValid() || draw_segment->Has3DFloorWalls() || IsFogBoundary(mFrontSector, mBackSector)) &&
(mCeilingClipped != ProjectedWallCull::OutsideBelow || !sidedef->GetTexture(side_t::top).isValid()) &&
(mFloorClipped != ProjectedWallCull::OutsideAbove || !sidedef->GetTexture(side_t::bottom).isValid()) &&
(WallC.sz1 >= TOO_CLOSE_Z && WallC.sz2 >= TOO_CLOSE_Z))
@@ -451,11 +451,12 @@ namespace swrenderer
lwal = draw_segment->maskedtexturecol;
swal = draw_segment->swall;
FTexture *pic = TexMan(sidedef->GetTexture(side_t::mid), true);
double yscale = pic->Scale.Y * sidedef->GetTextureYScale(side_t::mid);
FTexture *tex = TexMan(sidedef->GetTexture(side_t::mid), true);
FSoftwareTexture *pic = tex && tex->isValid()? tex->GetSoftwareTexture() : nullptr;
double yscale = pic->GetScale().Y * sidedef->GetTextureYScale(side_t::mid);
fixed_t xoffset = FLOAT2FIXED(sidedef->GetTextureXOffset(side_t::mid));
if (pic->bWorldPanning)
if (pic->useWorldPanning())
{
xoffset = xs_RoundToInt(xoffset * lwallscale);
}
@@ -769,17 +770,18 @@ namespace swrenderer
}
}
FTexture *midtex = TexMan(sidedef->GetTexture(side_t::mid), true);
FTexture *ftex = TexMan(sidedef->GetTexture(side_t::mid), true);
FSoftwareTexture *midtex = ftex && ftex->isValid() ? ftex->GetSoftwareTexture() : nullptr;
bool segtextured = midtex != NULL || mTopPart.Texture != NULL || mBottomPart.Texture != NULL;
// calculate light table
if (needlights && (segtextured || (mBackSector && IsFogBoundary(mFrontSector, mBackSector))))
{
lwallscale =
midtex ? (midtex->Scale.X * sidedef->GetTextureXScale(side_t::mid)) :
mTopPart.Texture ? (mTopPart.Texture->Scale.X * sidedef->GetTextureXScale(side_t::top)) :
mBottomPart.Texture ? (mBottomPart.Texture->Scale.X * sidedef->GetTextureXScale(side_t::bottom)) :
midtex ? (midtex->GetScale().X * sidedef->GetTextureXScale(side_t::mid)) :
mTopPart.Texture ? (mTopPart.Texture->GetScale().X * sidedef->GetTextureXScale(side_t::top)) :
mBottomPart.Texture ? (mBottomPart.Texture->GetScale().X * sidedef->GetTextureXScale(side_t::bottom)) :
1.;
walltexcoords.Project(Thread->Viewport.get(), sidedef->TexelLength * lwallscale, WallC.sx1, WallC.sx2, WallT);
@@ -814,13 +816,14 @@ namespace swrenderer
// No top texture for skyhack lines
if (mFrontSector->GetTexture(sector_t::ceiling) == skyflatnum && mBackSector->GetTexture(sector_t::ceiling) == skyflatnum) return;
mTopPart.Texture = TexMan(sidedef->GetTexture(side_t::top), true);
FTexture *tex = TexMan(sidedef->GetTexture(side_t::top), true);
mTopPart.Texture = tex && tex->isValid() ? tex->GetSoftwareTexture() : nullptr;
mTopPart.TextureOffsetU = FLOAT2FIXED(sidedef->GetTextureXOffset(side_t::top));
double rowoffset = sidedef->GetTextureYOffset(side_t::top);
mTopPart.TextureScaleU = sidedef->GetTextureXScale(side_t::top);
mTopPart.TextureScaleV = sidedef->GetTextureYScale(side_t::top);
double yrepeat = mTopPart.Texture->Scale.Y * mTopPart.TextureScaleV;
double yrepeat = mTopPart.Texture->GetScale().Y * mTopPart.TextureScaleV;
if (yrepeat >= 0)
{ // normal orientation
if (linedef->flags & ML_DONTPEGTOP)
@@ -848,7 +851,7 @@ namespace swrenderer
mTopPart.TextureMid = (mBackSector->GetPlaneTexZ(sector_t::ceiling) - Thread->Viewport->viewpoint.Pos.Z) * yrepeat;
}
}
if (mTopPart.Texture->bWorldPanning)
if (mTopPart.Texture->useWorldPanning())
{
mTopPart.TextureMid += rowoffset * yrepeat;
}
@@ -871,12 +874,13 @@ namespace swrenderer
if (linedef->isVisualPortal()) return;
if (linedef->special == Line_Horizon) return;
mMiddlePart.Texture = TexMan(sidedef->GetTexture(side_t::mid), true);
auto tex = TexMan(sidedef->GetTexture(side_t::mid), true);
mMiddlePart.Texture = tex && tex->isValid() ? tex->GetSoftwareTexture() : nullptr;
mMiddlePart.TextureOffsetU = FLOAT2FIXED(sidedef->GetTextureXOffset(side_t::mid));
double rowoffset = sidedef->GetTextureYOffset(side_t::mid);
mMiddlePart.TextureScaleU = sidedef->GetTextureXScale(side_t::mid);
mMiddlePart.TextureScaleV = sidedef->GetTextureYScale(side_t::mid);
double yrepeat = mMiddlePart.Texture->Scale.Y * mMiddlePart.TextureScaleV;
double yrepeat = mMiddlePart.Texture->GetScale().Y * mMiddlePart.TextureScaleV;
if (yrepeat >= 0)
{ // normal orientation
if (linedef->flags & ML_DONTPEGBOTTOM)
@@ -904,7 +908,7 @@ namespace swrenderer
mMiddlePart.TextureMid = (mFrontSector->GetPlaneTexZ(sector_t::ceiling) - Thread->Viewport->viewpoint.Pos.Z) * yrepeat + mMiddlePart.Texture->GetHeight();
}
}
if (mMiddlePart.Texture->bWorldPanning)
if (mMiddlePart.Texture->useWorldPanning())
{
mMiddlePart.TextureMid += rowoffset * yrepeat;
}
@@ -935,13 +939,14 @@ namespace swrenderer
frontlowertop = mBackSector->GetPlaneTexZ(sector_t::ceiling);
}
mBottomPart.Texture = TexMan(sidedef->GetTexture(side_t::bottom), true);
FTexture *tex = TexMan(sidedef->GetTexture(side_t::bottom), true);;
mBottomPart.Texture = tex && tex->isValid() ? tex->GetSoftwareTexture() : nullptr;
mBottomPart.TextureOffsetU = FLOAT2FIXED(sidedef->GetTextureXOffset(side_t::bottom));
double rowoffset = sidedef->GetTextureYOffset(side_t::bottom);
mBottomPart.TextureScaleU = sidedef->GetTextureXScale(side_t::bottom);
mBottomPart.TextureScaleV = sidedef->GetTextureYScale(side_t::bottom);
double yrepeat = mBottomPart.Texture->Scale.Y * mBottomPart.TextureScaleV;
double yrepeat = mBottomPart.Texture->GetScale().Y * mBottomPart.TextureScaleV;
if (yrepeat >= 0)
{ // normal orientation
if (linedef->flags & ML_DONTPEGBOTTOM)
@@ -969,7 +974,7 @@ namespace swrenderer
mBottomPart.TextureMid = (mBackSector->GetPlaneTexZ(sector_t::floor) - Thread->Viewport->viewpoint.Pos.Z) * yrepeat + mBottomPart.Texture->GetHeight();
}
}
if (mBottomPart.Texture->bWorldPanning)
if (mBottomPart.Texture->useWorldPanning())
{
mBottomPart.TextureMid += rowoffset * yrepeat;
}
@@ -1101,7 +1106,7 @@ namespace swrenderer
}
else
{ // two sided line
if (mTopPart.Texture != NULL && mTopPart.Texture->UseType != ETextureType::Null)
if (mTopPart.Texture != nullptr)
{ // top wall
for (int x = x1; x < x2; ++x)
{
@@ -1114,7 +1119,7 @@ namespace swrenderer
memcpy(ceilingclip + x1, walltop.ScreenY + x1, (x2 - x1) * sizeof(short));
}
if (mBottomPart.Texture != NULL && mBottomPart.Texture->UseType != ETextureType::Null)
if (mBottomPart.Texture != nullptr)
{ // bottom wall
for (int x = x1; x < x2; ++x)
{
@@ -1132,19 +1137,19 @@ namespace swrenderer
void SWRenderLine::RenderTopTexture(int x1, int x2)
{
if (mMiddlePart.Texture) return;
if (!mTopPart.Texture || mTopPart.Texture->UseType == ETextureType::Null) return;
if (!mTopPart.Texture) return;
if (!viewactive) return;
FTexture *rw_pic = mTopPart.Texture;
double xscale = rw_pic->Scale.X * mTopPart.TextureScaleU;
double yscale = rw_pic->Scale.Y * mTopPart.TextureScaleV;
auto rw_pic = mTopPart.Texture;
double xscale = rw_pic->GetScale().X * mTopPart.TextureScaleU;
double yscale = rw_pic->GetScale().Y * mTopPart.TextureScaleV;
if (xscale != lwallscale)
{
walltexcoords.ProjectPos(Thread->Viewport.get(), mLineSegment->sidedef->TexelLength*xscale, WallC.sx1, WallC.sx2, WallT);
lwallscale = xscale;
}
fixed_t offset;
if (mTopPart.Texture->bWorldPanning)
if (mTopPart.Texture->useWorldPanning())
{
offset = xs_RoundToInt(mTopPart.TextureOffsetU * xscale);
}
@@ -1179,19 +1184,19 @@ namespace swrenderer
void SWRenderLine::RenderMiddleTexture(int x1, int x2)
{
if (!mMiddlePart.Texture || mMiddlePart.Texture->UseType == ETextureType::Null) return;
if (!mMiddlePart.Texture) return;
if (!viewactive) return;
FTexture *rw_pic = mMiddlePart.Texture;
double xscale = rw_pic->Scale.X * mMiddlePart.TextureScaleU;
double yscale = rw_pic->Scale.Y * mMiddlePart.TextureScaleV;
auto rw_pic = mMiddlePart.Texture;
double xscale = rw_pic->GetScale().X * mMiddlePart.TextureScaleU;
double yscale = rw_pic->GetScale().Y * mMiddlePart.TextureScaleV;
if (xscale != lwallscale)
{
walltexcoords.ProjectPos(Thread->Viewport.get(), mLineSegment->sidedef->TexelLength*xscale, WallC.sx1, WallC.sx2, WallT);
lwallscale = xscale;
}
fixed_t offset;
if (mMiddlePart.Texture->bWorldPanning)
if (mMiddlePart.Texture->useWorldPanning())
{
offset = xs_RoundToInt(mMiddlePart.TextureOffsetU * xscale);
}
@@ -1227,19 +1232,19 @@ namespace swrenderer
void SWRenderLine::RenderBottomTexture(int x1, int x2)
{
if (mMiddlePart.Texture) return;
if (!mBottomPart.Texture || mBottomPart.Texture->UseType == ETextureType::Null) return;
if (!mBottomPart.Texture) return;
if (!viewactive) return;
FTexture *rw_pic = mBottomPart.Texture;
double xscale = rw_pic->Scale.X * mBottomPart.TextureScaleU;
double yscale = rw_pic->Scale.Y * mBottomPart.TextureScaleV;
auto rw_pic = mBottomPart.Texture;
double xscale = rw_pic->GetScale().X * mBottomPart.TextureScaleU;
double yscale = rw_pic->GetScale().Y * mBottomPart.TextureScaleV;
if (xscale != lwallscale)
{
walltexcoords.ProjectPos(Thread->Viewport.get(), mLineSegment->sidedef->TexelLength*xscale, WallC.sx1, WallC.sx2, WallT);
lwallscale = xscale;
}
fixed_t offset;
if (mBottomPart.Texture->bWorldPanning)
if (mBottomPart.Texture->useWorldPanning())
{
offset = xs_RoundToInt(mBottomPart.TextureOffsetU * xscale);
}
@@ -65,7 +65,7 @@ namespace swrenderer
double TextureMid;
double TextureScaleU;
double TextureScaleV;
FTexture *Texture;
FSoftwareTexture *Texture;
};
class SWRenderLine : VisibleSegmentRenderer
Oops, something went wrong.

0 comments on commit a4d61e6

Please sign in to comment.