diff --git a/src/swrenderer/drawers/r_draw.cpp b/src/swrenderer/drawers/r_draw.cpp index 201f09abf..cbfb8e253 100644 --- a/src/swrenderer/drawers/r_draw.cpp +++ b/src/swrenderer/drawers/r_draw.cpp @@ -496,23 +496,6 @@ namespace swrenderer basecolormap = basecolormapsave; } - const uint8_t *R_GetColumn(FTexture *tex, int col) - { - int width; - - // If the texture's width isn't a power of 2, then we need to make it a - // positive offset for proper clamping. - if (col < 0 && (width = tex->GetWidth()) != (1 << tex->WidthBits)) - { - col = width + (col % width); - } - - if (r_swtruecolor) - return (const uint8_t *)tex->GetColumnBgra(col, nullptr); - else - return tex->GetColumn(col, nullptr); - } - DrawerFunc R_GetTransMaskDrawer() { if (colfunc == &SWPixelFormatDrawers::DrawAddColumn) diff --git a/src/swrenderer/scene/r_plane.cpp b/src/swrenderer/scene/r_plane.cpp index 9988ab12f..b6f1eca43 100644 --- a/src/swrenderer/scene/r_plane.cpp +++ b/src/swrenderer/scene/r_plane.cpp @@ -60,6 +60,7 @@ #include "r_data/colormaps.h" #include "swrenderer/drawers/r_draw_rgba.h" #include "gl/dynlights/gl_dynlight.h" +#include "r_walldraw.h" #ifdef _MSC_VER #pragma warning(disable:4244) @@ -155,7 +156,6 @@ static double xstepscale, ystepscale; static double basexfrac, baseyfrac; void R_DrawSinglePlane (visplane_t *, fixed_t alpha, bool additive, bool masked); -void R_DrawSkySegment(visplane_t *vis, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const uint8_t *(*getcol)(FTexture *tex, int col)); //========================================================================== // @@ -1135,7 +1135,7 @@ static void R_DrawSky (visplane_t *pl) lastskycol[x] = 0xffffffff; lastskycol_bgra[x] = 0xffffffff; } - R_DrawSkySegment (pl, (short *)pl->top, (short *)pl->bottom, swall, lwall, + R_DrawSkySegment (pl->left, pl->right, (short *)pl->top, (short *)pl->bottom, swall, lwall, frontyScale, backskytex == NULL ? R_GetOneSkyColumn : R_GetTwoSkyColumns); } else @@ -1173,7 +1173,7 @@ static void R_DrawSkyStriped (visplane_t *pl) lastskycol[x] = 0xffffffff; lastskycol_bgra[x] = 0xffffffff; } - R_DrawSkySegment (pl, top, bot, swall, lwall, rw_pic->Scale.Y, + R_DrawSkySegment (pl->left, pl->right, top, bot, swall, lwall, rw_pic->Scale.Y, backskytex == NULL ? R_GetOneSkyColumn : R_GetTwoSkyColumns); yl = yh; yh += drawheight; diff --git a/src/swrenderer/scene/r_segs.cpp b/src/swrenderer/scene/r_segs.cpp index 0348ba26c..1c90ee2a3 100644 --- a/src/swrenderer/scene/r_segs.cpp +++ b/src/swrenderer/scene/r_segs.cpp @@ -47,6 +47,7 @@ #include "swrenderer/drawers/r_draw.h" #include "v_palette.h" #include "r_data/colormaps.h" +#include "r_walldraw.h" #define WALLYREPEAT 8 @@ -60,7 +61,6 @@ namespace swrenderer { using namespace drawerargs; - void R_DrawWallSegment(FTexture *rw_pic, int x1, int x2, short *walltop, short *wallbottom, float *swall, fixed_t *lwall, double yscale, double top, double bottom, bool mask, FLightNode *light_list = nullptr); void R_DrawDrawSeg(drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat); #define HEIGHTBITS 12 diff --git a/src/swrenderer/scene/r_walldraw.cpp b/src/swrenderer/scene/r_walldraw.cpp index 0ffb3632c..1b56e9524 100644 --- a/src/swrenderer/scene/r_walldraw.cpp +++ b/src/swrenderer/scene/r_walldraw.cpp @@ -44,6 +44,7 @@ #include "r_data/colormaps.h" #include "gl/dynlights/gl_dynlight.h" #include "swrenderer/drawers/r_drawers.h" +#include "r_walldraw.h" namespace swrenderer { @@ -52,20 +53,22 @@ namespace swrenderer extern FTexture *rw_pic; extern int wallshade; -struct WallSampler +static const uint8_t *R_GetColumn(FTexture *tex, int col) { - WallSampler() { } - WallSampler(int y1, float swal, double yrepeat, fixed_t xoffset, double xmagnitude, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x)); + int width; - uint32_t uv_pos; - uint32_t uv_step; - uint32_t uv_max; + // If the texture's width isn't a power of 2, then we need to make it a + // positive offset for proper clamping. + if (col < 0 && (width = tex->GetWidth()) != (1 << tex->WidthBits)) + { + col = width + (col % width); + } - const BYTE *source; - const BYTE *source2; - uint32_t texturefracx; - uint32_t height; -}; + if (r_swtruecolor) + return (const uint8_t *)tex->GetColumnBgra(col, nullptr); + else + return tex->GetColumn(col, nullptr); +} WallSampler::WallSampler(int y1, float swal, double yrepeat, fixed_t xoffset, double xmagnitude, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x)) { @@ -596,11 +599,9 @@ void R_DrawWallSegment(FTexture *rw_pic, int x1, int x2, short *walltop, short * dc_light_list = nullptr; } -void R_DrawSkySegment(visplane_t *pl, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) +void R_DrawSkySegment(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) { - ProcessNormalWall(pl->left, pl->right, uwal, dwal, swal, lwal, yrepeat, getcol); + ProcessNormalWall(x1, x2, uwal, dwal, swal, lwal, yrepeat, getcol); } - - } \ No newline at end of file diff --git a/src/swrenderer/scene/r_walldraw.h b/src/swrenderer/scene/r_walldraw.h new file mode 100644 index 000000000..50b1545ca --- /dev/null +++ b/src/swrenderer/scene/r_walldraw.h @@ -0,0 +1,26 @@ + +#pragma once + +class FTexture; +struct FLightNode; + +namespace swrenderer +{ + struct WallSampler + { + WallSampler() { } + WallSampler(int y1, float swal, double yrepeat, fixed_t xoffset, double xmagnitude, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x)); + + uint32_t uv_pos; + uint32_t uv_step; + uint32_t uv_max; + + const BYTE *source; + const BYTE *source2; + uint32_t texturefracx; + uint32_t height; + }; + + void R_DrawWallSegment(FTexture *rw_pic, int x1, int x2, short *walltop, short *wallbottom, float *swall, fixed_t *lwall, double yscale, double top, double bottom, bool mask, FLightNode *light_list = nullptr); + void R_DrawSkySegment(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const uint8_t *(*getcol)(FTexture *tex, int col)); +}