diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 4a683a0909..30a2918998 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.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 } //========================================================================== diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index 75d940d3b0..f6cdc8415c 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -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(tex)->NeedUpdate(); GLRenderer->mSamplerManager->Bind(texunit, clampmode, 255); -#endif return true; } diff --git a/src/swrenderer/line/r_line.cpp b/src/swrenderer/line/r_line.cpp index 77ac90f5bd..ddb291c360 100644 --- a/src/swrenderer/line/r_line.cpp +++ b/src/swrenderer/line/r_line.cpp @@ -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,7 +770,8 @@ 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; @@ -777,9 +779,9 @@ namespace swrenderer 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); } diff --git a/src/swrenderer/line/r_line.h b/src/swrenderer/line/r_line.h index a76f4dc7c4..dbe2cbb60f 100644 --- a/src/swrenderer/line/r_line.h +++ b/src/swrenderer/line/r_line.h @@ -65,7 +65,7 @@ namespace swrenderer double TextureMid; double TextureScaleU; double TextureScaleV; - FTexture *Texture; + FSoftwareTexture *Texture; }; class SWRenderLine : VisibleSegmentRenderer diff --git a/src/swrenderer/line/r_renderdrawsegment.cpp b/src/swrenderer/line/r_renderdrawsegment.cpp index fbc18b0c6f..060f40fa13 100644 --- a/src/swrenderer/line/r_renderdrawsegment.cpp +++ b/src/swrenderer/line/r_renderdrawsegment.cpp @@ -162,11 +162,12 @@ namespace swrenderer if (curline->sidedef->GetTexture(side_t::mid).isNull()) return false; - FTexture *tex = TexMan(curline->sidedef->GetTexture(side_t::mid), true); + FTexture *ttex = TexMan(curline->sidedef->GetTexture(side_t::mid), true); if (i_compatflags & COMPATF_MASKEDMIDTEX) { - tex = tex->GetRawTexture(); + ttex = ttex->GetRawTexture(); } + FSoftwareTexture *tex = ttex->GetSoftwareTexture(); const short *mfloorclip = ds->sprbottomclip - ds->x1; const short *mceilingclip = ds->sprtopclip - ds->x1; @@ -221,7 +222,7 @@ namespace swrenderer MaskedScaleY = -MaskedScaleY; sprflipvert = true; } - if (tex->bWorldPanning) + if (tex->useWorldPanning()) { // rowoffset is added before the multiply so that the masked texture will // still be positioned in world units rather than texels. @@ -354,7 +355,7 @@ namespace swrenderer } else { // Texture does wrap vertically. - if (tex->bWorldPanning) + if (tex->useWorldPanning()) { // rowoffset is added before the multiply so that the masked texture will // still be positioned in world units rather than texels. @@ -459,8 +460,8 @@ namespace swrenderer scaledside = rover->master->sidedef[0]; scaledpart = side_t::mid; } - xscale = rw_pic->Scale.X * scaledside->GetTextureXScale(scaledpart); - yscale = rw_pic->Scale.Y * scaledside->GetTextureYScale(scaledpart); + xscale = rw_pic->GetScale().X * scaledside->GetTextureXScale(scaledpart); + yscale = rw_pic->GetScale().Y * scaledside->GetTextureYScale(scaledpart); double rowoffset = curline->sidedef->GetTextureYOffset(side_t::mid) + rover->master->sidedef[0]->GetTextureYOffset(side_t::mid); double planez = rover->model->GetPlaneTexZ(sector_t::ceiling); @@ -470,7 +471,7 @@ namespace swrenderer rowoffset += rw_pic->GetHeight(); } double texturemid = (planez - Thread->Viewport->viewpoint.Pos.Z) * yscale; - if (rw_pic->bWorldPanning) + if (rw_pic->useWorldPanning()) { // rowoffset is added before the multiply so that the masked texture will // still be positioned in world units rather than texels. @@ -531,7 +532,7 @@ namespace swrenderer // kg3D - walls of fake floors void RenderDrawSegment::RenderFakeWallRange(DrawSegment *ds, int x1, int x2, int wallshade) { - FTexture *const DONT_DRAW = ((FTexture*)(intptr_t)-1); + FSoftwareTexture *const DONT_DRAW = ((FSoftwareTexture*)(intptr_t)-1); int i, j; F3DFloor *rover, *fover = nullptr; int passed, last; @@ -637,17 +638,22 @@ namespace swrenderer { // don't ever draw (but treat as something has been found) rw_pic = DONT_DRAW; } - else if (fover->flags & FF_UPPERTEXTURE) - { - rw_pic = TexMan(curline->sidedef->GetTexture(side_t::top), true); - } - else if (fover->flags & FF_LOWERTEXTURE) - { - rw_pic = TexMan(curline->sidedef->GetTexture(side_t::bottom), true); - } else { - rw_pic = TexMan(fover->master->sidedef[0]->GetTexture(side_t::mid), true); + FTexture *rw_tex = nullptr; + if (fover->flags & FF_UPPERTEXTURE) + { + rw_tex = TexMan(curline->sidedef->GetTexture(side_t::top), true); + } + else if (fover->flags & FF_LOWERTEXTURE) + { + rw_tex = TexMan(curline->sidedef->GetTexture(side_t::bottom), true); + } + else + { + rw_tex = TexMan(fover->master->sidedef[0]->GetTexture(side_t::mid), true); + } + rw_pic = rw_tex && rw_tex->isValid() ? rw_tex->GetSoftwareTexture() : nullptr; } } else if (frontsector->e->XFloor.ffloors.Size()) @@ -696,18 +702,20 @@ namespace swrenderer if (!rw_pic) { fover = nullptr; + FTexture *rw_tex; if (rover->flags & FF_UPPERTEXTURE) { - rw_pic = TexMan(curline->sidedef->GetTexture(side_t::top), true); + rw_tex = TexMan(curline->sidedef->GetTexture(side_t::top), true); } else if (rover->flags & FF_LOWERTEXTURE) { - rw_pic = TexMan(curline->sidedef->GetTexture(side_t::bottom), true); + rw_tex = TexMan(curline->sidedef->GetTexture(side_t::bottom), true); } else { - rw_pic = TexMan(rover->master->sidedef[0]->GetTexture(side_t::mid), true); + rw_tex = TexMan(rover->master->sidedef[0]->GetTexture(side_t::mid), true); } + rw_pic = rw_tex && rw_tex->isValid() ? rw_tex->GetSoftwareTexture() : nullptr; } // correct colors now FDynamicColormap *basecolormap = nullptr; @@ -819,17 +827,22 @@ namespace swrenderer { rw_pic = DONT_DRAW; // don't ever draw (but treat as something has been found) } - else if (fover->flags & FF_UPPERTEXTURE) - { - rw_pic = TexMan(curline->sidedef->GetTexture(side_t::top), true); - } - else if (fover->flags & FF_LOWERTEXTURE) - { - rw_pic = TexMan(curline->sidedef->GetTexture(side_t::bottom), true); - } else { - rw_pic = TexMan(fover->master->sidedef[0]->GetTexture(side_t::mid), true); + FTexture *rw_tex; + if (fover->flags & FF_UPPERTEXTURE) + { + rw_tex = TexMan(curline->sidedef->GetTexture(side_t::top), true); + } + else if (fover->flags & FF_LOWERTEXTURE) + { + rw_tex = TexMan(curline->sidedef->GetTexture(side_t::bottom), true); + } + else + { + rw_tex = TexMan(fover->master->sidedef[0]->GetTexture(side_t::mid), true); + } + rw_pic = rw_tex && rw_tex->isValid() ? rw_tex->GetSoftwareTexture() : nullptr; } } else if (frontsector->e->XFloor.ffloors.Size()) @@ -875,18 +888,20 @@ namespace swrenderer if (rw_pic == nullptr) { fover = nullptr; + FTexture *rw_tex; if (rover->flags & FF_UPPERTEXTURE) { - rw_pic = TexMan(curline->sidedef->GetTexture(side_t::top), true); + rw_tex = TexMan(curline->sidedef->GetTexture(side_t::top), true); } else if (rover->flags & FF_LOWERTEXTURE) { - rw_pic = TexMan(curline->sidedef->GetTexture(side_t::bottom), true); + rw_tex = TexMan(curline->sidedef->GetTexture(side_t::bottom), true); } else { - rw_pic = TexMan(rover->master->sidedef[0]->GetTexture(side_t::mid), true); + rw_tex = TexMan(rover->master->sidedef[0]->GetTexture(side_t::mid), true); } + rw_pic = rw_tex && rw_tex->isValid() ? rw_tex->GetSoftwareTexture() : nullptr; } // correct colors now FDynamicColormap *basecolormap = nullptr; diff --git a/src/swrenderer/line/r_renderdrawsegment.h b/src/swrenderer/line/r_renderdrawsegment.h index 82186f3174..3c45c9ab5f 100644 --- a/src/swrenderer/line/r_renderdrawsegment.h +++ b/src/swrenderer/line/r_renderdrawsegment.h @@ -55,7 +55,7 @@ namespace swrenderer float rw_light = 0.0f; float rw_lightstep = 0.0f; fixed_t rw_offset = 0; - FTexture *rw_pic = nullptr; + FSoftwareTexture *rw_pic = nullptr; ProjectedWallLine wallupper; ProjectedWallLine walllower; diff --git a/src/swrenderer/line/r_walldraw.cpp b/src/swrenderer/line/r_walldraw.cpp index 138efab840..0dce2236ea 100644 --- a/src/swrenderer/line/r_walldraw.cpp +++ b/src/swrenderer/line/r_walldraw.cpp @@ -54,7 +54,7 @@ namespace swrenderer { - WallSampler::WallSampler(RenderViewport *viewport, int y1, double texturemid, float swal, double yrepeat, fixed_t xoffset, double xmagnitude, FTexture *texture) + WallSampler::WallSampler(RenderViewport *viewport, int y1, double texturemid, float swal, double yrepeat, fixed_t xoffset, double xmagnitude, FSoftwareTexture *texture) { xoffset += FLOAT2FIXED(xmagnitude * 0.5); @@ -62,7 +62,7 @@ namespace swrenderer { height = texture->GetHeight(); - int uv_fracbits = 32 - texture->HeightBits; + int uv_fracbits = 32 - texture->GetHeightBits(); if (uv_fracbits != 32) { uv_max = height << uv_fracbits; @@ -92,7 +92,7 @@ namespace swrenderer // If the texture's width isn't a power of 2, then we need to make it a // positive offset for proper clamping. int width; - if (col < 0 && (width = texture->GetWidth()) != (1 << texture->WidthBits)) + if (col < 0 && (width = texture->GetWidth()) != (1 << texture->GetWidthBits())) { col = width + (col % width); } @@ -332,10 +332,10 @@ namespace swrenderer void RenderWallPart::ProcessWallWorker(const short *uwal, const short *dwal, double texturemid, float *swal, fixed_t *lwal) { - if (rw_pic->UseType == ETextureType::Null) + if (rw_pic == nullptr) return; - int fracbits = 32 - rw_pic->HeightBits; + int fracbits = 32 - rw_pic->GetHeightBits(); if (fracbits == 32) { // Hack for one pixel tall textures fracbits = 0; @@ -428,7 +428,7 @@ namespace swrenderer void RenderWallPart::ProcessWall(const short *uwal, const short *dwal, double texturemid, float *swal, fixed_t *lwal) { // Textures that aren't masked can use the faster ProcessNormalWall. - if (!rw_pic->bMasked && drawerargs.IsMaskedDrawer()) + if (!rw_pic->GetTexture()->isMasked() && drawerargs.IsMaskedDrawer()) { drawerargs.SetStyle(true, false, OPAQUE); } @@ -516,7 +516,7 @@ namespace swrenderer } } - void RenderWallPart::Render(const WallDrawerArgs &drawerargs, sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, FTexture *pic, int x1, int x2, const short *walltop, const short *wallbottom, double texturemid, float *swall, fixed_t *lwall, double yscale, double top, double bottom, bool mask, int wallshade, fixed_t xoffset, float light, float lightstep, FLightNode *light_list, bool foggy, FDynamicColormap *basecolormap) + void RenderWallPart::Render(const WallDrawerArgs &drawerargs, sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, FSoftwareTexture *pic, int x1, int x2, const short *walltop, const short *wallbottom, double texturemid, float *swall, fixed_t *lwall, double yscale, double top, double bottom, bool mask, int wallshade, fixed_t xoffset, float light, float lightstep, FLightNode *light_list, bool foggy, FDynamicColormap *basecolormap) { this->drawerargs = drawerargs; this->x1 = x1; @@ -537,7 +537,7 @@ namespace swrenderer Thread->PrepareTexture(pic, DefaultRenderStyle()); // Get correct render style? Shaded won't get here. - if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits) + if (rw_pic->GetHeight() != 1 << rw_pic->GetHeightBits()) { ProcessWallNP2(walltop, wallbottom, texturemid, swall, lwall, top, bottom); } diff --git a/src/swrenderer/line/r_walldraw.h b/src/swrenderer/line/r_walldraw.h index d3cd026a21..b3a47a7d36 100644 --- a/src/swrenderer/line/r_walldraw.h +++ b/src/swrenderer/line/r_walldraw.h @@ -50,7 +50,7 @@ namespace swrenderer sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, - FTexture *rw_pic, + FSoftwareTexture *rw_pic, int x1, int x2, const short *walltop, @@ -82,7 +82,7 @@ namespace swrenderer int x1 = 0; int x2 = 0; - FTexture *rw_pic = nullptr; + FSoftwareTexture *rw_pic = nullptr; sector_t *frontsector = nullptr; seg_t *curline = nullptr; FWallCoords WallC; @@ -103,7 +103,7 @@ namespace swrenderer struct WallSampler { WallSampler() { } - WallSampler(RenderViewport *viewport, int y1, double texturemid, float swal, double yrepeat, fixed_t xoffset, double xmagnitude, FTexture *texture); + WallSampler(RenderViewport *viewport, int y1, double texturemid, float swal, double yrepeat, fixed_t xoffset, double xmagnitude, FSoftwareTexture *texture); uint32_t uv_pos; uint32_t uv_step; diff --git a/src/swrenderer/plane/r_flatplane.cpp b/src/swrenderer/plane/r_flatplane.cpp index 51d376bd4c..d826dbc566 100644 --- a/src/swrenderer/plane/r_flatplane.cpp +++ b/src/swrenderer/plane/r_flatplane.cpp @@ -60,7 +60,7 @@ namespace swrenderer Thread = thread; } - void RenderFlatPlane::Render(VisiblePlane *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked, FDynamicColormap *colormap, FTexture *texture) + void RenderFlatPlane::Render(VisiblePlane *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked, FDynamicColormap *colormap, FSoftwareTexture *texture) { if (alpha <= 0) { diff --git a/src/swrenderer/plane/r_flatplane.h b/src/swrenderer/plane/r_flatplane.h index 56b70a40c0..9e01afb949 100644 --- a/src/swrenderer/plane/r_flatplane.h +++ b/src/swrenderer/plane/r_flatplane.h @@ -34,7 +34,7 @@ namespace swrenderer { public: RenderFlatPlane(RenderThread *thread); - void Render(VisiblePlane *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked, FDynamicColormap *basecolormap, FTexture *texture); + void Render(VisiblePlane *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked, FDynamicColormap *basecolormap, FSoftwareTexture *texture); RenderThread *Thread = nullptr; diff --git a/src/swrenderer/plane/r_skyplane.cpp b/src/swrenderer/plane/r_skyplane.cpp index afa9496c03..de30a0a893 100644 --- a/src/swrenderer/plane/r_skyplane.cpp +++ b/src/swrenderer/plane/r_skyplane.cpp @@ -59,6 +59,14 @@ EXTERN_CVAR(Int, r_skymode) namespace swrenderer { + static FSoftwareTexture *GetSWTex(FTextureID texid, bool allownull = true) + { + auto tex = TexMan(texid, true); + if (tex == nullptr) return nullptr; + if (!allownull && !tex->isValid()) return nullptr; + return tex->GetSoftwareTexture(); + } + RenderSkyPlane::RenderSkyPlane(RenderThread *thread) { Thread = thread; @@ -86,9 +94,9 @@ namespace swrenderer if (!(pl->sky & PL_SKYFLAT)) { // use sky1 sky1: - frontskytex = TexMan(sky1tex, true); + frontskytex = GetSWTex(sky1tex); if (level.flags & LEVEL_DOUBLESKY) - backskytex = TexMan(sky2tex, true); + backskytex = GetSWTex(sky2tex); else backskytex = NULL; skyflip = 0; @@ -99,7 +107,7 @@ namespace swrenderer } else if (pl->sky == PL_SKYFLAT) { // use sky2 - frontskytex = TexMan(sky2tex, true); + frontskytex = GetSWTex(sky2tex); backskytex = NULL; frontcyl = sky2cyl; skyflip = 0; @@ -125,8 +133,8 @@ namespace swrenderer pos = side_t::top; } - frontskytex = TexMan(s->GetTexture(pos), true); - if (frontskytex == NULL || frontskytex->UseType == ETextureType::Null) + frontskytex = GetSWTex(s->GetTexture(pos)); + if (frontskytex == nullptr) { // [RH] The blank texture: Use normal sky instead. goto sky1; } @@ -148,7 +156,7 @@ namespace swrenderer // allow old sky textures to be used. skyflip = l->args[2] ? 0u : ~0u; - int frontxscale = int(frontskytex->Scale.X * 1024); + int frontxscale = int(frontskytex->GetScale().X * 1024); frontcyl = MAX(frontskytex->GetWidth(), frontxscale); if (skystretch) { @@ -231,16 +239,16 @@ namespace swrenderer void RenderSkyPlane::DrawSkyColumn(int start_x, int y1, int y2) { - if (1 << frontskytex->HeightBits == frontskytex->GetHeight()) + if (1 << frontskytex->GetHeightBits() == frontskytex->GetHeight()) { - double texturemid = skymid * frontskytex->Scale.Y + frontskytex->GetHeight(); - DrawSkyColumnStripe(start_x, y1, y2, frontskytex->Scale.Y, texturemid, frontskytex->Scale.Y); + double texturemid = skymid * frontskytex->GetScale().Y + frontskytex->GetHeight(); + DrawSkyColumnStripe(start_x, y1, y2, frontskytex->GetScale().Y, texturemid, frontskytex->GetScale().Y); } else { auto viewport = Thread->Viewport.get(); - double yrepeat = frontskytex->Scale.Y; - double scale = frontskytex->Scale.Y * skyscale; + double yrepeat = frontskytex->GetScale().Y; + double scale = frontskytex->GetScale().Y * skyscale; double iscale = 1 / scale; short drawheight = short(frontskytex->GetHeight() * scale); double topfrac = fmod(skymid + iscale * (1 - viewport->CenterY), frontskytex->GetHeight()); diff --git a/src/swrenderer/plane/r_skyplane.h b/src/swrenderer/plane/r_skyplane.h index 79a27c987a..ac5e07d25a 100644 --- a/src/swrenderer/plane/r_skyplane.h +++ b/src/swrenderer/plane/r_skyplane.h @@ -41,8 +41,8 @@ namespace swrenderer void DrawSkyColumnStripe(int start_x, int y1, int y2, double scale, double texturemid, double yrepeat); void DrawSkyColumn(int start_x, int y1, int y2); - FTexture *frontskytex = nullptr; - FTexture *backskytex = nullptr; + FSoftwareTexture *frontskytex = nullptr; + FSoftwareTexture *backskytex = nullptr; angle_t skyflip = 0; int frontpos = 0; int backpos = 0; diff --git a/src/swrenderer/plane/r_slopeplane.cpp b/src/swrenderer/plane/r_slopeplane.cpp index 20eb3dbf4e..fb20f107eb 100644 --- a/src/swrenderer/plane/r_slopeplane.cpp +++ b/src/swrenderer/plane/r_slopeplane.cpp @@ -64,7 +64,7 @@ namespace swrenderer Thread = thread; } - void RenderSlopePlane::Render(VisiblePlane *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked, FDynamicColormap *colormap, FTexture *texture) + void RenderSlopePlane::Render(VisiblePlane *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked, FDynamicColormap *colormap, FSoftwareTexture *texture) { static const float ifloatpow2[16] = { diff --git a/src/swrenderer/plane/r_slopeplane.h b/src/swrenderer/plane/r_slopeplane.h index c59fa3f586..88ef199cb2 100644 --- a/src/swrenderer/plane/r_slopeplane.h +++ b/src/swrenderer/plane/r_slopeplane.h @@ -33,7 +33,7 @@ namespace swrenderer { public: RenderSlopePlane(RenderThread *thread); - void Render(VisiblePlane *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked, FDynamicColormap *basecolormap, FTexture *texture); + void Render(VisiblePlane *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked, FDynamicColormap *basecolormap, FSoftwareTexture *texture); RenderThread *Thread = nullptr; diff --git a/src/swrenderer/plane/r_visibleplane.cpp b/src/swrenderer/plane/r_visibleplane.cpp index ac4e070796..6ba69d90c8 100644 --- a/src/swrenderer/plane/r_visibleplane.cpp +++ b/src/swrenderer/plane/r_visibleplane.cpp @@ -113,23 +113,24 @@ namespace swrenderer } else // regular flat { - FTexture *tex = TexMan(picnum, true); + FTexture *ttex = TexMan(picnum, true); - if (tex->UseType == ETextureType::Null) + if (!ttex->isValid()) { return; } + FSoftwareTexture *tex = ttex->GetSoftwareTexture(); if (!masked && !additive) { // If we're not supposed to see through this plane, draw it opaque. alpha = OPAQUE; } - else if (!tex->bMasked) + else if (!tex->isMasked()) { // Don't waste time on a masked texture if it isn't really masked. masked = false; } - double xscale = xform.xScale * tex->Scale.X; - double yscale = xform.yScale * tex->Scale.Y; + double xscale = xform.xScale * tex->GetScale().X; + double yscale = xform.yScale * tex->GetScale().Y; if (!height.isSlope() && !tilt) { diff --git a/src/swrenderer/r_renderthread.cpp b/src/swrenderer/r_renderthread.cpp index 775528d71f..ae0837e6a1 100644 --- a/src/swrenderer/r_renderthread.cpp +++ b/src/swrenderer/r_renderthread.cpp @@ -89,7 +89,7 @@ namespace swrenderer return pal_drawers.get(); } - void RenderThread::PrepareTexture(FTexture *texture, FRenderStyle style) + void RenderThread::PrepareTexture(FSoftwareTexture *texture, FRenderStyle style) { if (texture == nullptr) return; diff --git a/src/swrenderer/r_renderthread.h b/src/swrenderer/r_renderthread.h index b65713e07f..8823b59cf8 100644 --- a/src/swrenderer/r_renderthread.h +++ b/src/swrenderer/r_renderthread.h @@ -88,7 +88,7 @@ namespace swrenderer SWPixelFormatDrawers *Drawers(RenderViewport *viewport); // Make sure texture can accessed safely - void PrepareTexture(FTexture *texture, FRenderStyle style); + void PrepareTexture(FSoftwareTexture *texture, FRenderStyle style); // Setup poly object in a threadsafe manner void PreparePolyObject(subsector_t *sub); diff --git a/src/swrenderer/r_swrenderer.cpp b/src/swrenderer/r_swrenderer.cpp index f8bb68ad71..66e4b79568 100644 --- a/src/swrenderer/r_swrenderer.cpp +++ b/src/swrenderer/r_swrenderer.cpp @@ -80,12 +80,13 @@ FRenderer *CreateSWRenderer() return new FSoftwareRenderer; } -void FSoftwareRenderer::PrecacheTexture(FTexture *tex, int cache) +void FSoftwareRenderer::PrecacheTexture(FTexture *ttex, int cache) { bool isbgra = V_IsTrueColor(); - if (tex != NULL) + if (ttex != NULL) { + FSoftwareTexture *tex = ttex->GetSoftwareTexture(); if (cache & FTextureManager::HIT_Columnmode) { const FSoftwareTextureSpan *spanp; @@ -232,6 +233,7 @@ void FSoftwareRenderer::SetClearColor(int color) void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoint, double fov) { +#if 0 // This will require a complete redesign. auto renderTarget = V_IsPolyRenderer() ? PolyRenderer::Instance()->RenderTarget : mScene.MainThread()->Viewport->RenderTarget; auto &cameraViewpoint = V_IsPolyRenderer() ? PolyRenderer::Instance()->Viewpoint : mScene.MainThread()->Viewport->viewpoint; auto &cameraViewwindow = V_IsPolyRenderer() ? PolyRenderer::Instance()->Viewwindow : mScene.MainThread()->Viewport->viewwindow; @@ -310,6 +312,7 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin // Sync state back to zdoom r_viewpoint = cameraViewpoint; r_viewwindow = cameraViewwindow; +#endif } void FSoftwareRenderer::SetColormap() diff --git a/src/swrenderer/r_swscene.cpp b/src/swrenderer/r_swscene.cpp index c29e4fb673..7a3cfe2d76 100644 --- a/src/swrenderer/r_swscene.cpp +++ b/src/swrenderer/r_swscene.cpp @@ -83,15 +83,15 @@ sector_t *SWSceneDrawer::RenderView(player_t *player) FBTextureIndex = (FBTextureIndex + 1) % 2; auto &fbtex = FBTexture[FBTextureIndex]; - if (fbtex == nullptr || fbtex->SystemTexture[0] == nullptr || - fbtex->GetWidth() != screen->GetWidth() || - fbtex->GetHeight() != screen->GetHeight() || - (V_IsTrueColor() ? 1:0) != fbtex->WidthBits) + if (fbtex == nullptr || fbtex->GetSystemTexture(0) == nullptr || + fbtex->GetDisplayWidth() != screen->GetWidth() || + fbtex->GetDisplayHeight() != screen->GetHeight() || + (V_IsTrueColor() ? 1:0) != fbtex->GetColorFormat()) { // This manually constructs its own material here. fbtex.reset(); fbtex.reset(new FWrapperTexture(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor())); - fbtex->SystemTexture[0]->AllocateBuffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor() ? 4 : 1); + fbtex->GetSystemTexture(0)->AllocateBuffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor() ? 4 : 1); auto mat = FMaterial::ValidateTexture(fbtex.get(), false); mat->AddTextureLayer(PaletteTexture.get()); @@ -99,10 +99,10 @@ sector_t *SWSceneDrawer::RenderView(player_t *player) Canvas.reset(new DCanvas(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor())); } - auto buf = fbtex->SystemTexture[0]->MapBuffer(); + auto buf = fbtex->GetSystemTexture(0)->MapBuffer(); if (!buf) I_FatalError("Unable to map buffer for software rendering"); SWRenderer->RenderView(player, Canvas.get(), buf); - fbtex->SystemTexture[0]->CreateTexture(nullptr, screen->GetWidth(), screen->GetHeight(), 0, false, 0, "swbuffer"); + fbtex->GetSystemTexture(0)->CreateTexture(nullptr, screen->GetWidth(), screen->GetHeight(), 0, false, 0, "swbuffer"); auto map = swrenderer::CameraLight::Instance()->ShaderColormap(); screen->DrawTexture(fbtex.get(), 0, 0, DTA_SpecialColormap, map, TAG_DONE); diff --git a/src/swrenderer/scene/r_opaque_pass.cpp b/src/swrenderer/scene/r_opaque_pass.cpp index de6922500e..ccdfb57841 100644 --- a/src/swrenderer/scene/r_opaque_pass.cpp +++ b/src/swrenderer/scene/r_opaque_pass.cpp @@ -1024,15 +1024,15 @@ namespace swrenderer sprite.picnum = thing->picnum; sprite.tex = TexMan(sprite.picnum); - if (sprite.tex->UseType == ETextureType::Null) + if (!sprite.tex->isValid()) { return false; } - if (sprite.tex->Rotations != 0xFFFF) + if (sprite.tex->GetRotations() != 0xFFFF) { // choose a different rotation based on player view - spriteframe_t *sprframe = &SpriteFrames[sprite.tex->Rotations]; + spriteframe_t *sprframe = &SpriteFrames[sprite.tex->GetRotations()]; DAngle ang = (sprite.pos - Thread->Viewport->viewpoint.Pos).Angle(); angle_t rot; if (sprframe->Texture[0] == sprframe->Texture[1]) @@ -1096,7 +1096,7 @@ namespace swrenderer return false; } - if (sprite.voxel == nullptr && (sprite.tex == nullptr || sprite.tex->UseType == ETextureType::Null)) + if (sprite.voxel == nullptr && (sprite.tex == nullptr || !sprite.tex->isValid())) { return false; } diff --git a/src/swrenderer/things/r_decal.cpp b/src/swrenderer/things/r_decal.cpp index 1f9dbf6a74..0f2e15296a 100644 --- a/src/swrenderer/things/r_decal.cpp +++ b/src/swrenderer/things/r_decal.cpp @@ -129,13 +129,14 @@ namespace swrenderer } } - FTexture *WallSpriteTile = TexMan(decal->PicNum, true); + FTexture *tex = TexMan(decal->PicNum, true); flipx = (uint8_t)(decal->RenderFlags & RF_XFLIP); - if (WallSpriteTile == NULL || WallSpriteTile->UseType == ETextureType::Null) + if (tex == NULL || !tex->isValid()) { return; } + FSoftwareTexture *WallSpriteTile = tex->GetSoftwareTexture(); // Determine left and right edges of sprite. Since this sprite is bound // to a wall, we use the wall's angle instead of the decal's. This is @@ -333,7 +334,7 @@ namespace swrenderer } while (needrepeat--); } - void RenderDecal::DrawColumn(RenderThread *thread, SpriteDrawerArgs &drawerargs, int x, FTexture *WallSpriteTile, const ProjectedWallTexcoords &walltexcoords, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, FRenderStyle style) + void RenderDecal::DrawColumn(RenderThread *thread, SpriteDrawerArgs &drawerargs, int x, FSoftwareTexture *WallSpriteTile, const ProjectedWallTexcoords &walltexcoords, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, FRenderStyle style) { auto viewport = thread->Viewport.get(); diff --git a/src/swrenderer/things/r_decal.h b/src/swrenderer/things/r_decal.h index e617b04a6a..82eab4d8f7 100644 --- a/src/swrenderer/things/r_decal.h +++ b/src/swrenderer/things/r_decal.h @@ -16,6 +16,6 @@ namespace swrenderer private: static void Render(RenderThread *thread, side_t *wall, DBaseDecal *first, DrawSegment *clipper, int wallshade, float lightleft, float lightstep, seg_t *curline, const FWallCoords &wallC, bool foggy, FDynamicColormap *basecolormap, const short *walltop, const short *wallbottom, bool drawsegPass); - static void DrawColumn(RenderThread *thread, SpriteDrawerArgs &drawerargs, int x, FTexture *WallSpriteTile, const ProjectedWallTexcoords &walltexcoords, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, FRenderStyle style); + static void DrawColumn(RenderThread *thread, SpriteDrawerArgs &drawerargs, int x, FSoftwareTexture *WallSpriteTile, const ProjectedWallTexcoords &walltexcoords, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, FRenderStyle style); }; } diff --git a/src/swrenderer/things/r_model.cpp b/src/swrenderer/things/r_model.cpp index 611d756699..26d54f104e 100644 --- a/src/swrenderer/things/r_model.cpp +++ b/src/swrenderer/things/r_model.cpp @@ -107,7 +107,7 @@ namespace swrenderer if (lump.isValid()) { FTexture * tex = TexMan(lump); - if (tex) disablefullbright = tex->bDisableFullbright; + if (tex) disablefullbright = tex->isFullbrightDisabled(); } return psp->GetState()->GetFullbright() && !disablefullbright; } @@ -354,7 +354,7 @@ namespace swrenderer args.SetLight(GetColorTable(sector->Colormap, sector->SpecialColors[sector_t::sprites], true), lightlevel, visibility, fullbrightSprite); args.SetLights(Lights, NumLights); args.SetNormal(FVector3(0.0f, 0.0f, 0.0f)); - args.SetStyle(RenderStyle, RenderAlpha, fillcolor, Translation, SkinTexture, fullbrightSprite); + args.SetStyle(RenderStyle, RenderAlpha, fillcolor, Translation, SkinTexture->GetSoftwareTexture(), fullbrightSprite); args.SetDepthTest(true); args.SetWriteDepth(true); args.SetWriteStencil(false); @@ -371,7 +371,7 @@ namespace swrenderer args.SetLight(GetColorTable(sector->Colormap, sector->SpecialColors[sector_t::sprites], true), lightlevel, visibility, fullbrightSprite); args.SetLights(Lights, NumLights); args.SetNormal(FVector3(0.0f, 0.0f, 0.0f)); - args.SetStyle(RenderStyle, RenderAlpha, fillcolor, Translation, SkinTexture, fullbrightSprite); + args.SetStyle(RenderStyle, RenderAlpha, fillcolor, Translation, SkinTexture->GetSoftwareTexture(), fullbrightSprite); args.SetDepthTest(true); args.SetWriteDepth(true); args.SetWriteStencil(false); diff --git a/src/swrenderer/things/r_playersprite.cpp b/src/swrenderer/things/r_playersprite.cpp index a51b3b5fda..6322ef6371 100644 --- a/src/swrenderer/things/r_playersprite.cpp +++ b/src/swrenderer/things/r_playersprite.cpp @@ -226,7 +226,7 @@ namespace swrenderer flip = sprframe->Flip & 1; tex = TexMan(picnum); - if (tex->UseType == ETextureType::Null) + if (!tex->isValid()) return; if (pspr->firstTic) @@ -263,8 +263,8 @@ namespace swrenderer double pspriteyscale = pspritexscale * viewport->BaseYaspectMul * ((double)SCREENHEIGHT / SCREENWIDTH) * r_viewwindow.WidescreenRatio; double pspritexiscale = 1 / pspritexscale; - int tleft = tex->GetScaledLeftOffset(0); - int twidth = tex->GetScaledWidth(); + int tleft = tex->GetDisplayLeftOffset(); + int twidth = tex->GetDisplayWidth(); // calculate edges of the shape tx = (pspr->Flags & PSPF_MIRROR) ? ((BASEXCENTER - twidth) - (sx - tleft)) : ((sx - BASEXCENTER) - tleft); @@ -286,7 +286,8 @@ namespace swrenderer vis.renderflags = owner->renderflags; - vis.texturemid = (BASEYCENTER - sy) * tex->Scale.Y + tex->GetTopOffset(0); + FSoftwareTexture *stex = tex->GetSoftwareTexture(); + vis.texturemid = (BASEYCENTER - sy) * stex->GetScale().Y + stex->GetTopOffset(0); // Force it to use software rendering when drawing to a canvas texture. bool renderToCanvas = viewport->RenderingToCanvas; @@ -303,20 +304,20 @@ namespace swrenderer } vis.x1 = x1 < 0 ? 0 : x1; vis.x2 = x2 >= viewwidth ? viewwidth : x2; - vis.xscale = FLOAT2FIXED(pspritexscale / tex->Scale.X); - vis.yscale = float(pspriteyscale / tex->Scale.Y); - vis.pic = tex; + vis.xscale = FLOAT2FIXED(pspritexscale / stex->GetScale().X); + vis.yscale = float(pspriteyscale / stex->GetScale().Y); + vis.pic = stex; // If flip is used, provided that it's not already flipped (that would just invert itself) // (It's an XOR...) if (!(flip) != !(pspr->Flags & PSPF_FLIP)) { - vis.xiscale = -FLOAT2FIXED(pspritexiscale * tex->Scale.X); - vis.startfrac = (tex->GetWidth() << FRACBITS) - 1; + vis.xiscale = -FLOAT2FIXED(pspritexiscale * stex->GetScale().X); + vis.startfrac = (stex->GetWidth() << FRACBITS) - 1; } else { - vis.xiscale = FLOAT2FIXED(pspritexiscale * tex->Scale.X); + vis.xiscale = FLOAT2FIXED(pspritexiscale * stex->GetScale().X); vis.startfrac = 0; } @@ -455,7 +456,7 @@ namespace swrenderer { for (const HWAccelPlayerSprite &sprite : AcceleratedSprites) { - screen->DrawTexture(sprite.pic, + screen->DrawTexture(sprite.pic->GetTexture(), viewwindowx + sprite.x1, viewwindowy + viewheight / 2 - sprite.texturemid * sprite.yscale - 0.5, DTA_DestWidthF, FIXED2DBL(sprite.pic->GetWidth() * sprite.xscale), diff --git a/src/swrenderer/things/r_playersprite.h b/src/swrenderer/things/r_playersprite.h index 24e6b25f07..6b7be57c16 100644 --- a/src/swrenderer/things/r_playersprite.h +++ b/src/swrenderer/things/r_playersprite.h @@ -59,7 +59,7 @@ namespace swrenderer class HWAccelPlayerSprite { public: - FTexture *pic = nullptr; + FSoftwareTexture *pic = nullptr; double texturemid = 0.0; float yscale = 0.0f; fixed_t xscale = 0; diff --git a/src/swrenderer/things/r_sprite.cpp b/src/swrenderer/things/r_sprite.cpp index 1251860d9d..49531337a1 100644 --- a/src/swrenderer/things/r_sprite.cpp +++ b/src/swrenderer/things/r_sprite.cpp @@ -72,8 +72,9 @@ EXTERN_CVAR(Bool, gl_light_sprites) namespace swrenderer { - void RenderSprite::Project(RenderThread *thread, AActor *thing, const DVector3 &pos, FTexture *tex, const DVector2 &spriteScale, int renderflags, WaterFakeSide fakeside, F3DFloor *fakefloor, F3DFloor *fakeceiling, sector_t *current_sector, int spriteshade, bool foggy, FDynamicColormap *basecolormap) + void RenderSprite::Project(RenderThread *thread, AActor *thing, const DVector3 &pos, FTexture *ttex, const DVector2 &spriteScale, int renderflags, WaterFakeSide fakeside, F3DFloor *fakefloor, F3DFloor *fakeceiling, sector_t *current_sector, int spriteshade, bool foggy, FDynamicColormap *basecolormap) { + FSoftwareTexture *tex = ttex->GetSoftwareTexture(); // transform the origin point double tr_x = pos.X - thread->Viewport->viewpoint.Pos.X; double tr_y = pos.Y - thread->Viewport->viewpoint.Pos.Y; @@ -151,7 +152,7 @@ namespace swrenderer renderflags ^= RF_XFLIP; // calculate edges of the shape - const double thingxscalemul = spriteScale.X / tex->Scale.X; + const double thingxscalemul = spriteScale.X / tex->GetScale().X; tx -= ((renderflags & RF_XFLIP) ? (tex->GetWidth() - tex->GetLeftOffsetSW() - 1) : tex->GetLeftOffsetSW()) * thingxscalemul; double dtx1 = tx * xscale; @@ -168,10 +169,10 @@ namespace swrenderer if ((x2 < renderportal->WindowLeft || x2 <= x1)) return; - xscale = spriteScale.X * xscale / tex->Scale.X; + xscale = spriteScale.X * xscale / tex->GetScale().X; fixed_t iscale = (fixed_t)(FRACUNIT / xscale); // Round towards zero to avoid wrapping in edge cases - double yscale = spriteScale.Y / tex->Scale.Y; + double yscale = spriteScale.Y / tex->GetScale().Y; // store information in a vissprite RenderSprite *vis = thread->FrameMemory->NewObject(); @@ -309,7 +310,7 @@ namespace swrenderer auto vis = this; fixed_t frac; - FTexture *tex; + FSoftwareTexture *tex; int x2; fixed_t xiscale; diff --git a/src/swrenderer/things/r_visiblesprite.h b/src/swrenderer/things/r_visiblesprite.h index 37787a8093..01b9198d1b 100644 --- a/src/swrenderer/things/r_visiblesprite.h +++ b/src/swrenderer/things/r_visiblesprite.h @@ -55,7 +55,7 @@ namespace swrenderer virtual void Render(RenderThread *thread, short *cliptop, short *clipbottom, int minZ, int maxZ, Fake3DTranslucent clip3DFloor) = 0; - FTexture *pic = nullptr; + FSoftwareTexture *pic = nullptr; short x1 = 0, x2 = 0; float gzb = 0.0f, gzt = 0.0f; // global bottom / top for silhouette clipping diff --git a/src/swrenderer/things/r_wallsprite.cpp b/src/swrenderer/things/r_wallsprite.cpp index a9f8154251..d6cf90d228 100644 --- a/src/swrenderer/things/r_wallsprite.cpp +++ b/src/swrenderer/things/r_wallsprite.cpp @@ -71,8 +71,9 @@ EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); namespace swrenderer { - void RenderWallSprite::Project(RenderThread *thread, AActor *thing, const DVector3 &pos, FTexture *pic, const DVector2 &scale, int renderflags, int spriteshade, bool foggy, FDynamicColormap *basecolormap) + void RenderWallSprite::Project(RenderThread *thread, AActor *thing, const DVector3 &pos, FTexture *ppic, const DVector2 &scale, int renderflags, int spriteshade, bool foggy, FDynamicColormap *basecolormap) { + FSoftwareTexture *pic = ppic->GetSoftwareTexture(); FWallCoords wallc; double x1, x2; DVector2 left, right; @@ -205,7 +206,7 @@ namespace swrenderer calclighting = true; // Draw it - FTexture *WallSpriteTile = spr->pic; + auto WallSpriteTile = spr->pic; if (spr->renderflags & RF_YFLIP) { sprflipvert = true; @@ -254,7 +255,7 @@ namespace swrenderer } } - void RenderWallSprite::DrawColumn(RenderThread *thread, SpriteDrawerArgs &drawerargs, int x, FTexture *WallSpriteTile, const ProjectedWallTexcoords &walltexcoords, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, FRenderStyle style) + void RenderWallSprite::DrawColumn(RenderThread *thread, SpriteDrawerArgs &drawerargs, int x, FSoftwareTexture *WallSpriteTile, const ProjectedWallTexcoords &walltexcoords, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, FRenderStyle style) { auto viewport = thread->Viewport.get(); diff --git a/src/swrenderer/things/r_wallsprite.h b/src/swrenderer/things/r_wallsprite.h index fa127ccf45..d4851d07c1 100644 --- a/src/swrenderer/things/r_wallsprite.h +++ b/src/swrenderer/things/r_wallsprite.h @@ -17,7 +17,7 @@ namespace swrenderer void Render(RenderThread *thread, short *cliptop, short *clipbottom, int minZ, int maxZ, Fake3DTranslucent clip3DFloor) override; private: - static void DrawColumn(RenderThread *thread, SpriteDrawerArgs &drawerargs, int x, FTexture *WallSpriteTile, const ProjectedWallTexcoords &walltexcoords, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, FRenderStyle style); + static void DrawColumn(RenderThread *thread, SpriteDrawerArgs &drawerargs, int x, FSoftwareTexture *WallSpriteTile, const ProjectedWallTexcoords &walltexcoords, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, FRenderStyle style); FWallCoords wallc; uint32_t Translation = 0; diff --git a/src/swrenderer/viewport/r_skydrawer.cpp b/src/swrenderer/viewport/r_skydrawer.cpp index c134a46e2b..2bbab5abf6 100644 --- a/src/swrenderer/viewport/r_skydrawer.cpp +++ b/src/swrenderer/viewport/r_skydrawer.cpp @@ -47,7 +47,7 @@ namespace swrenderer dc_viewport = viewport; } - void SkyDrawerArgs::SetFrontTexture(RenderThread *thread, FTexture *texture, uint32_t column) + void SkyDrawerArgs::SetFrontTexture(RenderThread *thread, FSoftwareTexture *texture, uint32_t column) { if (thread->Viewport->RenderTarget->IsBgra()) { @@ -61,7 +61,7 @@ namespace swrenderer } } - void SkyDrawerArgs::SetBackTexture(RenderThread *thread, FTexture *texture, uint32_t column) + void SkyDrawerArgs::SetBackTexture(RenderThread *thread, FSoftwareTexture *texture, uint32_t column) { if (texture == nullptr) { diff --git a/src/swrenderer/viewport/r_skydrawer.h b/src/swrenderer/viewport/r_skydrawer.h index 24c7e6f080..69ff04d9b7 100644 --- a/src/swrenderer/viewport/r_skydrawer.h +++ b/src/swrenderer/viewport/r_skydrawer.h @@ -15,8 +15,8 @@ namespace swrenderer public: void SetDest(RenderViewport *viewport, int x, int y); void SetCount(int count) { dc_count = count; } - void SetFrontTexture(RenderThread *thread, FTexture *texture, uint32_t column); - void SetBackTexture(RenderThread *thread, FTexture *texture, uint32_t column); + void SetFrontTexture(RenderThread *thread, FSoftwareTexture *texture, uint32_t column); + void SetBackTexture(RenderThread *thread, FSoftwareTexture *texture, uint32_t column); void SetTextureVPos(uint32_t texturefrac) { dc_texturefrac = texturefrac; } void SetTextureVStep(uint32_t iscale) { dc_iscale = iscale; } void SetSolidTop(uint32_t color) { solid_top = color; } diff --git a/src/swrenderer/viewport/r_spandrawer.cpp b/src/swrenderer/viewport/r_spandrawer.cpp index 0c1689f14e..8c4bb26a73 100644 --- a/src/swrenderer/viewport/r_spandrawer.cpp +++ b/src/swrenderer/viewport/r_spandrawer.cpp @@ -30,14 +30,14 @@ namespace swrenderer spanfunc = &SWPixelFormatDrawers::DrawSpan; } - void SpanDrawerArgs::SetTexture(RenderThread *thread, FTexture *tex) + void SpanDrawerArgs::SetTexture(RenderThread *thread, FSoftwareTexture *tex) { thread->PrepareTexture(tex, DefaultRenderStyle()); ds_texwidth = tex->GetWidth(); ds_texheight = tex->GetHeight(); - ds_xbits = tex->WidthBits; - ds_ybits = tex->HeightBits; + ds_xbits = tex->GetWidthBits(); + ds_ybits = tex->GetHeightBits(); if ((1 << ds_xbits) > tex->GetWidth()) { ds_xbits--; diff --git a/src/swrenderer/viewport/r_spandrawer.h b/src/swrenderer/viewport/r_spandrawer.h index 3dc7c61910..b31b571b2d 100644 --- a/src/swrenderer/viewport/r_spandrawer.h +++ b/src/swrenderer/viewport/r_spandrawer.h @@ -19,7 +19,7 @@ namespace swrenderer void SetDestY(RenderViewport *viewport, int y) { ds_viewport = viewport; ds_y = y; } void SetDestX1(int x) { ds_x1 = x; } void SetDestX2(int x) { ds_x2 = x; } - void SetTexture(RenderThread *thread, FTexture *tex); + void SetTexture(RenderThread *thread, FSoftwareTexture *tex); void SetTextureLOD(double lod) { ds_lod = lod; } void SetTextureUPos(double u) { ds_xfrac = (uint32_t)(int64_t)(u * 4294967296.0); } void SetTextureVPos(double v) { ds_yfrac = (uint32_t)(int64_t)(v * 4294967296.0); } diff --git a/src/swrenderer/viewport/r_spritedrawer.cpp b/src/swrenderer/viewport/r_spritedrawer.cpp index 7eb8007c18..f53fe70b24 100644 --- a/src/swrenderer/viewport/r_spritedrawer.cpp +++ b/src/swrenderer/viewport/r_spritedrawer.cpp @@ -43,7 +43,7 @@ namespace swrenderer colfunc = &SWPixelFormatDrawers::DrawColumn; } - void SpriteDrawerArgs::DrawMaskedColumn(RenderThread *thread, int x, fixed_t iscale, FTexture *tex, fixed_t col, double spryscale, double sprtopscreen, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, FRenderStyle style, bool unmasked) + void SpriteDrawerArgs::DrawMaskedColumn(RenderThread *thread, int x, fixed_t iscale, FSoftwareTexture *tex, fixed_t col, double spryscale, double sprtopscreen, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, FRenderStyle style, bool unmasked) { if (x < thread->X1 || x >= thread->X2) return; @@ -126,7 +126,7 @@ namespace swrenderer } } - void SpriteDrawerArgs::DrawMaskedColumnBgra(RenderThread *thread, int x, fixed_t iscale, FTexture *tex, fixed_t col, double spryscale, double sprtopscreen, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, bool unmasked) + void SpriteDrawerArgs::DrawMaskedColumnBgra(RenderThread *thread, int x, fixed_t iscale, FSoftwareTexture *tex, fixed_t col, double spryscale, double sprtopscreen, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, bool unmasked) { dc_viewport = thread->Viewport.get(); dc_x = x; diff --git a/src/swrenderer/viewport/r_spritedrawer.h b/src/swrenderer/viewport/r_spritedrawer.h index f6a3aae79f..e025d5c9e6 100644 --- a/src/swrenderer/viewport/r_spritedrawer.h +++ b/src/swrenderer/viewport/r_spritedrawer.h @@ -33,7 +33,7 @@ namespace swrenderer void SetSolidColor(int color) { dc_color = color; dc_color_bgra = GPalette.BaseColors[color]; } void SetDynamicLight(uint32_t color) { dynlightcolor = color; } - void DrawMaskedColumn(RenderThread *thread, int x, fixed_t iscale, FTexture *texture, fixed_t column, double spryscale, double sprtopscreen, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, FRenderStyle style, bool unmasked = false); + void DrawMaskedColumn(RenderThread *thread, int x, fixed_t iscale, FSoftwareTexture *texture, fixed_t column, double spryscale, double sprtopscreen, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, FRenderStyle style, bool unmasked = false); void FillColumn(RenderThread *thread); void DrawVoxelBlocks(RenderThread *thread, const VoxelBlock *blocks, int blockcount); @@ -71,7 +71,7 @@ namespace swrenderer private: bool SetBlendFunc(int op, fixed_t fglevel, fixed_t bglevel, int flags); static fixed_t GetAlpha(int type, fixed_t alpha); - void DrawMaskedColumnBgra(RenderThread *thread, int x, fixed_t iscale, FTexture *tex, fixed_t column, double spryscale, double sprtopscreen, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, bool unmasked); + void DrawMaskedColumnBgra(RenderThread *thread, int x, fixed_t iscale, FSoftwareTexture *tex, fixed_t column, double spryscale, double sprtopscreen, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, bool unmasked); uint8_t *dc_dest = nullptr; int dc_dest_y = 0; diff --git a/src/textures/formats/brightmaptexture.cpp b/src/textures/formats/brightmaptexture.cpp index 7b3dae3a69..c649f3e172 100644 --- a/src/textures/formats/brightmaptexture.cpp +++ b/src/textures/formats/brightmaptexture.cpp @@ -66,9 +66,9 @@ FBrightmapTexture::FBrightmapTexture (FTexture *source) Name = ""; SourcePic = source; CopySize(source); - bNoDecals = source->bNoDecals; - Rotations = source->Rotations; - UseType = source->UseType; + bNoDecals = true; + Rotations = 0xffff; + UseType = ETextureType::Override; bMasked = false; id.SetInvalid(); SourceLump = -1; diff --git a/src/textures/texturemanager.cpp b/src/textures/texturemanager.cpp index 4080018bf3..6a64f4c6fd 100644 --- a/src/textures/texturemanager.cpp +++ b/src/textures/texturemanager.cpp @@ -1399,7 +1399,7 @@ DEFINE_ACTION_FUNCTION(_TexMan, GetName) if (tex != nullptr) { - if (tex->Name.IsNotEmpty()) retval = tex->Name; + if (tex->GetName().IsNotEmpty()) retval = tex->GetName(); else { // Textures for full path names do not have their own name, they merely link to the source lump. @@ -1423,8 +1423,8 @@ static int GetTextureSize(int texid, int *py) int x, y; if (tex != nullptr) { - x = tex->GetWidth(); - y = tex->GetHeight(); + x = tex->GetDisplayWidth(); + y = tex->GetDisplayHeight(); } else x = y = -1; if (py) *py = y; @@ -1453,8 +1453,8 @@ static void GetScaledSize(int texid, DVector2 *pvec) double x, y; if (tex != nullptr) { - x = tex->GetScaledWidthDouble(); - y = tex->GetScaledHeightDouble(); + x = tex->GetDisplayWidthDouble(); + y = tex->GetDisplayHeightDouble(); } else x = y = -1; if (pvec) @@ -1484,8 +1484,8 @@ static void GetScaledOffset(int texid, DVector2 *pvec) double x, y; if (tex != nullptr) { - x = tex->GetScaledLeftOffsetDouble(0); - y = tex->GetScaledTopOffsetDouble(0); + x = tex->GetDisplayLeftOffsetDouble(); + y = tex->GetDisplayTopOffsetDouble(); } else x = y = -1; if (pvec) diff --git a/src/textures/textures.h b/src/textures/textures.h index f02c6e23b4..1e8885ceb1 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -222,6 +222,12 @@ struct FSoftwareTextureSpan struct spriteframewithrotate; class FSerializer; +namespace OpenGLRenderer +{ + class FGLRenderState; + class FHardwareTexture; +} + // Base texture class class FTexture @@ -238,11 +244,13 @@ class FTexture friend class FSoftwareTexture; friend class FWarpTexture; friend class FMaterial; - friend class FGLRenderState; // For now this needs access to some fields in ApplyMaterial. This should be rerouted through the Material class + friend class OpenGLRenderer::FGLRenderState; // For now this needs access to some fields in ApplyMaterial. This should be rerouted through the Material class friend struct FTexCoordInfo; - friend class FHardwareTexture; + friend class OpenGLRenderer::FHardwareTexture; friend class FMultiPatchTexture; friend class FSkyBox; + friend class FBrightmapTexture; + friend class FFontChar1; friend void RecordTextureColors (FTexture *pic, uint8_t *usedcolors); @@ -275,6 +283,7 @@ public: bool isFullbrightDisabled() const { return bDisableFullbright; } bool isHardwareCanvas() const { return bHasCanvas; } // There's two here so that this can deal with software canvases in the hardware renderer later. bool isCanvas() const { return bHasCanvas; } + bool isMiscPatch() const { return UseType == ETextureType::MiscPatch; } // only used by the intermission screen to decide whether to tile the background image or not. int isWarped() const { return bWarped; } int GetRotations() const { return Rotations; } void SetRotations(int rot) { Rotations = int16_t(rot); } @@ -282,10 +291,12 @@ public: const FString &GetName() const { return Name; } bool allowNoDecals() const { return bNoDecals; } bool isScaled() const { return Scale.X != 1 || Scale.Y != 1; } + bool isMasked() const { return bMasked; } int GetSkyOffset() const { return SkyOffset; } FTextureID GetID() const { return id; } PalEntry GetSkyCapColor(bool bottom); virtual FTexture *GetRawTexture(); // for FMultiPatchTexture to override + virtual int GetSourceLump() { return SourceLump; } // needed by the scripted GetName method. void GetGlowColor(float *data); bool isGlowing() const { return bGlowing; } bool isAutoGlowing() const { return bAutoGlowing; } @@ -319,7 +330,7 @@ protected: FMaterial *Material[2] = { nullptr, nullptr }; IHardwareTexture *SystemTexture[2] = { nullptr, nullptr }; - FSoftwareTexture *SoftwareTexture; + FSoftwareTexture *SoftwareTexture = nullptr; // None of the following pointers are owned by this texture, they are all controlled by the texture manager. @@ -396,7 +407,6 @@ protected: virtual int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate=0, FCopyInfo *inf = NULL); virtual int CopyTrueColorTranslated(FBitmap *bmp, int x, int y, int rotate, PalEntry *remap, FCopyInfo *inf = NULL); virtual bool UseBasePalette(); - virtual int GetSourceLump() { return SourceLump; } virtual FTexture *GetRedirect(); virtual void Unload (); @@ -589,6 +599,11 @@ public: { return mTexture->bWorldPanning; } + + bool isMasked() + { + return mTexture->bMasked; + } bool UseBasePalette() const { return mTexture->UseBasePalette(); } int GetSkyOffset() const { return mTexture->GetSkyOffset(); } @@ -596,7 +611,10 @@ public: int GetWidth () { return mTexture->GetWidth(); } int GetHeight () { return mTexture->GetHeight(); } - + int GetWidthBits() { return mTexture->WidthBits; } + int GetHeightBits() { return mTexture->HeightBits; } + bool Mipmapped() { return mTexture->Mipmapped(); } + int GetScaledWidth () { return mTexture->GetScaledWidth(); } int GetScaledHeight () { return mTexture->GetScaledHeight(); } double GetScaledWidthDouble () { return mTexture->GetScaledWidthDouble(); } @@ -652,6 +670,11 @@ public: return mTexture->GetPixelsBgra(); } + void Unload() + { + mTexture->Unload(); + } + }; @@ -960,6 +983,11 @@ public: { return SystemTexture[slot]; } + + int GetColorFormat() const + { + return WidthBits; + } }; extern FTextureManager TexMan; diff --git a/src/v_font.cpp b/src/v_font.cpp index ea50ae4cca..b863e42564 100644 --- a/src/v_font.cpp +++ b/src/v_font.cpp @@ -402,8 +402,8 @@ FFont::FFont (const char *name, const char *nametemplate, int first, int count, if (i != 124-start || !stcfn121) charLumps[i] = pic; - int height = pic->GetScaledHeight(); - int yoffs = pic->GetScaledTopOffset(0); + int height = pic->GetDisplayHeight(); + int yoffs = pic->GetDisplayTopOffset(); if (yoffs > maxyoffs) { @@ -421,7 +421,7 @@ FFont::FFont (const char *name, const char *nametemplate, int first, int count, { if (!noTranslate) Chars[i].Pic = new FFontChar1 (charLumps[i]); else Chars[i].Pic = charLumps[i]; - Chars[i].XMove = Chars[i].Pic->GetScaledWidth(); + Chars[i].XMove = Chars[i].Pic->GetDisplayWidth(); } else { @@ -465,7 +465,7 @@ FFont::~FFont () { for (int i = 0; i < count; ++i) { - if (Chars[i].Pic != NULL && Chars[i].Pic->Name[0] == 0) + if (Chars[i].Pic != nullptr && Chars[i].Pic->GetName().IsEmpty()) { delete Chars[i].Pic; } @@ -843,8 +843,8 @@ double GetBottomAlignOffset(FFont *font, int c) FTexture *tex_zero = font->GetChar('0', &w); FTexture *texc = font->GetChar(c, &w); double offset = 0; - if (texc) offset += texc->GetScaledTopOffsetDouble(0); - if (tex_zero) offset += -tex_zero->GetScaledTopOffsetDouble(0) + tex_zero->GetScaledHeightDouble(); + if (texc) offset += texc->GetDisplayTopOffsetDouble(); + if (tex_zero) offset += -tex_zero->GetDisplayTopOffsetDouble() + tex_zero->GetDisplayHeightDouble(); return offset; } @@ -999,8 +999,8 @@ void FSingleLumpFont::CreateFontFromPic (FTextureID picnum) { FTexture *pic = TexMan[picnum]; - FontHeight = pic->GetHeight (); - SpaceWidth = pic->GetWidth (); + FontHeight = pic->GetDisplayHeight (); + SpaceWidth = pic->GetDisplayWidth (); GlobalKerning = 0; FirstChar = LastChar = 'A'; @@ -1498,8 +1498,8 @@ FSinglePicFont::FSinglePicFont(const char *picname) : FTexture *pic = TexMan[picnum]; FontName = picname; - FontHeight = pic->GetScaledHeight(); - SpaceWidth = pic->GetScaledWidth(); + FontHeight = pic->GetDisplayHeight(); + SpaceWidth = pic->GetDisplayWidth(); GlobalKerning = 0; FirstChar = LastChar = 'A'; ActiveColors = 0; @@ -1927,8 +1927,8 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, FTexture **l pic = charlumps[i] = lumplist[i]; if (pic != NULL) { - int height = pic->GetScaledHeight(); - int yoffs = pic->GetScaledTopOffset(0); + int height = pic->GetDisplayHeight(); + int yoffs = pic->GetDisplayTopOffset(); if (yoffs > maxyoffs) { @@ -1945,7 +1945,7 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, FTexture **l { if (!noTranslate) Chars[i].Pic = new FFontChar1 (charlumps[i]); else Chars[i].Pic = charlumps[i]; - Chars[i].XMove = Chars[i].Pic->GetScaledWidth(); + Chars[i].XMove = Chars[i].Pic->GetDisplayWidth(); } else { diff --git a/src/wi_stuff.cpp b/src/wi_stuff.cpp index e3e010fedc..4c3129c985 100644 --- a/src/wi_stuff.cpp +++ b/src/wi_stuff.cpp @@ -217,10 +217,10 @@ private: int bottom; - right = c[i]->GetScaledWidth(); - bottom = c[i]->GetScaledHeight(); - left = lnodes[n].x - c[i]->GetScaledLeftOffset(0); - top = lnodes[n].y - c[i]->GetScaledTopOffset(0); + right = c[i]->GetDisplayWidth(); + bottom = c[i]->GetDisplayHeight(); + left = lnodes[n].x - c[i]->GetDisplayLeftOffset(); + top = lnodes[n].y - c[i]->GetDisplayTopOffset(); right += left; bottom += top; @@ -589,13 +589,13 @@ void DInterBackground::drawBackground(int state, bool drawsplat, bool snl_pointe if (background) { // background - if (background->UseType == ETextureType::MiscPatch) + if (background->isMiscPatch()) { // scale all animations below to fit the size of the base pic // The base pic is always scaled to fit the screen so this allows // placing the animations precisely where they belong on the base pic - animwidth = background->GetScaledWidthDouble(); - animheight = background->GetScaledHeightDouble(); + animwidth = background->GetDisplayWidthDouble(); + animheight = background->GetDisplayHeightDouble(); screen->FillBorder(NULL); screen->DrawTexture(background, 0, 0, DTA_Fullscreen, true, TAG_DONE); } diff --git a/src/win32/i_system.cpp b/src/win32/i_system.cpp index 1e5c786400..6b6ce6aefd 100644 --- a/src/win32/i_system.cpp +++ b/src/win32/i_system.cpp @@ -912,10 +912,12 @@ int I_PickIWad(WadStuff *wads, int numwads, bool showwin, int defaultiwad) // //========================================================================== +// Custom cursors temporarily disabled until this can directly reference a texture's backing image. bool I_SetCursor(FTexture *cursorpic) { HCURSOR cursor; +#if 0 if (cursorpic != NULL && cursorpic->UseType != ETextureType::Null) { // Must be no larger than 32x32. @@ -939,6 +941,7 @@ bool I_SetCursor(FTexture *cursorpic) atterm(DestroyCustomCursor); } else +#endif { DestroyCustomCursor(); cursor = LoadCursor(NULL, IDC_ARROW); @@ -974,6 +977,7 @@ bool I_SetCursor(FTexture *cursorpic) static HCURSOR CreateCompatibleCursor(FTexture *cursorpic) { +#if 0 int picwidth = cursorpic->GetWidth(); int picheight = cursorpic->GetHeight(); @@ -1025,6 +1029,9 @@ static HCURSOR CreateCompatibleCursor(FTexture *cursorpic) // Create the cursor from the bitmaps. return CreateBitmapCursor(cursorpic->GetLeftOffset(0), cursorpic->GetTopOffset(0), and_mask, xor_mask); +#else + return nullptr; +#endif } //========================================================================== @@ -1037,6 +1044,7 @@ static HCURSOR CreateCompatibleCursor(FTexture *cursorpic) static HCURSOR CreateAlphaCursor(FTexture *cursorpic) { +#if 0 HDC dc; BITMAPV5HEADER bi; HBITMAP color, mono; @@ -1109,6 +1117,9 @@ static HCURSOR CreateAlphaCursor(FTexture *cursorpic) } return CreateBitmapCursor(cursorpic->GetLeftOffset(0) * scale, cursorpic->GetTopOffset(0) * scale, mono, color); +#else + return nullptr; +#endif } //==========================================================================