Fix cameras and kdizd intro for true color mode

This commit is contained in:
Magnus Norddahl 2016-06-13 03:16:48 +02:00
commit cc10c2a970
5 changed files with 126 additions and 16 deletions

View file

@ -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 ()