mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-21 15:43:45 +00:00
implement copyResource, fix copyToBmp
GFXFormatR16G16B16A16F case wasn't accounting for mips, nor was it using the right memcpy aperture
This commit is contained in:
parent
f6a2149dd1
commit
1f37bdb786
3 changed files with 67 additions and 22 deletions
|
|
@ -175,30 +175,37 @@ bool GFXGLTextureObject::copyToBmp(GBitmap * bmp)
|
|||
|
||||
FrameAllocatorMarker mem;
|
||||
|
||||
U32 srcPixelCount = mTextureSize.x * mTextureSize.y;
|
||||
U8 *dest = bmp->getWritableBits();
|
||||
U8 *orig = (U8*)mem.alloc(srcPixelCount * srcBytesPerPixel);
|
||||
|
||||
glGetTexImage(mBinding, 0, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], orig);
|
||||
|
||||
PROFILE_START(GFXGLTextureObject_copyToBmp_pixCopy);
|
||||
if (mFormat == GFXFormatR16G16B16A16F)
|
||||
U32 mipLevels = getMipLevels();
|
||||
if (mipLevels < 1) mipLevels = 1;//ensure we loop at least the once
|
||||
for (U32 mip = 0; mip < mipLevels; mip++)
|
||||
{
|
||||
dMemcpy(dest, orig, sizeof(U16) * 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < srcPixelCount; ++i)
|
||||
{
|
||||
dest[0] = orig[0];
|
||||
dest[1] = orig[1];
|
||||
dest[2] = orig[2];
|
||||
if (dstBytesPerPixel == 4)
|
||||
dest[3] = orig[3];
|
||||
U32 srcPixelCount = bmp->getSurfaceSize(mip)/ srcBytesPerPixel;
|
||||
|
||||
orig += srcBytesPerPixel;
|
||||
dest += dstBytesPerPixel;
|
||||
}
|
||||
U8* dest = bmp->getWritableBits(mip);
|
||||
U8* orig = (U8*)mem.alloc(srcPixelCount * srcBytesPerPixel);
|
||||
|
||||
glGetTexImage(mBinding, mip, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], orig);
|
||||
|
||||
PROFILE_START(GFXGLTextureObject_copyToBmp_pixCopy);
|
||||
if (mFormat == GFXFormatR16G16B16A16F)
|
||||
{
|
||||
dMemcpy(dest, orig, srcPixelCount * sizeof(U16) * 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < srcPixelCount; ++i)
|
||||
{
|
||||
dest[0] = orig[0];
|
||||
dest[1] = orig[1];
|
||||
dest[2] = orig[2];
|
||||
if (dstBytesPerPixel == 4)
|
||||
dest[3] = orig[3];
|
||||
|
||||
orig += srcBytesPerPixel;
|
||||
dest += dstBytesPerPixel;
|
||||
}
|
||||
}
|
||||
}
|
||||
PROFILE_END();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue