mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-29 23:23:07 +00:00
Move Drawers function to viewport
This commit is contained in:
parent
c219969b68
commit
191438b238
8 changed files with 43 additions and 29 deletions
|
@ -13,25 +13,9 @@
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include "r_drawerargs.h"
|
#include "r_drawerargs.h"
|
||||||
#include "swrenderer/drawers/r_draw_pal.h"
|
|
||||||
#include "swrenderer/drawers/r_draw_rgba.h"
|
|
||||||
|
|
||||||
namespace swrenderer
|
namespace swrenderer
|
||||||
{
|
{
|
||||||
SWPixelFormatDrawers *DrawerArgs::Drawers()
|
|
||||||
{
|
|
||||||
if (RenderViewport::Instance()->RenderTarget->IsBgra())
|
|
||||||
{
|
|
||||||
static SWTruecolorDrawers tc_drawers;
|
|
||||||
return &tc_drawers;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
static SWPalDrawers pal_drawers;
|
|
||||||
return &pal_drawers;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrawerArgs::SetLight(FSWColormap *base_colormap, float light, int shade)
|
void DrawerArgs::SetLight(FSWColormap *base_colormap, float light, int shade)
|
||||||
{
|
{
|
||||||
mBaseColormap = base_colormap;
|
mBaseColormap = base_colormap;
|
||||||
|
|
|
@ -33,9 +33,6 @@ namespace swrenderer
|
||||||
ShadeConstants ColormapConstants() const;
|
ShadeConstants ColormapConstants() const;
|
||||||
fixed_t Light() const { return LIGHTSCALE(mLight, mShade); }
|
fixed_t Light() const { return LIGHTSCALE(mLight, mShade); }
|
||||||
|
|
||||||
protected:
|
|
||||||
static SWPixelFormatDrawers *Drawers();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FSWColormap *mBaseColormap = nullptr;
|
FSWColormap *mBaseColormap = nullptr;
|
||||||
float mLight = 0.0f;
|
float mLight = 0.0f;
|
||||||
|
|
|
@ -18,12 +18,12 @@ namespace swrenderer
|
||||||
{
|
{
|
||||||
void SkyDrawerArgs::DrawSingleSkyColumn()
|
void SkyDrawerArgs::DrawSingleSkyColumn()
|
||||||
{
|
{
|
||||||
Drawers()->DrawSingleSkyColumn(*this);
|
RenderViewport::Instance()->Drawers()->DrawSingleSkyColumn(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkyDrawerArgs::DrawDoubleSkyColumn()
|
void SkyDrawerArgs::DrawDoubleSkyColumn()
|
||||||
{
|
{
|
||||||
Drawers()->DrawDoubleSkyColumn(*this);
|
RenderViewport::Instance()->Drawers()->DrawDoubleSkyColumn(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkyDrawerArgs::SetDest(int x, int y)
|
void SkyDrawerArgs::SetDest(int x, int y)
|
||||||
|
|
|
@ -98,21 +98,21 @@ namespace swrenderer
|
||||||
|
|
||||||
void SpanDrawerArgs::DrawSpan()
|
void SpanDrawerArgs::DrawSpan()
|
||||||
{
|
{
|
||||||
(Drawers()->*spanfunc)(*this);
|
(RenderViewport::Instance()->Drawers()->*spanfunc)(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpanDrawerArgs::DrawTiltedSpan(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy, FDynamicColormap *basecolormap)
|
void SpanDrawerArgs::DrawTiltedSpan(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy, FDynamicColormap *basecolormap)
|
||||||
{
|
{
|
||||||
Drawers()->DrawTiltedSpan(*this, y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy, basecolormap);
|
RenderViewport::Instance()->Drawers()->DrawTiltedSpan(*this, y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy, basecolormap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpanDrawerArgs::DrawFogBoundaryLine(int y, int x1, int x2)
|
void SpanDrawerArgs::DrawFogBoundaryLine(int y, int x1, int x2)
|
||||||
{
|
{
|
||||||
Drawers()->DrawFogBoundaryLine(*this, y, x1, x2);
|
RenderViewport::Instance()->Drawers()->DrawFogBoundaryLine(*this, y, x1, x2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpanDrawerArgs::DrawColoredSpan(int y, int x1, int x2)
|
void SpanDrawerArgs::DrawColoredSpan(int y, int x1, int x2)
|
||||||
{
|
{
|
||||||
Drawers()->DrawColoredSpan(*this, y, x1, x2);
|
RenderViewport::Instance()->Drawers()->DrawColoredSpan(*this, y, x1, x2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ namespace swrenderer
|
||||||
else if (dc_iscale < 0)
|
else if (dc_iscale < 0)
|
||||||
dc_count = MIN(dc_count, (dc_texturefrac - dc_iscale) / (-dc_iscale));
|
dc_count = MIN(dc_count, (dc_texturefrac - dc_iscale) / (-dc_iscale));
|
||||||
|
|
||||||
(Drawers()->*colfunc)(*this);
|
(RenderViewport::Instance()->Drawers()->*colfunc)(*this);
|
||||||
}
|
}
|
||||||
span++;
|
span++;
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ namespace swrenderer
|
||||||
double v = ((dc_yl + 0.5 - sprtopscreen) / spryscale) / tex->GetHeight();
|
double v = ((dc_yl + 0.5 - sprtopscreen) / spryscale) / tex->GetHeight();
|
||||||
dc_texturefrac = (uint32_t)(v * (1 << 30));
|
dc_texturefrac = (uint32_t)(v * (1 << 30));
|
||||||
|
|
||||||
(Drawers()->*colfunc)(*this);
|
(RenderViewport::Instance()->Drawers()->*colfunc)(*this);
|
||||||
}
|
}
|
||||||
span++;
|
span++;
|
||||||
}
|
}
|
||||||
|
@ -490,7 +490,7 @@ namespace swrenderer
|
||||||
|
|
||||||
void SpriteDrawerArgs::FillColumn()
|
void SpriteDrawerArgs::FillColumn()
|
||||||
{
|
{
|
||||||
Drawers()->FillColumn(*this);
|
RenderViewport::Instance()->Drawers()->FillColumn(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpriteDrawerArgs::SetDest(int x, int y)
|
void SpriteDrawerArgs::SetDest(int x, int y)
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
#include "swrenderer/drawers/r_draw.h"
|
#include "swrenderer/drawers/r_draw.h"
|
||||||
#include "swrenderer/things/r_playersprite.h"
|
#include "swrenderer/things/r_playersprite.h"
|
||||||
#include "swrenderer/plane/r_flatplane.h"
|
#include "swrenderer/plane/r_flatplane.h"
|
||||||
|
#include "swrenderer/drawers/r_draw_pal.h"
|
||||||
|
#include "swrenderer/drawers/r_draw_rgba.h"
|
||||||
|
|
||||||
CVAR(String, r_viewsize, "", CVAR_NOSET)
|
CVAR(String, r_viewsize, "", CVAR_NOSET)
|
||||||
|
|
||||||
|
@ -44,6 +46,24 @@ namespace swrenderer
|
||||||
return &instance;
|
return &instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RenderViewport::RenderViewport()
|
||||||
|
{
|
||||||
|
tc_drawers = std::make_unique<SWTruecolorDrawers>();
|
||||||
|
pal_drawers = std::make_unique<SWPalDrawers>();
|
||||||
|
}
|
||||||
|
|
||||||
|
RenderViewport::~RenderViewport()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
SWPixelFormatDrawers *RenderViewport::Drawers()
|
||||||
|
{
|
||||||
|
if (RenderTarget->IsBgra())
|
||||||
|
return tc_drawers.get();
|
||||||
|
else
|
||||||
|
return pal_drawers.get();
|
||||||
|
}
|
||||||
|
|
||||||
void RenderViewport::SetViewport(int fullWidth, int fullHeight, float trueratio)
|
void RenderViewport::SetViewport(int fullWidth, int fullHeight, float trueratio)
|
||||||
{
|
{
|
||||||
int virtheight, virtwidth, virtwidth2, virtheight2;
|
int virtheight, virtwidth, virtwidth2, virtheight2;
|
||||||
|
|
|
@ -14,15 +14,23 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <memory>
|
||||||
#include "r_defs.h"
|
#include "r_defs.h"
|
||||||
|
|
||||||
namespace swrenderer
|
namespace swrenderer
|
||||||
{
|
{
|
||||||
|
class SWPixelFormatDrawers;
|
||||||
|
class SWTruecolorDrawers;
|
||||||
|
class SWPalDrawers;
|
||||||
|
|
||||||
class RenderViewport
|
class RenderViewport
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static RenderViewport *Instance();
|
static RenderViewport *Instance();
|
||||||
|
|
||||||
|
RenderViewport();
|
||||||
|
~RenderViewport();
|
||||||
|
|
||||||
void SetViewport(int width, int height, float trueratio);
|
void SetViewport(int width, int height, float trueratio);
|
||||||
void SetupFreelook();
|
void SetupFreelook();
|
||||||
|
|
||||||
|
@ -55,10 +63,15 @@ namespace swrenderer
|
||||||
DVector2 PointWorldToView(const DVector2 &worldPos) const;
|
DVector2 PointWorldToView(const DVector2 &worldPos) const;
|
||||||
DVector2 ScaleViewToScreen(const DVector2 &scale, double viewZ, bool pixelstretch = true) const;
|
DVector2 ScaleViewToScreen(const DVector2 &scale, double viewZ, bool pixelstretch = true) const;
|
||||||
|
|
||||||
|
SWPixelFormatDrawers *Drawers();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InitTextureMapping();
|
void InitTextureMapping();
|
||||||
void SetupBuffer();
|
void SetupBuffer();
|
||||||
|
|
||||||
double BaseYaspectMul = 0.0; // yaspectmul without a forced aspect ratio
|
double BaseYaspectMul = 0.0; // yaspectmul without a forced aspect ratio
|
||||||
|
|
||||||
|
std::unique_ptr<SWTruecolorDrawers> tc_drawers;
|
||||||
|
std::unique_ptr<SWPalDrawers> pal_drawers;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace swrenderer
|
||||||
|
|
||||||
void WallDrawerArgs::DrawColumn()
|
void WallDrawerArgs::DrawColumn()
|
||||||
{
|
{
|
||||||
(Drawers()->*wallfunc)(*this);
|
(RenderViewport::Instance()->Drawers()->*wallfunc)(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WallDrawerArgs::SetStyle(bool masked, bool additive, fixed_t alpha)
|
void WallDrawerArgs::SetStyle(bool masked, bool additive, fixed_t alpha)
|
||||||
|
|
Loading…
Reference in a new issue