mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 16:14:38 +00:00
straight convert of RGBA16F saving support for probes. should note gl side seems to be having an issue with loading probes thats resulting in color channel swapping.
This commit is contained in:
parent
9d560d9b12
commit
a9cb78b67f
1 changed files with 18 additions and 21 deletions
|
|
@ -149,14 +149,9 @@ bool GFXGLTextureObject::copyToBmp(GBitmap * bmp)
|
||||||
// check format limitations
|
// check format limitations
|
||||||
// at the moment we only support RGBA for the source (other 4 byte formats should
|
// at the moment we only support RGBA for the source (other 4 byte formats should
|
||||||
// be easy to add though)
|
// be easy to add though)
|
||||||
AssertFatal(mFormat == GFXFormatR8G8B8A8 || mFormat == GFXFormatR8G8B8A8_SRGB , "GFXGLTextureObject::copyToBmp - invalid format");
|
AssertFatal(mFormat == GFXFormatR16G16B16A16F || mFormat == GFXFormatR8G8B8A8 || mFormat == GFXFormatR8G8B8A8_LINEAR_FORCE || mFormat == GFXFormatR8G8B8A8_SRGB, "copyToBmp: invalid format");
|
||||||
AssertFatal(bmp->getFormat() == GFXFormatR8G8B8A8 || bmp->getFormat() == GFXFormatR8G8B8 || bmp->getFormat() == GFXFormatR8G8B8A8_SRGB, "GFXGLTextureObject::copyToBmp - invalid format");
|
if (mFormat != GFXFormatR16G16B16A16F && mFormat != GFXFormatR8G8B8A8 && mFormat != GFXFormatR8G8B8A8_LINEAR_FORCE && mFormat != GFXFormatR8G8B8A8_SRGB)
|
||||||
|
return false;
|
||||||
if(mFormat != GFXFormatR8G8B8A8 && mFormat != GFXFormatR8G8B8A8_SRGB)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if(bmp->getFormat() != GFXFormatR8G8B8A8 && bmp->getFormat() != GFXFormatR8G8B8 && bmp->getFormat() != GFXFormatR8G8B8A8_SRGB )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
AssertFatal(bmp->getWidth() == getWidth(), "GFXGLTextureObject::copyToBmp - invalid size");
|
AssertFatal(bmp->getWidth() == getWidth(), "GFXGLTextureObject::copyToBmp - invalid size");
|
||||||
AssertFatal(bmp->getHeight() == getHeight(), "GFXGLTextureObject::copyToBmp - invalid size");
|
AssertFatal(bmp->getHeight() == getHeight(), "GFXGLTextureObject::copyToBmp - invalid size");
|
||||||
|
|
@ -168,11 +163,6 @@ bool GFXGLTextureObject::copyToBmp(GBitmap * bmp)
|
||||||
|
|
||||||
U8 dstBytesPerPixel = GFXFormat_getByteSize( bmp->getFormat() );
|
U8 dstBytesPerPixel = GFXFormat_getByteSize( bmp->getFormat() );
|
||||||
U8 srcBytesPerPixel = GFXFormat_getByteSize( mFormat );
|
U8 srcBytesPerPixel = GFXFormat_getByteSize( mFormat );
|
||||||
if(dstBytesPerPixel == srcBytesPerPixel)
|
|
||||||
{
|
|
||||||
glGetTexImage(mBinding, 0, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], bmp->getWritableBits());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
FrameAllocatorMarker mem;
|
FrameAllocatorMarker mem;
|
||||||
|
|
||||||
|
|
@ -183,16 +173,23 @@ bool GFXGLTextureObject::copyToBmp(GBitmap * bmp)
|
||||||
glGetTexImage(mBinding, 0, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], orig);
|
glGetTexImage(mBinding, 0, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], orig);
|
||||||
|
|
||||||
PROFILE_START(GFXGLTextureObject_copyToBmp_pixCopy);
|
PROFILE_START(GFXGLTextureObject_copyToBmp_pixCopy);
|
||||||
for(int i = 0; i < srcPixelCount; ++i)
|
if (mFormat == GFXFormatR16G16B16A16F)
|
||||||
{
|
{
|
||||||
dest[0] = orig[0];
|
dMemcpy(dest, orig, sizeof(U16) * 4);
|
||||||
dest[1] = orig[1];
|
}
|
||||||
dest[2] = orig[2];
|
else
|
||||||
if(dstBytesPerPixel == 4)
|
{
|
||||||
dest[3] = orig[3];
|
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;
|
orig += srcBytesPerPixel;
|
||||||
dest += dstBytesPerPixel;
|
dest += dstBytesPerPixel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
PROFILE_END();
|
PROFILE_END();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue