mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 15:22:15 +00:00
Move viewport drawing to its own folder
This commit is contained in:
parent
d8c6f9acfd
commit
e90b73539e
48 changed files with 759 additions and 631 deletions
|
@ -807,6 +807,7 @@ file( GLOB HEADER_FILES
|
|||
swrenderer/line/*.h
|
||||
swrenderer/plane/*.h
|
||||
swrenderer/things/*.h
|
||||
swrenderer/viewport/*.h
|
||||
polyrenderer/*.h
|
||||
polyrenderer/math/*.h
|
||||
polyrenderer/drawers/*.h
|
||||
|
@ -850,7 +851,6 @@ set( FASTMATH_PCH_SOURCES
|
|||
swrenderer/drawers/r_draw.cpp
|
||||
swrenderer/drawers/r_draw_pal.cpp
|
||||
swrenderer/drawers/r_draw_rgba.cpp
|
||||
swrenderer/drawers/r_drawerargs.cpp
|
||||
swrenderer/drawers/r_drawers.cpp
|
||||
swrenderer/drawers/r_thread.cpp
|
||||
swrenderer/scene/r_3dfloors.cpp
|
||||
|
@ -859,7 +859,12 @@ set( FASTMATH_PCH_SOURCES
|
|||
swrenderer/scene/r_portal.cpp
|
||||
swrenderer/scene/r_scene.cpp
|
||||
swrenderer/scene/r_translucent_pass.cpp
|
||||
swrenderer/scene/r_viewport.cpp
|
||||
swrenderer/viewport/r_drawerargs.cpp
|
||||
swrenderer/viewport/r_skydrawer.cpp
|
||||
swrenderer/viewport/r_spandrawer.cpp
|
||||
swrenderer/viewport/r_spritedrawer.cpp
|
||||
swrenderer/viewport/r_viewport.cpp
|
||||
swrenderer/viewport/r_walldrawer.cpp
|
||||
swrenderer/line/r_line.cpp
|
||||
swrenderer/line/r_walldraw.cpp
|
||||
swrenderer/line/r_wallsetup.cpp
|
||||
|
@ -1506,6 +1511,7 @@ source_group("Software Renderer\\Segments" REGULAR_EXPRESSION "^${CMAKE_CURRENT_
|
|||
source_group("Software Renderer\\Line" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/swrenderer/line/.+")
|
||||
source_group("Software Renderer\\Plane" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/swrenderer/plane/.+")
|
||||
source_group("Software Renderer\\Things" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/swrenderer/things/.+")
|
||||
source_group("Software Renderer\\Viewport" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/swrenderer/viewport/.+")
|
||||
source_group("Poly Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/polyrenderer/.+")
|
||||
source_group("Poly Renderer\\Math" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/polyrenderer/math/.+")
|
||||
source_group("Poly Renderer\\Drawers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/polyrenderer/drawers/.+")
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include "tri_matrix.h"
|
||||
#include "polyrenderer/drawers/poly_triangle.h"
|
||||
#include "swrenderer/drawers/r_draw_rgba.h"
|
||||
#include "swrenderer/scene/r_viewport.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
|
||||
TriMatrix TriMatrix::null()
|
||||
{
|
||||
|
|
|
@ -33,9 +33,9 @@
|
|||
#include "po_man.h"
|
||||
#include "st_stuff.h"
|
||||
#include "swrenderer/scene/r_scene.h"
|
||||
#include "swrenderer/scene/r_viewport.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
#include "swrenderer/drawers/r_draw_rgba.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
|
||||
EXTERN_CVAR(Bool, r_shadercolormaps)
|
||||
EXTERN_CVAR(Int, screenblocks)
|
||||
|
|
|
@ -50,7 +50,6 @@
|
|||
#include "r_draw_rgba.h"
|
||||
#include "r_draw_pal.h"
|
||||
#include "r_thread.h"
|
||||
#include "r_drawerargs.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
|
||||
CVAR(Bool, r_dynlights, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
#include "r_draw.h"
|
||||
#include "v_video.h"
|
||||
#include "r_draw_pal.h"
|
||||
#include "swrenderer/scene/r_viewport.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
|
||||
// [SP] r_blendmethod - false = rgb555 matching (ZDoom classic), true = rgb666 (refactored)
|
||||
|
|
|
@ -4,7 +4,10 @@
|
|||
#include "r_draw.h"
|
||||
#include "v_palette.h"
|
||||
#include "r_thread.h"
|
||||
#include "r_drawerargs.h"
|
||||
#include "swrenderer/viewport/r_skydrawer.h"
|
||||
#include "swrenderer/viewport/r_spandrawer.h"
|
||||
#include "swrenderer/viewport/r_walldrawer.h"
|
||||
#include "swrenderer/viewport/r_spritedrawer.h"
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include "r_draw_rgba.h"
|
||||
#include "r_drawers.h"
|
||||
#include "gl/data/gl_matrix.h"
|
||||
#include "swrenderer/scene/r_viewport.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
|
||||
#include "gi.h"
|
||||
|
|
|
@ -26,7 +26,10 @@
|
|||
#include "v_palette.h"
|
||||
#include "r_thread.h"
|
||||
#include "r_drawers.h"
|
||||
#include "r_drawerargs.h"
|
||||
#include "swrenderer/viewport/r_skydrawer.h"
|
||||
#include "swrenderer/viewport/r_spandrawer.h"
|
||||
#include "swrenderer/viewport/r_walldrawer.h"
|
||||
#include "swrenderer/viewport/r_spritedrawer.h"
|
||||
|
||||
#ifdef __arm__
|
||||
#define NO_SSE
|
||||
|
|
|
@ -1,317 +0,0 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "templates.h"
|
||||
#include "doomtype.h"
|
||||
#include "doomdef.h"
|
||||
#include "r_defs.h"
|
||||
#include "r_draw.h"
|
||||
#include "v_video.h"
|
||||
#include "r_data/colormaps.h"
|
||||
#include "r_data/r_translate.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
|
||||
struct FSWColormap;
|
||||
struct FLightNode;
|
||||
struct TriLight;
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
class SWPixelFormatDrawers;
|
||||
class DrawerArgs;
|
||||
struct ShadeConstants;
|
||||
|
||||
class DrawerArgs
|
||||
{
|
||||
public:
|
||||
void SetLight(FSWColormap *base_colormap, float light, int shade);
|
||||
void SetTranslationMap(lighttable_t *translation);
|
||||
|
||||
uint8_t *Colormap() const;
|
||||
uint8_t *TranslationMap() const { return mTranslation; }
|
||||
|
||||
ShadeConstants ColormapConstants() const;
|
||||
fixed_t Light() const { return LIGHTSCALE(mLight, mShade); }
|
||||
|
||||
protected:
|
||||
static SWPixelFormatDrawers *Drawers();
|
||||
|
||||
private:
|
||||
FSWColormap *mBaseColormap = nullptr;
|
||||
float mLight = 0.0f;
|
||||
int mShade = 0;
|
||||
uint8_t *mTranslation = nullptr;
|
||||
};
|
||||
|
||||
class SkyDrawerArgs : public DrawerArgs
|
||||
{
|
||||
public:
|
||||
void SetDest(int x, int y);
|
||||
void SetCount(int count) { dc_count = count; }
|
||||
void SetFrontTexture(FTexture *texture, uint32_t column);
|
||||
void SetBackTexture(FTexture *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; }
|
||||
void SetSolidBottom(uint32_t color) { solid_bottom = color; }
|
||||
void SetFadeSky(bool enable) { fadeSky = enable; }
|
||||
|
||||
uint8_t *Dest() const { return dc_dest; }
|
||||
int DestY() const { return dc_dest_y; }
|
||||
int Count() const { return dc_count; }
|
||||
|
||||
uint32_t TextureVPos() const { return dc_texturefrac; }
|
||||
uint32_t TextureVStep() const { return dc_iscale; }
|
||||
|
||||
uint32_t SolidTopColor() const { return solid_top; }
|
||||
uint32_t SolidBottomColor() const { return solid_bottom; }
|
||||
bool FadeSky() const { return fadeSky; }
|
||||
|
||||
const uint8_t *FrontTexturePixels() const { return dc_source; }
|
||||
const uint8_t *BackTexturePixels() const { return dc_source2; }
|
||||
int FrontTextureHeight() const { return dc_sourceheight; }
|
||||
int BackTextureHeight() const { return dc_sourceheight2; }
|
||||
|
||||
void DrawSingleSkyColumn();
|
||||
void DrawDoubleSkyColumn();
|
||||
|
||||
private:
|
||||
uint8_t *dc_dest = nullptr;
|
||||
int dc_dest_y = 0;
|
||||
int dc_count = 0;
|
||||
const uint8_t *dc_source;
|
||||
const uint8_t *dc_source2;
|
||||
uint32_t dc_sourceheight;
|
||||
uint32_t dc_sourceheight2;
|
||||
uint32_t dc_texturefrac;
|
||||
uint32_t dc_iscale;
|
||||
uint32_t solid_top;
|
||||
uint32_t solid_bottom;
|
||||
bool fadeSky;
|
||||
};
|
||||
|
||||
class SpanDrawerArgs : public DrawerArgs
|
||||
{
|
||||
public:
|
||||
SpanDrawerArgs();
|
||||
|
||||
void SetStyle(bool masked, bool additive, fixed_t alpha);
|
||||
void SetDestY(int y) { ds_y = y; }
|
||||
void SetDestX1(int x) { ds_x1 = x; }
|
||||
void SetDestX2(int x) { ds_x2 = x; }
|
||||
void SetTexture(FTexture *tex);
|
||||
void SetTextureLOD(double lod) { ds_lod = lod; }
|
||||
void SetTextureUPos(dsfixed_t xfrac) { ds_xfrac = xfrac; }
|
||||
void SetTextureVPos(dsfixed_t yfrac) { ds_yfrac = yfrac; }
|
||||
void SetTextureUStep(dsfixed_t xstep) { ds_xstep = xstep; }
|
||||
void SetTextureVStep(dsfixed_t vstep) { ds_ystep = vstep; }
|
||||
void SetSolidColor(int colorIndex) { ds_color = colorIndex; }
|
||||
|
||||
void DrawSpan();
|
||||
void 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 DrawColoredSpan(int y, int x1, int x2);
|
||||
void DrawFogBoundaryLine(int y, int x1, int x2);
|
||||
|
||||
uint32_t *SrcBlend() const { return dc_srcblend; }
|
||||
uint32_t *DestBlend() const { return dc_destblend; }
|
||||
fixed_t SrcAlpha() const { return dc_srcalpha; }
|
||||
fixed_t DestAlpha() const { return dc_destalpha; }
|
||||
int DestY() const { return ds_y; }
|
||||
int DestX1() const { return ds_x1; }
|
||||
int DestX2() const { return ds_x2; }
|
||||
dsfixed_t TextureUPos() const { return ds_xfrac; }
|
||||
dsfixed_t TextureVPos() const { return ds_yfrac; }
|
||||
dsfixed_t TextureUStep() const { return ds_xstep; }
|
||||
dsfixed_t TextureVStep() const { return ds_ystep; }
|
||||
int SolidColor() const { return ds_color; }
|
||||
int TextureWidthBits() const { return ds_xbits; }
|
||||
int TextureHeightBits() const { return ds_ybits; }
|
||||
const uint8_t *TexturePixels() const { return ds_source; }
|
||||
bool MipmappedTexture() const { return ds_source_mipmapped; }
|
||||
double TextureLOD() const { return ds_lod; }
|
||||
|
||||
FVector3 dc_normal;
|
||||
FVector3 dc_viewpos;
|
||||
FVector3 dc_viewpos_step;
|
||||
TriLight *dc_lights = nullptr;
|
||||
int dc_num_lights = 0;
|
||||
|
||||
private:
|
||||
typedef void(SWPixelFormatDrawers::*SpanDrawerFunc)(const SpanDrawerArgs &args);
|
||||
SpanDrawerFunc spanfunc;
|
||||
|
||||
int ds_y;
|
||||
int ds_x1;
|
||||
int ds_x2;
|
||||
int ds_xbits;
|
||||
int ds_ybits;
|
||||
const uint8_t *ds_source;
|
||||
bool ds_source_mipmapped;
|
||||
dsfixed_t ds_xfrac;
|
||||
dsfixed_t ds_yfrac;
|
||||
dsfixed_t ds_xstep;
|
||||
dsfixed_t ds_ystep;
|
||||
uint32_t *dc_srcblend;
|
||||
uint32_t *dc_destblend;
|
||||
fixed_t dc_srcalpha;
|
||||
fixed_t dc_destalpha;
|
||||
int ds_color = 0;
|
||||
double ds_lod;
|
||||
};
|
||||
|
||||
class WallDrawerArgs : public DrawerArgs
|
||||
{
|
||||
public:
|
||||
void SetStyle(bool masked, bool additive, fixed_t alpha);
|
||||
void SetDest(int x, int y);
|
||||
void SetCount(int count) { dc_count = count; }
|
||||
void SetTexture(const uint8_t *pixels, const uint8_t *pixels2, int height)
|
||||
{
|
||||
dc_source = pixels;
|
||||
dc_source2 = pixels2;
|
||||
dc_textureheight = height;
|
||||
}
|
||||
void SetTextureFracBits(int bits) { dc_wall_fracbits = bits; }
|
||||
void SetTextureUPos(uint32_t pos) { dc_texturefracx = pos; }
|
||||
void SetTextureVPos(fixed_t pos) { dc_texturefrac = pos; }
|
||||
void SetTextureVStep(fixed_t step) { dc_iscale = step; }
|
||||
|
||||
bool IsMaskedDrawer() const;
|
||||
|
||||
void DrawColumn();
|
||||
|
||||
uint8_t *Dest() const { return dc_dest; }
|
||||
int DestY() const { return dc_dest_y; }
|
||||
int Count() const { return dc_count; }
|
||||
|
||||
uint32_t *SrcBlend() const { return dc_srcblend; }
|
||||
uint32_t *DestBlend() const { return dc_destblend; }
|
||||
fixed_t SrcAlpha() const { return dc_srcalpha; }
|
||||
fixed_t DestAlpha() const { return dc_destalpha; }
|
||||
|
||||
uint32_t TextureUPos() const { return dc_texturefracx; }
|
||||
fixed_t TextureVPos() const { return dc_texturefrac; }
|
||||
fixed_t TextureVStep() const { return dc_iscale; }
|
||||
|
||||
const uint8_t *TexturePixels() const { return dc_source; }
|
||||
const uint8_t *TexturePixels2() const { return dc_source2; }
|
||||
uint32_t TextureHeight() const { return dc_textureheight; }
|
||||
|
||||
int TextureFracBits() const { return dc_wall_fracbits; }
|
||||
|
||||
FVector3 dc_normal;
|
||||
FVector3 dc_viewpos;
|
||||
FVector3 dc_viewpos_step;
|
||||
TriLight *dc_lights = nullptr;
|
||||
int dc_num_lights = 0;
|
||||
|
||||
private:
|
||||
uint8_t *dc_dest = nullptr;
|
||||
int dc_dest_y = 0;
|
||||
int dc_count;
|
||||
|
||||
fixed_t dc_iscale;
|
||||
fixed_t dc_texturefrac;
|
||||
uint32_t dc_texturefracx;
|
||||
uint32_t dc_textureheight;
|
||||
const uint8_t *dc_source;
|
||||
const uint8_t *dc_source2;
|
||||
int dc_wall_fracbits;
|
||||
|
||||
uint32_t *dc_srcblend;
|
||||
uint32_t *dc_destblend;
|
||||
fixed_t dc_srcalpha;
|
||||
fixed_t dc_destalpha;
|
||||
|
||||
typedef void(SWPixelFormatDrawers::*WallDrawerFunc)(const WallDrawerArgs &args);
|
||||
WallDrawerFunc wallfunc = nullptr;
|
||||
};
|
||||
|
||||
class SpriteDrawerArgs : public DrawerArgs
|
||||
{
|
||||
public:
|
||||
SpriteDrawerArgs();
|
||||
|
||||
bool SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap, fixed_t shadedlightshade = 0);
|
||||
bool SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap, fixed_t shadedlightshade = 0);
|
||||
void SetDest(int x, int y);
|
||||
void SetCount(int count) { dc_count = count; }
|
||||
void SetSolidColor(int color) { dc_color = color; }
|
||||
|
||||
void DrawMaskedColumn(int x, fixed_t iscale, FTexture *texture, fixed_t column, double spryscale, double sprtopscreen, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, bool unmasked = false);
|
||||
void FillColumn();
|
||||
|
||||
uint8_t *Dest() const { return dc_dest; }
|
||||
int DestY() const { return dc_dest_y; }
|
||||
int Count() const { return dc_count; }
|
||||
|
||||
int FuzzX() const { return dc_x; }
|
||||
int FuzzY1() const { return dc_yl; }
|
||||
int FuzzY2() const { return dc_yh; }
|
||||
|
||||
uint32_t TextureUPos() const { return dc_texturefracx; }
|
||||
fixed_t TextureVPos() const { return dc_texturefrac; }
|
||||
fixed_t TextureVStep() const { return dc_iscale; }
|
||||
|
||||
int SolidColor() const { return dc_color; }
|
||||
uint32_t SrcColorIndex() const { return dc_srccolor; }
|
||||
uint32_t SrcColorBgra() const { return dc_srccolor_bgra; }
|
||||
|
||||
const uint8_t *TexturePixels() const { return dc_source; }
|
||||
const uint8_t *TexturePixels2() const { return dc_source2; }
|
||||
uint32_t TextureHeight() const { return dc_textureheight; }
|
||||
|
||||
uint32_t *SrcBlend() const { return dc_srcblend; }
|
||||
uint32_t *DestBlend() const { return dc_destblend; }
|
||||
fixed_t SrcAlpha() const { return dc_srcalpha; }
|
||||
fixed_t DestAlpha() const { return dc_destalpha; }
|
||||
|
||||
private:
|
||||
bool SetBlendFunc(int op, fixed_t fglevel, fixed_t bglevel, int flags);
|
||||
static fixed_t GetAlpha(int type, fixed_t alpha);
|
||||
void DrawMaskedColumnBgra(int x, fixed_t iscale, FTexture *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;
|
||||
int dc_count = 0;
|
||||
|
||||
fixed_t dc_iscale;
|
||||
fixed_t dc_texturefrac;
|
||||
uint32_t dc_texturefracx;
|
||||
|
||||
uint32_t dc_textureheight = 0;
|
||||
const uint8_t *dc_source = nullptr;
|
||||
const uint8_t *dc_source2 = nullptr;
|
||||
bool drawer_needs_pal_input = false;
|
||||
|
||||
uint32_t *dc_srcblend = nullptr;
|
||||
uint32_t *dc_destblend = nullptr;
|
||||
fixed_t dc_srcalpha = OPAQUE;
|
||||
fixed_t dc_destalpha = 0;
|
||||
|
||||
int dc_x = 0;
|
||||
int dc_yl = 0;
|
||||
int dc_yh = 0;
|
||||
|
||||
int dc_color = 0;
|
||||
uint32_t dc_srccolor = 0;
|
||||
uint32_t dc_srccolor_bgra = 0;
|
||||
|
||||
typedef void(SWPixelFormatDrawers::*SpriteDrawerFunc)(const SpriteDrawerArgs &args);
|
||||
SpriteDrawerFunc colfunc;
|
||||
};
|
||||
|
||||
struct ShadeConstants
|
||||
{
|
||||
uint16_t light_alpha;
|
||||
uint16_t light_red;
|
||||
uint16_t light_green;
|
||||
uint16_t light_blue;
|
||||
uint16_t fade_alpha;
|
||||
uint16_t fade_red;
|
||||
uint16_t fade_green;
|
||||
uint16_t fade_blue;
|
||||
uint16_t desaturate;
|
||||
bool simple_shade;
|
||||
};
|
||||
}
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "swrenderer/drawers/r_draw.h"
|
||||
#include "swrenderer/viewport/r_spandrawer.h"
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
|
|
|
@ -40,7 +40,8 @@
|
|||
#include "swrenderer/segments/r_drawsegment.h"
|
||||
#include "swrenderer/things/r_visiblesprite.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
#include "swrenderer/scene/r_viewport.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
#include "swrenderer/viewport/r_spritedrawer.h"
|
||||
|
||||
EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor);
|
||||
|
||||
|
|
|
@ -36,8 +36,8 @@
|
|||
#include "swrenderer/scene/r_3dfloors.h"
|
||||
#include "swrenderer/scene/r_portal.h"
|
||||
#include "swrenderer/scene/r_scene.h"
|
||||
#include "swrenderer/scene/r_viewport.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
#include "swrenderer/line/r_walldraw.h"
|
||||
#include "swrenderer/line/r_wallsetup.h"
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "swrenderer/drawers/r_drawerargs.h"
|
||||
#include "swrenderer/viewport/r_walldrawer.h"
|
||||
#include "r_line.h"
|
||||
|
||||
class FTexture;
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
#include "swrenderer/r_memory.h"
|
||||
#include "swrenderer/line/r_line.h"
|
||||
#include "swrenderer/scene/r_scene.h"
|
||||
#include "swrenderer/scene/r_viewport.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
|
|
|
@ -37,9 +37,9 @@
|
|||
#include "swrenderer/segments/r_drawsegment.h"
|
||||
#include "swrenderer/scene/r_portal.h"
|
||||
#include "swrenderer/scene/r_scene.h"
|
||||
#include "swrenderer/scene/r_viewport.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
#include "swrenderer/plane/r_visibleplane.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
#include "swrenderer/r_memory.h"
|
||||
|
||||
namespace swrenderer
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "r_planerenderer.h"
|
||||
#include "swrenderer/drawers/r_drawerargs.h"
|
||||
#include "swrenderer/viewport/r_spandrawer.h"
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
|
|
|
@ -39,8 +39,8 @@
|
|||
#include "swrenderer/line/r_walldraw.h"
|
||||
#include "swrenderer/scene/r_portal.h"
|
||||
#include "swrenderer/scene/r_scene.h"
|
||||
#include "swrenderer/scene/r_viewport.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
#include "swrenderer/r_memory.h"
|
||||
#include "g_levellocals.h"
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "r_visibleplane.h"
|
||||
#include "swrenderer/drawers/r_drawerargs.h"
|
||||
#include "swrenderer/viewport/r_skydrawer.h"
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
|
|
|
@ -37,8 +37,8 @@
|
|||
#include "swrenderer/segments/r_drawsegment.h"
|
||||
#include "swrenderer/scene/r_portal.h"
|
||||
#include "swrenderer/scene/r_scene.h"
|
||||
#include "swrenderer/scene/r_viewport.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
#include "swrenderer/r_memory.h"
|
||||
#include "swrenderer/plane/r_visibleplane.h"
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "r_planerenderer.h"
|
||||
#include "swrenderer/drawers/r_drawerargs.h"
|
||||
#include "swrenderer/viewport/r_spandrawer.h"
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include "swrenderer/scene/r_3dfloors.h"
|
||||
#include "swrenderer/scene/r_portal.h"
|
||||
#include "swrenderer/scene/r_scene.h"
|
||||
#include "swrenderer/scene/r_viewport.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
#include "swrenderer/plane/r_flatplane.h"
|
||||
#include "swrenderer/plane/r_slopeplane.h"
|
||||
|
@ -41,6 +40,7 @@
|
|||
#include "swrenderer/plane/r_visibleplane.h"
|
||||
#include "swrenderer/plane/r_visibleplanelist.h"
|
||||
#include "swrenderer/drawers/r_draw.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
|
|
|
@ -33,10 +33,9 @@
|
|||
*/
|
||||
|
||||
#include "swrenderer/scene/r_scene.h"
|
||||
#include "swrenderer/scene/r_viewport.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
#include "swrenderer/things/r_playersprite.h"
|
||||
#include "swrenderer/scene/r_scene.h"
|
||||
#include "swrenderer/scene/r_viewport.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
#include "v_palette.h"
|
||||
#include "v_video.h"
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include "r_utility.h"
|
||||
#include "d_player.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
#include "swrenderer/scene/r_viewport.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
|
||||
CVAR(Bool, r_shadercolormaps, true, CVAR_ARCHIVE)
|
||||
EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor)
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "v_palette.h"
|
||||
#include "r_data/colormaps.h"
|
||||
#include "r_utility.h"
|
||||
#include "r_viewport.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
|
||||
// Lighting.
|
||||
//
|
||||
|
|
|
@ -42,8 +42,8 @@
|
|||
#include "swrenderer/segments/r_clipsegment.h"
|
||||
#include "swrenderer/line/r_wallsetup.h"
|
||||
#include "swrenderer/scene/r_scene.h"
|
||||
#include "swrenderer/scene/r_viewport.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
#include "r_3dfloors.h"
|
||||
#include "r_portal.h"
|
||||
#include "a_sharedglobal.h"
|
||||
|
|
|
@ -54,8 +54,8 @@
|
|||
#include "swrenderer/scene/r_opaque_pass.h"
|
||||
#include "swrenderer/scene/r_translucent_pass.h"
|
||||
#include "swrenderer/scene/r_scene.h"
|
||||
#include "swrenderer/scene/r_viewport.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
#include "swrenderer/r_memory.h"
|
||||
|
||||
CVAR(Int, r_portal_recursions, 4, CVAR_ARCHIVE)
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include "st_stuff.h"
|
||||
#include "r_data/r_interpolate.h"
|
||||
#include "swrenderer/scene/r_scene.h"
|
||||
#include "swrenderer/scene/r_viewport.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
#include "swrenderer/scene/r_3dfloors.h"
|
||||
#include "swrenderer/scene/r_opaque_pass.h"
|
||||
|
@ -43,6 +42,7 @@
|
|||
#include "swrenderer/segments/r_drawsegment.h"
|
||||
#include "swrenderer/segments/r_portalsegment.h"
|
||||
#include "swrenderer/plane/r_visibleplanelist.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
#include "swrenderer/drawers/r_draw.h"
|
||||
#include "swrenderer/drawers/r_draw_rgba.h"
|
||||
#include "swrenderer/drawers/r_thread.h"
|
||||
|
|
|
@ -32,11 +32,11 @@
|
|||
#include "swrenderer/segments/r_drawsegment.h"
|
||||
#include "swrenderer/scene/r_portal.h"
|
||||
#include "swrenderer/scene/r_translucent_pass.h"
|
||||
#include "swrenderer/scene/r_viewport.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
#include "swrenderer/plane/r_visibleplane.h"
|
||||
#include "swrenderer/plane/r_visibleplanelist.h"
|
||||
#include "swrenderer/line/r_renderdrawsegment.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
#include "swrenderer/r_memory.h"
|
||||
|
||||
EXTERN_CVAR(Int, r_drawfuzz)
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include "swrenderer/segments/r_drawsegment.h"
|
||||
#include "swrenderer/things/r_visiblesprite.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
#include "swrenderer/scene/r_viewport.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
|
|
|
@ -38,9 +38,10 @@
|
|||
#include "swrenderer/segments/r_drawsegment.h"
|
||||
#include "swrenderer/scene/r_portal.h"
|
||||
#include "swrenderer/scene/r_scene.h"
|
||||
#include "swrenderer/scene/r_viewport.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
#include "swrenderer/things/r_wallsprite.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
#include "swrenderer/viewport/r_spritedrawer.h"
|
||||
#include "swrenderer/r_memory.h"
|
||||
|
||||
EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor);
|
||||
|
|
|
@ -47,11 +47,11 @@
|
|||
#include "swrenderer/scene/r_3dfloors.h"
|
||||
#include "swrenderer/scene/r_translucent_pass.h"
|
||||
#include "swrenderer/scene/r_portal.h"
|
||||
#include "swrenderer/scene/r_viewport.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
#include "swrenderer/segments/r_drawsegment.h"
|
||||
#include "swrenderer/line/r_renderdrawsegment.h"
|
||||
#include "swrenderer/things/r_particle.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
#include "swrenderer/drawers/r_draw_rgba.h"
|
||||
#include "swrenderer/drawers/r_draw_pal.h"
|
||||
#include "swrenderer/r_memory.h"
|
||||
|
|
|
@ -51,9 +51,9 @@
|
|||
#include "swrenderer/segments/r_drawsegment.h"
|
||||
#include "swrenderer/scene/r_portal.h"
|
||||
#include "swrenderer/scene/r_scene.h"
|
||||
#include "swrenderer/scene/r_viewport.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
#include "swrenderer/things/r_sprite.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
#include "swrenderer/r_memory.h"
|
||||
#include "g_levellocals.h"
|
||||
|
||||
|
|
|
@ -51,9 +51,9 @@
|
|||
#include "swrenderer/segments/r_drawsegment.h"
|
||||
#include "swrenderer/scene/r_portal.h"
|
||||
#include "swrenderer/scene/r_scene.h"
|
||||
#include "swrenderer/scene/r_viewport.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
#include "swrenderer/things/r_sprite.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
#include "swrenderer/r_memory.h"
|
||||
|
||||
EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor)
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include "swrenderer/plane/r_visibleplane.h"
|
||||
#include "swrenderer/scene/r_portal.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
#include "swrenderer/scene/r_viewport.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
#include "swrenderer/r_memory.h"
|
||||
|
||||
EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor);
|
||||
|
|
|
@ -52,10 +52,10 @@
|
|||
#include "swrenderer/segments/r_drawsegment.h"
|
||||
#include "swrenderer/scene/r_portal.h"
|
||||
#include "swrenderer/scene/r_scene.h"
|
||||
#include "swrenderer/scene/r_viewport.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
#include "swrenderer/line/r_wallsetup.h"
|
||||
#include "swrenderer/line/r_walldraw.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
#include "swrenderer/r_memory.h"
|
||||
|
||||
EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor);
|
||||
|
|
94
src/swrenderer/viewport/r_drawerargs.cpp
Normal file
94
src/swrenderer/viewport/r_drawerargs.cpp
Normal file
|
@ -0,0 +1,94 @@
|
|||
//
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
//
|
||||
// This source is available for distribution and/or modification
|
||||
// only under the terms of the DOOM Source Code License as
|
||||
// published by id Software. All rights reserved.
|
||||
//
|
||||
// The source is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
|
||||
// for more details.
|
||||
//
|
||||
|
||||
#include <stddef.h>
|
||||
#include "r_drawerargs.h"
|
||||
#include "swrenderer/drawers/r_draw_pal.h"
|
||||
#include "swrenderer/drawers/r_draw_rgba.h"
|
||||
|
||||
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)
|
||||
{
|
||||
mBaseColormap = base_colormap;
|
||||
mTranslation = nullptr;
|
||||
mLight = light;
|
||||
mShade = shade;
|
||||
}
|
||||
|
||||
void DrawerArgs::SetTranslationMap(lighttable_t *translation)
|
||||
{
|
||||
mTranslation = translation;
|
||||
}
|
||||
|
||||
uint8_t *DrawerArgs::Colormap() const
|
||||
{
|
||||
if (mBaseColormap)
|
||||
{
|
||||
if (RenderViewport::Instance()->RenderTarget->IsBgra())
|
||||
return mBaseColormap->Maps;
|
||||
else
|
||||
return mBaseColormap->Maps + (GETPALOOKUP(mLight, mShade) << COLORMAPSHIFT);
|
||||
}
|
||||
else
|
||||
{
|
||||
return mTranslation;
|
||||
}
|
||||
}
|
||||
|
||||
ShadeConstants DrawerArgs::ColormapConstants() const
|
||||
{
|
||||
ShadeConstants shadeConstants;
|
||||
if (mBaseColormap)
|
||||
{
|
||||
shadeConstants.light_red = mBaseColormap->Color.r * 256 / 255;
|
||||
shadeConstants.light_green = mBaseColormap->Color.g * 256 / 255;
|
||||
shadeConstants.light_blue = mBaseColormap->Color.b * 256 / 255;
|
||||
shadeConstants.light_alpha = mBaseColormap->Color.a * 256 / 255;
|
||||
shadeConstants.fade_red = mBaseColormap->Fade.r;
|
||||
shadeConstants.fade_green = mBaseColormap->Fade.g;
|
||||
shadeConstants.fade_blue = mBaseColormap->Fade.b;
|
||||
shadeConstants.fade_alpha = mBaseColormap->Fade.a;
|
||||
shadeConstants.desaturate = MIN(abs(mBaseColormap->Desaturate), 255) * 255 / 256;
|
||||
shadeConstants.simple_shade = (mBaseColormap->Color.d == 0x00ffffff && mBaseColormap->Fade.d == 0x00000000 && mBaseColormap->Desaturate == 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
shadeConstants.light_red = 256;
|
||||
shadeConstants.light_green = 256;
|
||||
shadeConstants.light_blue = 256;
|
||||
shadeConstants.light_alpha = 256;
|
||||
shadeConstants.fade_red = 0;
|
||||
shadeConstants.fade_green = 0;
|
||||
shadeConstants.fade_blue = 0;
|
||||
shadeConstants.fade_alpha = 256;
|
||||
shadeConstants.desaturate = 0;
|
||||
shadeConstants.simple_shade = true;
|
||||
}
|
||||
return shadeConstants;
|
||||
}
|
||||
}
|
59
src/swrenderer/viewport/r_drawerargs.h
Normal file
59
src/swrenderer/viewport/r_drawerargs.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "templates.h"
|
||||
#include "doomtype.h"
|
||||
#include "doomdef.h"
|
||||
#include "r_defs.h"
|
||||
#include "swrenderer/drawers/r_draw.h"
|
||||
#include "v_video.h"
|
||||
#include "r_data/colormaps.h"
|
||||
#include "r_data/r_translate.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
|
||||
struct FSWColormap;
|
||||
struct FLightNode;
|
||||
struct TriLight;
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
class SWPixelFormatDrawers;
|
||||
class DrawerArgs;
|
||||
struct ShadeConstants;
|
||||
|
||||
class DrawerArgs
|
||||
{
|
||||
public:
|
||||
void SetLight(FSWColormap *base_colormap, float light, int shade);
|
||||
void SetTranslationMap(lighttable_t *translation);
|
||||
|
||||
uint8_t *Colormap() const;
|
||||
uint8_t *TranslationMap() const { return mTranslation; }
|
||||
|
||||
ShadeConstants ColormapConstants() const;
|
||||
fixed_t Light() const { return LIGHTSCALE(mLight, mShade); }
|
||||
|
||||
protected:
|
||||
static SWPixelFormatDrawers *Drawers();
|
||||
|
||||
private:
|
||||
FSWColormap *mBaseColormap = nullptr;
|
||||
float mLight = 0.0f;
|
||||
int mShade = 0;
|
||||
uint8_t *mTranslation = nullptr;
|
||||
};
|
||||
|
||||
struct ShadeConstants
|
||||
{
|
||||
uint16_t light_alpha;
|
||||
uint16_t light_red;
|
||||
uint16_t light_green;
|
||||
uint16_t light_blue;
|
||||
uint16_t fade_alpha;
|
||||
uint16_t fade_red;
|
||||
uint16_t fade_green;
|
||||
uint16_t fade_blue;
|
||||
uint16_t desaturate;
|
||||
bool simple_shade;
|
||||
};
|
||||
}
|
68
src/swrenderer/viewport/r_skydrawer.cpp
Normal file
68
src/swrenderer/viewport/r_skydrawer.cpp
Normal file
|
@ -0,0 +1,68 @@
|
|||
//
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
//
|
||||
// This source is available for distribution and/or modification
|
||||
// only under the terms of the DOOM Source Code License as
|
||||
// published by id Software. All rights reserved.
|
||||
//
|
||||
// The source is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
|
||||
// for more details.
|
||||
//
|
||||
|
||||
#include <stddef.h>
|
||||
#include "r_skydrawer.h"
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
void SkyDrawerArgs::DrawSingleSkyColumn()
|
||||
{
|
||||
Drawers()->DrawSingleSkyColumn(*this);
|
||||
}
|
||||
|
||||
void SkyDrawerArgs::DrawDoubleSkyColumn()
|
||||
{
|
||||
Drawers()->DrawDoubleSkyColumn(*this);
|
||||
}
|
||||
|
||||
void SkyDrawerArgs::SetDest(int x, int y)
|
||||
{
|
||||
auto viewport = RenderViewport::Instance();
|
||||
dc_dest = viewport->GetDest(x, y);
|
||||
dc_dest_y = y;
|
||||
}
|
||||
|
||||
void SkyDrawerArgs::SetFrontTexture(FTexture *texture, uint32_t column)
|
||||
{
|
||||
if (RenderViewport::Instance()->RenderTarget->IsBgra())
|
||||
{
|
||||
dc_source = (const uint8_t *)texture->GetColumnBgra(column, nullptr);
|
||||
dc_sourceheight = texture->GetHeight();
|
||||
}
|
||||
else
|
||||
{
|
||||
dc_source = texture->GetColumn(column, nullptr);
|
||||
dc_sourceheight = texture->GetHeight();
|
||||
}
|
||||
}
|
||||
|
||||
void SkyDrawerArgs::SetBackTexture(FTexture *texture, uint32_t column)
|
||||
{
|
||||
if (texture == nullptr)
|
||||
{
|
||||
dc_source2 = nullptr;
|
||||
dc_sourceheight2 = 1;
|
||||
}
|
||||
else if (RenderViewport::Instance()->RenderTarget->IsBgra())
|
||||
{
|
||||
dc_source2 = (const uint8_t *)texture->GetColumnBgra(column, nullptr);
|
||||
dc_sourceheight2 = texture->GetHeight();
|
||||
}
|
||||
else
|
||||
{
|
||||
dc_source2 = texture->GetColumn(column, nullptr);
|
||||
dc_sourceheight2 = texture->GetHeight();
|
||||
}
|
||||
}
|
||||
}
|
58
src/swrenderer/viewport/r_skydrawer.h
Normal file
58
src/swrenderer/viewport/r_skydrawer.h
Normal file
|
@ -0,0 +1,58 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "r_drawerargs.h"
|
||||
|
||||
struct FSWColormap;
|
||||
struct FLightNode;
|
||||
struct TriLight;
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
class SkyDrawerArgs : public DrawerArgs
|
||||
{
|
||||
public:
|
||||
void SetDest(int x, int y);
|
||||
void SetCount(int count) { dc_count = count; }
|
||||
void SetFrontTexture(FTexture *texture, uint32_t column);
|
||||
void SetBackTexture(FTexture *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; }
|
||||
void SetSolidBottom(uint32_t color) { solid_bottom = color; }
|
||||
void SetFadeSky(bool enable) { fadeSky = enable; }
|
||||
|
||||
uint8_t *Dest() const { return dc_dest; }
|
||||
int DestY() const { return dc_dest_y; }
|
||||
int Count() const { return dc_count; }
|
||||
|
||||
uint32_t TextureVPos() const { return dc_texturefrac; }
|
||||
uint32_t TextureVStep() const { return dc_iscale; }
|
||||
|
||||
uint32_t SolidTopColor() const { return solid_top; }
|
||||
uint32_t SolidBottomColor() const { return solid_bottom; }
|
||||
bool FadeSky() const { return fadeSky; }
|
||||
|
||||
const uint8_t *FrontTexturePixels() const { return dc_source; }
|
||||
const uint8_t *BackTexturePixels() const { return dc_source2; }
|
||||
int FrontTextureHeight() const { return dc_sourceheight; }
|
||||
int BackTextureHeight() const { return dc_sourceheight2; }
|
||||
|
||||
void DrawSingleSkyColumn();
|
||||
void DrawDoubleSkyColumn();
|
||||
|
||||
private:
|
||||
uint8_t *dc_dest = nullptr;
|
||||
int dc_dest_y = 0;
|
||||
int dc_count = 0;
|
||||
const uint8_t *dc_source;
|
||||
const uint8_t *dc_source2;
|
||||
uint32_t dc_sourceheight;
|
||||
uint32_t dc_sourceheight2;
|
||||
uint32_t dc_texturefrac;
|
||||
uint32_t dc_iscale;
|
||||
uint32_t solid_top;
|
||||
uint32_t solid_bottom;
|
||||
bool fadeSky;
|
||||
};
|
||||
}
|
118
src/swrenderer/viewport/r_spandrawer.cpp
Normal file
118
src/swrenderer/viewport/r_spandrawer.cpp
Normal file
|
@ -0,0 +1,118 @@
|
|||
//
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
//
|
||||
// This source is available for distribution and/or modification
|
||||
// only under the terms of the DOOM Source Code License as
|
||||
// published by id Software. All rights reserved.
|
||||
//
|
||||
// The source is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
|
||||
// for more details.
|
||||
//
|
||||
|
||||
#include <stddef.h>
|
||||
#include "r_spandrawer.h"
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
SpanDrawerArgs::SpanDrawerArgs()
|
||||
{
|
||||
spanfunc = &SWPixelFormatDrawers::DrawSpan;
|
||||
}
|
||||
|
||||
void SpanDrawerArgs::SetTexture(FTexture *tex)
|
||||
{
|
||||
tex->GetWidth();
|
||||
ds_xbits = tex->WidthBits;
|
||||
ds_ybits = tex->HeightBits;
|
||||
if ((1 << ds_xbits) > tex->GetWidth())
|
||||
{
|
||||
ds_xbits--;
|
||||
}
|
||||
if ((1 << ds_ybits) > tex->GetHeight())
|
||||
{
|
||||
ds_ybits--;
|
||||
}
|
||||
|
||||
auto viewport = RenderViewport::Instance();
|
||||
ds_source = viewport->RenderTarget->IsBgra() ? (const uint8_t*)tex->GetPixelsBgra() : tex->GetPixels();
|
||||
ds_source_mipmapped = tex->Mipmapped() && tex->GetWidth() > 1 && tex->GetHeight() > 1;
|
||||
}
|
||||
|
||||
void SpanDrawerArgs::SetStyle(bool masked, bool additive, fixed_t alpha)
|
||||
{
|
||||
if (masked)
|
||||
{
|
||||
if (alpha < OPAQUE || additive)
|
||||
{
|
||||
if (!additive)
|
||||
{
|
||||
spanfunc = &SWPixelFormatDrawers::DrawSpanMaskedTranslucent;
|
||||
dc_srcblend = Col2RGB8[alpha >> 10];
|
||||
dc_destblend = Col2RGB8[(OPAQUE - alpha) >> 10];
|
||||
dc_srcalpha = alpha;
|
||||
dc_destalpha = OPAQUE - alpha;
|
||||
}
|
||||
else
|
||||
{
|
||||
spanfunc = &SWPixelFormatDrawers::DrawSpanMaskedAddClamp;
|
||||
dc_srcblend = Col2RGB8_LessPrecision[alpha >> 10];
|
||||
dc_destblend = Col2RGB8_LessPrecision[FRACUNIT >> 10];
|
||||
dc_srcalpha = alpha;
|
||||
dc_destalpha = FRACUNIT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
spanfunc = &SWPixelFormatDrawers::DrawSpanMasked;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (alpha < OPAQUE || additive)
|
||||
{
|
||||
if (!additive)
|
||||
{
|
||||
spanfunc = &SWPixelFormatDrawers::DrawSpanTranslucent;
|
||||
dc_srcblend = Col2RGB8[alpha >> 10];
|
||||
dc_destblend = Col2RGB8[(OPAQUE - alpha) >> 10];
|
||||
dc_srcalpha = alpha;
|
||||
dc_destalpha = OPAQUE - alpha;
|
||||
}
|
||||
else
|
||||
{
|
||||
spanfunc = &SWPixelFormatDrawers::DrawSpanAddClamp;
|
||||
dc_srcblend = Col2RGB8_LessPrecision[alpha >> 10];
|
||||
dc_destblend = Col2RGB8_LessPrecision[FRACUNIT >> 10];
|
||||
dc_srcalpha = alpha;
|
||||
dc_destalpha = FRACUNIT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
spanfunc = &SWPixelFormatDrawers::DrawSpan;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SpanDrawerArgs::DrawSpan()
|
||||
{
|
||||
(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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
Drawers()->DrawFogBoundaryLine(*this, y, x1, x2);
|
||||
}
|
||||
|
||||
void SpanDrawerArgs::DrawColoredSpan(int y, int x1, int x2)
|
||||
{
|
||||
Drawers()->DrawColoredSpan(*this, y, x1, x2);
|
||||
}
|
||||
}
|
80
src/swrenderer/viewport/r_spandrawer.h
Normal file
80
src/swrenderer/viewport/r_spandrawer.h
Normal file
|
@ -0,0 +1,80 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "r_drawerargs.h"
|
||||
|
||||
struct FSWColormap;
|
||||
struct FLightNode;
|
||||
struct TriLight;
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
class SpanDrawerArgs : public DrawerArgs
|
||||
{
|
||||
public:
|
||||
SpanDrawerArgs();
|
||||
|
||||
void SetStyle(bool masked, bool additive, fixed_t alpha);
|
||||
void SetDestY(int y) { ds_y = y; }
|
||||
void SetDestX1(int x) { ds_x1 = x; }
|
||||
void SetDestX2(int x) { ds_x2 = x; }
|
||||
void SetTexture(FTexture *tex);
|
||||
void SetTextureLOD(double lod) { ds_lod = lod; }
|
||||
void SetTextureUPos(dsfixed_t xfrac) { ds_xfrac = xfrac; }
|
||||
void SetTextureVPos(dsfixed_t yfrac) { ds_yfrac = yfrac; }
|
||||
void SetTextureUStep(dsfixed_t xstep) { ds_xstep = xstep; }
|
||||
void SetTextureVStep(dsfixed_t vstep) { ds_ystep = vstep; }
|
||||
void SetSolidColor(int colorIndex) { ds_color = colorIndex; }
|
||||
|
||||
void DrawSpan();
|
||||
void 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 DrawColoredSpan(int y, int x1, int x2);
|
||||
void DrawFogBoundaryLine(int y, int x1, int x2);
|
||||
|
||||
uint32_t *SrcBlend() const { return dc_srcblend; }
|
||||
uint32_t *DestBlend() const { return dc_destblend; }
|
||||
fixed_t SrcAlpha() const { return dc_srcalpha; }
|
||||
fixed_t DestAlpha() const { return dc_destalpha; }
|
||||
int DestY() const { return ds_y; }
|
||||
int DestX1() const { return ds_x1; }
|
||||
int DestX2() const { return ds_x2; }
|
||||
dsfixed_t TextureUPos() const { return ds_xfrac; }
|
||||
dsfixed_t TextureVPos() const { return ds_yfrac; }
|
||||
dsfixed_t TextureUStep() const { return ds_xstep; }
|
||||
dsfixed_t TextureVStep() const { return ds_ystep; }
|
||||
int SolidColor() const { return ds_color; }
|
||||
int TextureWidthBits() const { return ds_xbits; }
|
||||
int TextureHeightBits() const { return ds_ybits; }
|
||||
const uint8_t *TexturePixels() const { return ds_source; }
|
||||
bool MipmappedTexture() const { return ds_source_mipmapped; }
|
||||
double TextureLOD() const { return ds_lod; }
|
||||
|
||||
FVector3 dc_normal;
|
||||
FVector3 dc_viewpos;
|
||||
FVector3 dc_viewpos_step;
|
||||
TriLight *dc_lights = nullptr;
|
||||
int dc_num_lights = 0;
|
||||
|
||||
private:
|
||||
typedef void(SWPixelFormatDrawers::*SpanDrawerFunc)(const SpanDrawerArgs &args);
|
||||
SpanDrawerFunc spanfunc;
|
||||
|
||||
int ds_y;
|
||||
int ds_x1;
|
||||
int ds_x2;
|
||||
int ds_xbits;
|
||||
int ds_ybits;
|
||||
const uint8_t *ds_source;
|
||||
bool ds_source_mipmapped;
|
||||
dsfixed_t ds_xfrac;
|
||||
dsfixed_t ds_yfrac;
|
||||
dsfixed_t ds_xstep;
|
||||
dsfixed_t ds_ystep;
|
||||
uint32_t *dc_srcblend;
|
||||
uint32_t *dc_destblend;
|
||||
fixed_t dc_srcalpha;
|
||||
fixed_t dc_destalpha;
|
||||
int ds_color = 0;
|
||||
double ds_lod;
|
||||
};
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** r_drawerargs.cpp
|
||||
** r_spritedrawer.cpp
|
||||
**
|
||||
**---------------------------------------------------------------------------
|
||||
** Copyright 1998-2016 Randy Heit
|
||||
|
@ -33,115 +33,15 @@
|
|||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include "r_drawerargs.h"
|
||||
#include "r_draw_pal.h"
|
||||
#include "r_draw_rgba.h"
|
||||
#include "r_spritedrawer.h"
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
SpriteDrawerArgs::SpriteDrawerArgs()
|
||||
{
|
||||
colfunc = &SWPixelFormatDrawers::DrawColumn;
|
||||
}
|
||||
|
||||
SpanDrawerArgs::SpanDrawerArgs()
|
||||
{
|
||||
spanfunc = &SWPixelFormatDrawers::DrawSpan;
|
||||
}
|
||||
|
||||
void DrawerArgs::SetLight(FSWColormap *base_colormap, float light, int shade)
|
||||
{
|
||||
mBaseColormap = base_colormap;
|
||||
mTranslation = nullptr;
|
||||
mLight = light;
|
||||
mShade = shade;
|
||||
}
|
||||
|
||||
void DrawerArgs::SetTranslationMap(lighttable_t *translation)
|
||||
{
|
||||
mTranslation = translation;
|
||||
}
|
||||
|
||||
uint8_t *DrawerArgs::Colormap() const
|
||||
{
|
||||
if (mBaseColormap)
|
||||
{
|
||||
if (RenderViewport::Instance()->RenderTarget->IsBgra())
|
||||
return mBaseColormap->Maps;
|
||||
else
|
||||
return mBaseColormap->Maps + (GETPALOOKUP(mLight, mShade) << COLORMAPSHIFT);
|
||||
}
|
||||
else
|
||||
{
|
||||
return mTranslation;
|
||||
}
|
||||
}
|
||||
|
||||
ShadeConstants DrawerArgs::ColormapConstants() const
|
||||
{
|
||||
ShadeConstants shadeConstants;
|
||||
if (mBaseColormap)
|
||||
{
|
||||
shadeConstants.light_red = mBaseColormap->Color.r * 256 / 255;
|
||||
shadeConstants.light_green = mBaseColormap->Color.g * 256 / 255;
|
||||
shadeConstants.light_blue = mBaseColormap->Color.b * 256 / 255;
|
||||
shadeConstants.light_alpha = mBaseColormap->Color.a * 256 / 255;
|
||||
shadeConstants.fade_red = mBaseColormap->Fade.r;
|
||||
shadeConstants.fade_green = mBaseColormap->Fade.g;
|
||||
shadeConstants.fade_blue = mBaseColormap->Fade.b;
|
||||
shadeConstants.fade_alpha = mBaseColormap->Fade.a;
|
||||
shadeConstants.desaturate = MIN(abs(mBaseColormap->Desaturate), 255) * 255 / 256;
|
||||
shadeConstants.simple_shade = (mBaseColormap->Color.d == 0x00ffffff && mBaseColormap->Fade.d == 0x00000000 && mBaseColormap->Desaturate == 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
shadeConstants.light_red = 256;
|
||||
shadeConstants.light_green = 256;
|
||||
shadeConstants.light_blue = 256;
|
||||
shadeConstants.light_alpha = 256;
|
||||
shadeConstants.fade_red = 0;
|
||||
shadeConstants.fade_green = 0;
|
||||
shadeConstants.fade_blue = 0;
|
||||
shadeConstants.fade_alpha = 256;
|
||||
shadeConstants.desaturate = 0;
|
||||
shadeConstants.simple_shade = true;
|
||||
}
|
||||
return shadeConstants;
|
||||
}
|
||||
|
||||
void SpanDrawerArgs::SetTexture(FTexture *tex)
|
||||
{
|
||||
tex->GetWidth();
|
||||
ds_xbits = tex->WidthBits;
|
||||
ds_ybits = tex->HeightBits;
|
||||
if ((1 << ds_xbits) > tex->GetWidth())
|
||||
{
|
||||
ds_xbits--;
|
||||
}
|
||||
if ((1 << ds_ybits) > tex->GetHeight())
|
||||
{
|
||||
ds_ybits--;
|
||||
}
|
||||
|
||||
auto viewport = RenderViewport::Instance();
|
||||
ds_source = viewport->RenderTarget->IsBgra() ? (const uint8_t*)tex->GetPixelsBgra() : tex->GetPixels();
|
||||
ds_source_mipmapped = tex->Mipmapped() && tex->GetWidth() > 1 && tex->GetHeight() > 1;
|
||||
}
|
||||
|
||||
void SpriteDrawerArgs::DrawMaskedColumn(int x, fixed_t iscale, FTexture *tex, fixed_t col, double spryscale, double sprtopscreen, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, bool unmasked)
|
||||
{
|
||||
auto viewport = RenderViewport::Instance();
|
||||
|
@ -588,180 +488,6 @@ namespace swrenderer
|
|||
return SetPatchStyle(style, FLOAT2FIXED(alpha), translation, color, basecolormap, shadedlightshade);
|
||||
}
|
||||
|
||||
void WallDrawerArgs::SetDest(int x, int y)
|
||||
{
|
||||
auto viewport = RenderViewport::Instance();
|
||||
dc_dest = viewport->GetDest(x, y);
|
||||
dc_dest_y = y;
|
||||
}
|
||||
|
||||
void WallDrawerArgs::DrawColumn()
|
||||
{
|
||||
(Drawers()->*wallfunc)(*this);
|
||||
}
|
||||
|
||||
void SpanDrawerArgs::SetStyle(bool masked, bool additive, fixed_t alpha)
|
||||
{
|
||||
if (masked)
|
||||
{
|
||||
if (alpha < OPAQUE || additive)
|
||||
{
|
||||
if (!additive)
|
||||
{
|
||||
spanfunc = &SWPixelFormatDrawers::DrawSpanMaskedTranslucent;
|
||||
dc_srcblend = Col2RGB8[alpha >> 10];
|
||||
dc_destblend = Col2RGB8[(OPAQUE - alpha) >> 10];
|
||||
dc_srcalpha = alpha;
|
||||
dc_destalpha = OPAQUE - alpha;
|
||||
}
|
||||
else
|
||||
{
|
||||
spanfunc = &SWPixelFormatDrawers::DrawSpanMaskedAddClamp;
|
||||
dc_srcblend = Col2RGB8_LessPrecision[alpha >> 10];
|
||||
dc_destblend = Col2RGB8_LessPrecision[FRACUNIT >> 10];
|
||||
dc_srcalpha = alpha;
|
||||
dc_destalpha = FRACUNIT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
spanfunc = &SWPixelFormatDrawers::DrawSpanMasked;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (alpha < OPAQUE || additive)
|
||||
{
|
||||
if (!additive)
|
||||
{
|
||||
spanfunc = &SWPixelFormatDrawers::DrawSpanTranslucent;
|
||||
dc_srcblend = Col2RGB8[alpha >> 10];
|
||||
dc_destblend = Col2RGB8[(OPAQUE - alpha) >> 10];
|
||||
dc_srcalpha = alpha;
|
||||
dc_destalpha = OPAQUE - alpha;
|
||||
}
|
||||
else
|
||||
{
|
||||
spanfunc = &SWPixelFormatDrawers::DrawSpanAddClamp;
|
||||
dc_srcblend = Col2RGB8_LessPrecision[alpha >> 10];
|
||||
dc_destblend = Col2RGB8_LessPrecision[FRACUNIT >> 10];
|
||||
dc_srcalpha = alpha;
|
||||
dc_destalpha = FRACUNIT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
spanfunc = &SWPixelFormatDrawers::DrawSpan;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WallDrawerArgs::SetStyle(bool masked, bool additive, fixed_t alpha)
|
||||
{
|
||||
if (alpha < OPAQUE || additive)
|
||||
{
|
||||
if (!additive)
|
||||
{
|
||||
wallfunc = &SWPixelFormatDrawers::DrawWallAddColumn;
|
||||
dc_srcblend = Col2RGB8[alpha >> 10];
|
||||
dc_destblend = Col2RGB8[(OPAQUE - alpha) >> 10];
|
||||
dc_srcalpha = alpha;
|
||||
dc_destalpha = OPAQUE - alpha;
|
||||
}
|
||||
else
|
||||
{
|
||||
wallfunc = &SWPixelFormatDrawers::DrawWallAddClampColumn;
|
||||
dc_srcblend = Col2RGB8_LessPrecision[alpha >> 10];
|
||||
dc_destblend = Col2RGB8_LessPrecision[FRACUNIT >> 10];
|
||||
dc_srcalpha = alpha;
|
||||
dc_destalpha = FRACUNIT;
|
||||
}
|
||||
}
|
||||
else if (masked)
|
||||
{
|
||||
wallfunc = &SWPixelFormatDrawers::DrawWallMaskedColumn;
|
||||
}
|
||||
else
|
||||
{
|
||||
wallfunc = &SWPixelFormatDrawers::DrawWallColumn;
|
||||
}
|
||||
}
|
||||
|
||||
bool WallDrawerArgs::IsMaskedDrawer() const
|
||||
{
|
||||
return wallfunc == &SWPixelFormatDrawers::DrawWallMaskedColumn;
|
||||
}
|
||||
|
||||
void SpanDrawerArgs::DrawSpan()
|
||||
{
|
||||
(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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
Drawers()->DrawFogBoundaryLine(*this, y, x1, x2);
|
||||
}
|
||||
|
||||
void SpanDrawerArgs::DrawColoredSpan(int y, int x1, int x2)
|
||||
{
|
||||
Drawers()->DrawColoredSpan(*this, y, x1, x2);
|
||||
}
|
||||
|
||||
void SkyDrawerArgs::DrawSingleSkyColumn()
|
||||
{
|
||||
Drawers()->DrawSingleSkyColumn(*this);
|
||||
}
|
||||
|
||||
void SkyDrawerArgs::DrawDoubleSkyColumn()
|
||||
{
|
||||
Drawers()->DrawDoubleSkyColumn(*this);
|
||||
}
|
||||
|
||||
void SkyDrawerArgs::SetDest(int x, int y)
|
||||
{
|
||||
auto viewport = RenderViewport::Instance();
|
||||
dc_dest = viewport->GetDest(x, y);
|
||||
dc_dest_y = y;
|
||||
}
|
||||
|
||||
void SkyDrawerArgs::SetFrontTexture(FTexture *texture, uint32_t column)
|
||||
{
|
||||
if (RenderViewport::Instance()->RenderTarget->IsBgra())
|
||||
{
|
||||
dc_source = (const uint8_t *)texture->GetColumnBgra(column, nullptr);
|
||||
dc_sourceheight = texture->GetHeight();
|
||||
}
|
||||
else
|
||||
{
|
||||
dc_source = texture->GetColumn(column, nullptr);
|
||||
dc_sourceheight = texture->GetHeight();
|
||||
}
|
||||
}
|
||||
|
||||
void SkyDrawerArgs::SetBackTexture(FTexture *texture, uint32_t column)
|
||||
{
|
||||
if (texture == nullptr)
|
||||
{
|
||||
dc_source2 = nullptr;
|
||||
dc_sourceheight2 = 1;
|
||||
}
|
||||
else if (RenderViewport::Instance()->RenderTarget->IsBgra())
|
||||
{
|
||||
dc_source2 = (const uint8_t *)texture->GetColumnBgra(column, nullptr);
|
||||
dc_sourceheight2 = texture->GetHeight();
|
||||
}
|
||||
else
|
||||
{
|
||||
dc_source2 = texture->GetColumn(column, nullptr);
|
||||
dc_sourceheight2 = texture->GetHeight();
|
||||
}
|
||||
}
|
||||
|
||||
void SpriteDrawerArgs::FillColumn()
|
||||
{
|
||||
Drawers()->FillColumn(*this);
|
85
src/swrenderer/viewport/r_spritedrawer.h
Normal file
85
src/swrenderer/viewport/r_spritedrawer.h
Normal file
|
@ -0,0 +1,85 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "r_drawerargs.h"
|
||||
|
||||
struct FSWColormap;
|
||||
struct FLightNode;
|
||||
struct TriLight;
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
class SpriteDrawerArgs : public DrawerArgs
|
||||
{
|
||||
public:
|
||||
SpriteDrawerArgs();
|
||||
|
||||
bool SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap, fixed_t shadedlightshade = 0);
|
||||
bool SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap, fixed_t shadedlightshade = 0);
|
||||
void SetDest(int x, int y);
|
||||
void SetCount(int count) { dc_count = count; }
|
||||
void SetSolidColor(int color) { dc_color = color; }
|
||||
|
||||
void DrawMaskedColumn(int x, fixed_t iscale, FTexture *texture, fixed_t column, double spryscale, double sprtopscreen, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, bool unmasked = false);
|
||||
void FillColumn();
|
||||
|
||||
uint8_t *Dest() const { return dc_dest; }
|
||||
int DestY() const { return dc_dest_y; }
|
||||
int Count() const { return dc_count; }
|
||||
|
||||
int FuzzX() const { return dc_x; }
|
||||
int FuzzY1() const { return dc_yl; }
|
||||
int FuzzY2() const { return dc_yh; }
|
||||
|
||||
uint32_t TextureUPos() const { return dc_texturefracx; }
|
||||
fixed_t TextureVPos() const { return dc_texturefrac; }
|
||||
fixed_t TextureVStep() const { return dc_iscale; }
|
||||
|
||||
int SolidColor() const { return dc_color; }
|
||||
uint32_t SrcColorIndex() const { return dc_srccolor; }
|
||||
uint32_t SrcColorBgra() const { return dc_srccolor_bgra; }
|
||||
|
||||
const uint8_t *TexturePixels() const { return dc_source; }
|
||||
const uint8_t *TexturePixels2() const { return dc_source2; }
|
||||
uint32_t TextureHeight() const { return dc_textureheight; }
|
||||
|
||||
uint32_t *SrcBlend() const { return dc_srcblend; }
|
||||
uint32_t *DestBlend() const { return dc_destblend; }
|
||||
fixed_t SrcAlpha() const { return dc_srcalpha; }
|
||||
fixed_t DestAlpha() const { return dc_destalpha; }
|
||||
|
||||
private:
|
||||
bool SetBlendFunc(int op, fixed_t fglevel, fixed_t bglevel, int flags);
|
||||
static fixed_t GetAlpha(int type, fixed_t alpha);
|
||||
void DrawMaskedColumnBgra(int x, fixed_t iscale, FTexture *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;
|
||||
int dc_count = 0;
|
||||
|
||||
fixed_t dc_iscale;
|
||||
fixed_t dc_texturefrac;
|
||||
uint32_t dc_texturefracx;
|
||||
|
||||
uint32_t dc_textureheight = 0;
|
||||
const uint8_t *dc_source = nullptr;
|
||||
const uint8_t *dc_source2 = nullptr;
|
||||
bool drawer_needs_pal_input = false;
|
||||
|
||||
uint32_t *dc_srcblend = nullptr;
|
||||
uint32_t *dc_destblend = nullptr;
|
||||
fixed_t dc_srcalpha = OPAQUE;
|
||||
fixed_t dc_destalpha = 0;
|
||||
|
||||
int dc_x = 0;
|
||||
int dc_yl = 0;
|
||||
int dc_yh = 0;
|
||||
|
||||
int dc_color = 0;
|
||||
uint32_t dc_srccolor = 0;
|
||||
uint32_t dc_srccolor_bgra = 0;
|
||||
|
||||
typedef void(SWPixelFormatDrawers::*SpriteDrawerFunc)(const SpriteDrawerArgs &args);
|
||||
SpriteDrawerFunc colfunc;
|
||||
};
|
||||
}
|
|
@ -28,7 +28,7 @@
|
|||
#include "d_net.h"
|
||||
#include "g_level.h"
|
||||
#include "r_utility.h"
|
||||
#include "swrenderer/scene/r_viewport.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
#include "swrenderer/drawers/r_draw.h"
|
||||
#include "swrenderer/things/r_playersprite.h"
|
66
src/swrenderer/viewport/r_walldrawer.cpp
Normal file
66
src/swrenderer/viewport/r_walldrawer.cpp
Normal file
|
@ -0,0 +1,66 @@
|
|||
//
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
//
|
||||
// This source is available for distribution and/or modification
|
||||
// only under the terms of the DOOM Source Code License as
|
||||
// published by id Software. All rights reserved.
|
||||
//
|
||||
// The source is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
|
||||
// for more details.
|
||||
//
|
||||
|
||||
#include <stddef.h>
|
||||
#include "r_walldrawer.h"
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
void WallDrawerArgs::SetDest(int x, int y)
|
||||
{
|
||||
auto viewport = RenderViewport::Instance();
|
||||
dc_dest = viewport->GetDest(x, y);
|
||||
dc_dest_y = y;
|
||||
}
|
||||
|
||||
void WallDrawerArgs::DrawColumn()
|
||||
{
|
||||
(Drawers()->*wallfunc)(*this);
|
||||
}
|
||||
|
||||
void WallDrawerArgs::SetStyle(bool masked, bool additive, fixed_t alpha)
|
||||
{
|
||||
if (alpha < OPAQUE || additive)
|
||||
{
|
||||
if (!additive)
|
||||
{
|
||||
wallfunc = &SWPixelFormatDrawers::DrawWallAddColumn;
|
||||
dc_srcblend = Col2RGB8[alpha >> 10];
|
||||
dc_destblend = Col2RGB8[(OPAQUE - alpha) >> 10];
|
||||
dc_srcalpha = alpha;
|
||||
dc_destalpha = OPAQUE - alpha;
|
||||
}
|
||||
else
|
||||
{
|
||||
wallfunc = &SWPixelFormatDrawers::DrawWallAddClampColumn;
|
||||
dc_srcblend = Col2RGB8_LessPrecision[alpha >> 10];
|
||||
dc_destblend = Col2RGB8_LessPrecision[FRACUNIT >> 10];
|
||||
dc_srcalpha = alpha;
|
||||
dc_destalpha = FRACUNIT;
|
||||
}
|
||||
}
|
||||
else if (masked)
|
||||
{
|
||||
wallfunc = &SWPixelFormatDrawers::DrawWallMaskedColumn;
|
||||
}
|
||||
else
|
||||
{
|
||||
wallfunc = &SWPixelFormatDrawers::DrawWallColumn;
|
||||
}
|
||||
}
|
||||
|
||||
bool WallDrawerArgs::IsMaskedDrawer() const
|
||||
{
|
||||
return wallfunc == &SWPixelFormatDrawers::DrawWallMaskedColumn;
|
||||
}
|
||||
}
|
79
src/swrenderer/viewport/r_walldrawer.h
Normal file
79
src/swrenderer/viewport/r_walldrawer.h
Normal file
|
@ -0,0 +1,79 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "r_drawerargs.h"
|
||||
|
||||
struct FSWColormap;
|
||||
struct FLightNode;
|
||||
struct TriLight;
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
class WallDrawerArgs : public DrawerArgs
|
||||
{
|
||||
public:
|
||||
void SetStyle(bool masked, bool additive, fixed_t alpha);
|
||||
void SetDest(int x, int y);
|
||||
void SetCount(int count) { dc_count = count; }
|
||||
void SetTexture(const uint8_t *pixels, const uint8_t *pixels2, int height)
|
||||
{
|
||||
dc_source = pixels;
|
||||
dc_source2 = pixels2;
|
||||
dc_textureheight = height;
|
||||
}
|
||||
void SetTextureFracBits(int bits) { dc_wall_fracbits = bits; }
|
||||
void SetTextureUPos(uint32_t pos) { dc_texturefracx = pos; }
|
||||
void SetTextureVPos(fixed_t pos) { dc_texturefrac = pos; }
|
||||
void SetTextureVStep(fixed_t step) { dc_iscale = step; }
|
||||
|
||||
bool IsMaskedDrawer() const;
|
||||
|
||||
void DrawColumn();
|
||||
|
||||
uint8_t *Dest() const { return dc_dest; }
|
||||
int DestY() const { return dc_dest_y; }
|
||||
int Count() const { return dc_count; }
|
||||
|
||||
uint32_t *SrcBlend() const { return dc_srcblend; }
|
||||
uint32_t *DestBlend() const { return dc_destblend; }
|
||||
fixed_t SrcAlpha() const { return dc_srcalpha; }
|
||||
fixed_t DestAlpha() const { return dc_destalpha; }
|
||||
|
||||
uint32_t TextureUPos() const { return dc_texturefracx; }
|
||||
fixed_t TextureVPos() const { return dc_texturefrac; }
|
||||
fixed_t TextureVStep() const { return dc_iscale; }
|
||||
|
||||
const uint8_t *TexturePixels() const { return dc_source; }
|
||||
const uint8_t *TexturePixels2() const { return dc_source2; }
|
||||
uint32_t TextureHeight() const { return dc_textureheight; }
|
||||
|
||||
int TextureFracBits() const { return dc_wall_fracbits; }
|
||||
|
||||
FVector3 dc_normal;
|
||||
FVector3 dc_viewpos;
|
||||
FVector3 dc_viewpos_step;
|
||||
TriLight *dc_lights = nullptr;
|
||||
int dc_num_lights = 0;
|
||||
|
||||
private:
|
||||
uint8_t *dc_dest = nullptr;
|
||||
int dc_dest_y = 0;
|
||||
int dc_count;
|
||||
|
||||
fixed_t dc_iscale;
|
||||
fixed_t dc_texturefrac;
|
||||
uint32_t dc_texturefracx;
|
||||
uint32_t dc_textureheight;
|
||||
const uint8_t *dc_source;
|
||||
const uint8_t *dc_source2;
|
||||
int dc_wall_fracbits;
|
||||
|
||||
uint32_t *dc_srcblend;
|
||||
uint32_t *dc_destblend;
|
||||
fixed_t dc_srcalpha;
|
||||
fixed_t dc_destalpha;
|
||||
|
||||
typedef void(SWPixelFormatDrawers::*WallDrawerFunc)(const WallDrawerArgs &args);
|
||||
WallDrawerFunc wallfunc = nullptr;
|
||||
};
|
||||
}
|
|
@ -46,7 +46,7 @@
|
|||
#include "swrenderer/drawers/r_draw.h"
|
||||
#include "swrenderer/drawers/r_draw_rgba.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
#include "swrenderer/scene/r_viewport.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
#endif
|
||||
#include "r_data/r_translate.h"
|
||||
#include "doomstat.h"
|
||||
|
|
Loading…
Reference in a new issue