Move R_GetColumn to walldraw and create header file

This commit is contained in:
Magnus Norddahl 2016-12-28 01:35:22 +01:00
parent f8010854c3
commit 259d724106
5 changed files with 46 additions and 36 deletions

View file

@ -496,23 +496,6 @@ namespace swrenderer
basecolormap = basecolormapsave; 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() DrawerFunc R_GetTransMaskDrawer()
{ {
if (colfunc == &SWPixelFormatDrawers::DrawAddColumn) if (colfunc == &SWPixelFormatDrawers::DrawAddColumn)

View file

@ -60,6 +60,7 @@
#include "r_data/colormaps.h" #include "r_data/colormaps.h"
#include "swrenderer/drawers/r_draw_rgba.h" #include "swrenderer/drawers/r_draw_rgba.h"
#include "gl/dynlights/gl_dynlight.h" #include "gl/dynlights/gl_dynlight.h"
#include "r_walldraw.h"
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable:4244) #pragma warning(disable:4244)
@ -155,7 +156,6 @@ static double xstepscale, ystepscale;
static double basexfrac, baseyfrac; static double basexfrac, baseyfrac;
void R_DrawSinglePlane (visplane_t *, fixed_t alpha, bool additive, bool masked); 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[x] = 0xffffffff;
lastskycol_bgra[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); frontyScale, backskytex == NULL ? R_GetOneSkyColumn : R_GetTwoSkyColumns);
} }
else else
@ -1173,7 +1173,7 @@ static void R_DrawSkyStriped (visplane_t *pl)
lastskycol[x] = 0xffffffff; lastskycol[x] = 0xffffffff;
lastskycol_bgra[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); backskytex == NULL ? R_GetOneSkyColumn : R_GetTwoSkyColumns);
yl = yh; yl = yh;
yh += drawheight; yh += drawheight;

View file

@ -47,6 +47,7 @@
#include "swrenderer/drawers/r_draw.h" #include "swrenderer/drawers/r_draw.h"
#include "v_palette.h" #include "v_palette.h"
#include "r_data/colormaps.h" #include "r_data/colormaps.h"
#include "r_walldraw.h"
#define WALLYREPEAT 8 #define WALLYREPEAT 8
@ -60,7 +61,6 @@ namespace swrenderer
{ {
using namespace drawerargs; 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); void R_DrawDrawSeg(drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat);
#define HEIGHTBITS 12 #define HEIGHTBITS 12

View file

@ -44,6 +44,7 @@
#include "r_data/colormaps.h" #include "r_data/colormaps.h"
#include "gl/dynlights/gl_dynlight.h" #include "gl/dynlights/gl_dynlight.h"
#include "swrenderer/drawers/r_drawers.h" #include "swrenderer/drawers/r_drawers.h"
#include "r_walldraw.h"
namespace swrenderer namespace swrenderer
{ {
@ -52,20 +53,22 @@ namespace swrenderer
extern FTexture *rw_pic; extern FTexture *rw_pic;
extern int wallshade; extern int wallshade;
struct WallSampler static const uint8_t *R_GetColumn(FTexture *tex, int col)
{ {
WallSampler() { } int width;
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; // If the texture's width isn't a power of 2, then we need to make it a
uint32_t uv_step; // positive offset for proper clamping.
uint32_t uv_max; if (col < 0 && (width = tex->GetWidth()) != (1 << tex->WidthBits))
{
col = width + (col % width);
}
const BYTE *source; if (r_swtruecolor)
const BYTE *source2; return (const uint8_t *)tex->GetColumnBgra(col, nullptr);
uint32_t texturefracx; else
uint32_t height; 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)) 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; 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);
} }
} }

View file

@ -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));
}