mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-12-02 08:53:42 +00:00
Fix cameras and kdizd intro for true color mode
This commit is contained in:
parent
0f0859b0b2
commit
cc10c2a970
5 changed files with 126 additions and 16 deletions
|
@ -974,6 +974,8 @@ void R_RenderViewToCanvas (AActor *actor, DCanvas *canvas,
|
|||
|
||||
R_RenderActorView (actor, dontmaplines);
|
||||
|
||||
R_EndDrawerCommands();
|
||||
|
||||
RenderTarget = screen;
|
||||
bRenderingToCanvas = false;
|
||||
R_ExecuteSetViewSize ();
|
||||
|
@ -981,8 +983,6 @@ void R_RenderViewToCanvas (AActor *actor, DCanvas *canvas,
|
|||
R_SetupBuffer ();
|
||||
screen->Unlock ();
|
||||
|
||||
R_EndDrawerCommands();
|
||||
|
||||
viewactive = savedviewactive;
|
||||
r_swtruecolor = savedoutputformat;
|
||||
|
||||
|
|
|
@ -87,11 +87,17 @@ void FSoftwareRenderer::PrecacheTexture(FTexture *tex, int cache)
|
|||
if (cache & FTextureManager::HIT_Columnmode)
|
||||
{
|
||||
const FTexture::Span *spanp;
|
||||
tex->GetColumn(0, &spanp);
|
||||
/*if (r_swtruecolor)
|
||||
tex->GetColumnBgra(0, &spanp);
|
||||
else*/
|
||||
tex->GetColumn(0, &spanp);
|
||||
}
|
||||
else if (cache != 0)
|
||||
{
|
||||
tex->GetPixels ();
|
||||
if (r_swtruecolor)
|
||||
tex->GetPixels();
|
||||
else
|
||||
tex->GetPixels ();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -328,8 +334,8 @@ void FSoftwareRenderer::CopyStackedViewParameters()
|
|||
|
||||
void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoint, int fov)
|
||||
{
|
||||
BYTE *Pixels = const_cast<BYTE*>(tex->GetPixels());
|
||||
DSimpleCanvas *Canvas = tex->GetCanvas();
|
||||
BYTE *Pixels = r_swtruecolor ? (BYTE*)tex->GetPixelsBgra() : (BYTE*)tex->GetPixels();
|
||||
DSimpleCanvas *Canvas = r_swtruecolor ? tex->GetCanvasBgra() : tex->GetCanvas();
|
||||
|
||||
// curse Doom's overuse of global variables in the renderer.
|
||||
// These get clobbered by rendering to a camera texture but they need to be preserved so the final rendering can be done with the correct palette.
|
||||
|
@ -340,13 +346,28 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin
|
|||
R_SetFOV ((double)fov);
|
||||
R_RenderViewToCanvas (viewpoint, Canvas, 0, 0, tex->GetWidth(), tex->GetHeight(), tex->bFirstUpdate);
|
||||
R_SetFOV (savedfov);
|
||||
if (Pixels == Canvas->GetBuffer())
|
||||
|
||||
if (Canvas->IsBgra())
|
||||
{
|
||||
FTexture::FlipSquareBlockRemap (Pixels, tex->GetWidth(), tex->GetHeight(), GPalette.Remap);
|
||||
if (Pixels == Canvas->GetBuffer())
|
||||
{
|
||||
FTexture::FlipSquareBlockBgra((uint32_t*)Pixels, tex->GetWidth(), tex->GetHeight());
|
||||
}
|
||||
else
|
||||
{
|
||||
FTexture::FlipNonSquareBlockBgra((uint32_t*)Pixels, (const uint32_t*)Canvas->GetBuffer(), tex->GetWidth(), tex->GetHeight(), Canvas->GetPitch());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FTexture::FlipNonSquareBlockRemap (Pixels, Canvas->GetBuffer(), tex->GetWidth(), tex->GetHeight(), Canvas->GetPitch(), GPalette.Remap);
|
||||
if (Pixels == Canvas->GetBuffer())
|
||||
{
|
||||
FTexture::FlipSquareBlockRemap(Pixels, tex->GetWidth(), tex->GetHeight(), GPalette.Remap);
|
||||
}
|
||||
else
|
||||
{
|
||||
FTexture::FlipNonSquareBlockRemap(Pixels, Canvas->GetBuffer(), tex->GetWidth(), tex->GetHeight(), Canvas->GetPitch(), GPalette.Remap);
|
||||
}
|
||||
}
|
||||
tex->SetUpdated();
|
||||
fixedcolormap = savecolormap;
|
||||
|
|
|
@ -53,7 +53,6 @@ FCanvasTexture::FCanvasTexture (const char *name, int width, int height)
|
|||
DummySpans[1].TopOffset = 0;
|
||||
DummySpans[1].Length = 0;
|
||||
UseType = TEX_Wall;
|
||||
Canvas = NULL;
|
||||
bNeedsUpdate = true;
|
||||
bDidUpdate = false;
|
||||
bHasCanvas = true;
|
||||
|
@ -101,6 +100,16 @@ const BYTE *FCanvasTexture::GetPixels ()
|
|||
return Pixels;
|
||||
}
|
||||
|
||||
const uint32_t *FCanvasTexture::GetPixelsBgra()
|
||||
{
|
||||
bNeedsUpdate = true;
|
||||
if (CanvasBgra == NULL)
|
||||
{
|
||||
MakeTextureBgra();
|
||||
}
|
||||
return PixelsBgra;
|
||||
}
|
||||
|
||||
void FCanvasTexture::MakeTexture ()
|
||||
{
|
||||
Canvas = new DSimpleCanvas (Width, Height, false);
|
||||
|
@ -123,21 +132,57 @@ void FCanvasTexture::MakeTexture ()
|
|||
memset (Pixels+Width*Height/2, 255, Width*Height/2);
|
||||
}
|
||||
|
||||
void FCanvasTexture::MakeTextureBgra()
|
||||
{
|
||||
CanvasBgra = new DSimpleCanvas(Width, Height, true);
|
||||
CanvasBgra->Lock();
|
||||
GC::AddSoftRoot(CanvasBgra);
|
||||
|
||||
if (Width != Height || Width != CanvasBgra->GetPitch())
|
||||
{
|
||||
PixelsBgra = new uint32_t[Width*Height];
|
||||
bPixelsAllocatedBgra = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
PixelsBgra = (uint32_t*)CanvasBgra->GetBuffer();
|
||||
bPixelsAllocatedBgra = false;
|
||||
}
|
||||
|
||||
// Draw a special "unrendered" initial texture into the buffer.
|
||||
memset(PixelsBgra, 0, Width*Height / 2 * 4);
|
||||
memset(PixelsBgra + Width*Height / 2, 255, Width*Height / 2 * 4);
|
||||
}
|
||||
|
||||
void FCanvasTexture::Unload ()
|
||||
{
|
||||
if (bPixelsAllocated)
|
||||
{
|
||||
if (Pixels != NULL) delete [] Pixels;
|
||||
if (Pixels != NULL) delete[] Pixels;
|
||||
bPixelsAllocated = false;
|
||||
Pixels = NULL;
|
||||
}
|
||||
|
||||
if (bPixelsAllocatedBgra)
|
||||
{
|
||||
if (PixelsBgra != NULL) delete[] PixelsBgra;
|
||||
bPixelsAllocatedBgra = false;
|
||||
PixelsBgra = NULL;
|
||||
}
|
||||
|
||||
if (Canvas != NULL)
|
||||
{
|
||||
GC::DelSoftRoot(Canvas);
|
||||
Canvas->Destroy();
|
||||
Canvas = NULL;
|
||||
}
|
||||
|
||||
if (CanvasBgra != NULL)
|
||||
{
|
||||
GC::DelSoftRoot(CanvasBgra);
|
||||
CanvasBgra->Destroy();
|
||||
CanvasBgra = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool FCanvasTexture::CheckModified ()
|
||||
|
|
|
@ -410,6 +410,29 @@ void FTexture::FlipSquareBlock (BYTE *block, int x, int y)
|
|||
}
|
||||
}
|
||||
|
||||
void FTexture::FlipSquareBlockBgra(uint32_t *block, int x, int y)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
if (x != y) return;
|
||||
|
||||
for (i = 0; i < x; ++i)
|
||||
{
|
||||
uint32_t *corner = block + x*i + i;
|
||||
int count = x - i;
|
||||
if (count & 1)
|
||||
{
|
||||
count--;
|
||||
swapvalues<uint32_t>(corner[count], corner[count*x]);
|
||||
}
|
||||
for (j = 0; j < count; j += 2)
|
||||
{
|
||||
swapvalues<uint32_t>(corner[j], corner[j*x]);
|
||||
swapvalues<uint32_t>(corner[j + 1], corner[(j + 1)*x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FTexture::FlipSquareBlockRemap (BYTE *block, int x, int y, const BYTE *remap)
|
||||
{
|
||||
int i, j;
|
||||
|
@ -453,6 +476,19 @@ void FTexture::FlipNonSquareBlock (BYTE *dst, const BYTE *src, int x, int y, int
|
|||
}
|
||||
}
|
||||
|
||||
void FTexture::FlipNonSquareBlockBgra(uint32_t *dst, const uint32_t *src, int x, int y, int srcpitch)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < x; ++i)
|
||||
{
|
||||
for (j = 0; j < y; ++j)
|
||||
{
|
||||
dst[i*y + j] = src[i + j*srcpitch];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FTexture::FlipNonSquareBlockRemap (BYTE *dst, const BYTE *src, int x, int y, int srcpitch, const BYTE *remap)
|
||||
{
|
||||
int i, j;
|
||||
|
|
|
@ -274,8 +274,10 @@ private:
|
|||
|
||||
public:
|
||||
static void FlipSquareBlock (BYTE *block, int x, int y);
|
||||
static void FlipSquareBlockBgra (uint32_t *block, int x, int y);
|
||||
static void FlipSquareBlockRemap (BYTE *block, int x, int y, const BYTE *remap);
|
||||
static void FlipNonSquareBlock (BYTE *blockto, const BYTE *blockfrom, int x, int y, int srcpitch);
|
||||
static void FlipNonSquareBlockBgra (uint32_t *blockto, const uint32_t *blockfrom, int x, int y, int srcpitch);
|
||||
static void FlipNonSquareBlockRemap (BYTE *blockto, const BYTE *blockfrom, int x, int y, int srcpitch, const BYTE *remap);
|
||||
|
||||
friend class D3DTex;
|
||||
|
@ -518,21 +520,27 @@ public:
|
|||
|
||||
const BYTE *GetColumn (unsigned int column, const Span **spans_out);
|
||||
const BYTE *GetPixels ();
|
||||
const uint32_t *GetPixelsBgra() override;
|
||||
void Unload ();
|
||||
bool CheckModified ();
|
||||
void NeedUpdate() { bNeedsUpdate=true; }
|
||||
void SetUpdated() { bNeedsUpdate = false; bDidUpdate = true; bFirstUpdate = false; }
|
||||
DSimpleCanvas *GetCanvas() { return Canvas; }
|
||||
DSimpleCanvas *GetCanvasBgra() { return CanvasBgra; }
|
||||
void MakeTexture ();
|
||||
void MakeTextureBgra ();
|
||||
|
||||
protected:
|
||||
|
||||
DSimpleCanvas *Canvas;
|
||||
BYTE *Pixels;
|
||||
DSimpleCanvas *Canvas = nullptr;
|
||||
DSimpleCanvas *CanvasBgra = nullptr;
|
||||
BYTE *Pixels = nullptr;
|
||||
uint32_t *PixelsBgra = nullptr;
|
||||
Span DummySpans[2];
|
||||
bool bNeedsUpdate;
|
||||
bool bDidUpdate;
|
||||
bool bPixelsAllocated;
|
||||
bool bNeedsUpdate = true;
|
||||
bool bDidUpdate = false;
|
||||
bool bPixelsAllocated = false;
|
||||
bool bPixelsAllocatedBgra = false;
|
||||
public:
|
||||
bool bFirstUpdate;
|
||||
|
||||
|
|
Loading…
Reference in a new issue