mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-26 14:55:39 +00:00
timmy merge work
This commit is contained in:
parent
f1e584ca69
commit
ab10cc0c87
29 changed files with 295 additions and 925 deletions
|
|
@ -177,7 +177,7 @@ void GFXD3D11Cubemap::initStatic(DDSFile *dds)
|
|||
continue;
|
||||
|
||||
// convert to Z up
|
||||
const U32 faceIndex = _zUpFaceIndex(currentFace);
|
||||
const U32 faceIndex = zUpFaceIndex(currentFace);
|
||||
|
||||
for(U32 currentMip = 0; currentMip < mMipMapLevels; currentMip++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -909,6 +909,25 @@ void GFXD3D11Device::setShaderConstBufferInternal(GFXShaderConstBuffer* buffer)
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void GFXD3D11Device::copyResource(GFXTextureObject *pDst, GFXCubemap *pSrc, const U32 face)
|
||||
{
|
||||
AssertFatal(pDst, "GFXD3D11Device::copyResource: Destination texture is null");
|
||||
AssertFatal(pSrc, "GFXD3D11Device::copyResource: Source cubemap is null");
|
||||
|
||||
GFXD3D11TextureObject *pD3DDst = static_cast<GFXD3D11TextureObject*>(pDst);
|
||||
GFXD3D11Cubemap *pD3DSrc = static_cast<GFXD3D11Cubemap*>(pSrc);
|
||||
|
||||
const U32 mipLevels = pD3DSrc->getMipMapLevels();
|
||||
for (U32 mip = 0; mip < mipLevels; mip++)
|
||||
{
|
||||
const U32 srcSubResource = D3D11CalcSubresource(mip, face, mipLevels);
|
||||
const U32 dstSubResource = D3D11CalcSubresource(mip, 0, mipLevels);
|
||||
mD3DDeviceContext->CopySubresourceRegion(pD3DDst->get2DTex(), dstSubResource, 0, 0, 0, pD3DSrc->get2DTex(), srcSubResource, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void GFXD3D11Device::clear(U32 flags, const LinearColorF& color, F32 z, U32 stencil)
|
||||
{
|
||||
// Make sure we have flushed our render target state.
|
||||
|
|
|
|||
|
|
@ -239,6 +239,11 @@ public:
|
|||
virtual U32 getNumRenderTargets() const { return 8; }
|
||||
// }
|
||||
|
||||
// Copy methods
|
||||
// {
|
||||
virtual void copyResource(GFXTextureObject *pDst, GFXCubemap *pSrc, const U32 face);
|
||||
// }
|
||||
|
||||
// Misc rendering control
|
||||
// {
|
||||
virtual void clear( U32 flags, const LinearColorF& color, F32 z, U32 stencil );
|
||||
|
|
|
|||
|
|
@ -185,8 +185,7 @@ bool GFXD3D11TextureObject::copyToBmp(GBitmap* bmp)
|
|||
|
||||
AssertFatal(bmp->getWidth() == getWidth(), "GFXD3D11TextureObject::copyToBmp - source/dest width does not match");
|
||||
AssertFatal(bmp->getHeight() == getHeight(), "GFXD3D11TextureObject::copyToBmp - source/dest height does not match");
|
||||
const U32 width = getWidth();
|
||||
const U32 height = getHeight();
|
||||
const U32 mipLevels = getMipLevels();
|
||||
|
||||
bmp->setHasTransparency(mHasTransparency);
|
||||
|
||||
|
|
@ -221,52 +220,58 @@ bool GFXD3D11TextureObject::copyToBmp(GBitmap* bmp)
|
|||
//copy the classes texture to the staging texture
|
||||
D3D11DEVICECONTEXT->CopyResource(pStagingTexture, mD3DTexture);
|
||||
|
||||
//map the staging resource
|
||||
D3D11_MAPPED_SUBRESOURCE mappedRes;
|
||||
hr = D3D11DEVICECONTEXT->Map(pStagingTexture, 0, D3D11_MAP_READ, 0, &mappedRes);
|
||||
if (FAILED(hr))
|
||||
for (U32 mip = 0; mip < mipLevels; mip++)
|
||||
{
|
||||
//cleanup
|
||||
SAFE_RELEASE(pStagingTexture);
|
||||
Con::errorf("GFXD3D11TextureObject::copyToBmp - Failed to map staging texture");
|
||||
return false;
|
||||
}
|
||||
|
||||
// set pointers
|
||||
const U8* srcPtr = (U8*)mappedRes.pData;
|
||||
U8* destPtr = bmp->getWritableBits();
|
||||
|
||||
// we will want to skip over any D3D cache data in the source texture
|
||||
const S32 sourceCacheSize = mappedRes.RowPitch - width * sourceBytesPerPixel;
|
||||
AssertFatal(sourceCacheSize >= 0, "GFXD3D11TextureObject::copyToBmp - cache size is less than zero?");
|
||||
|
||||
// copy data into bitmap
|
||||
for (U32 row = 0; row < height; ++row)
|
||||
{
|
||||
for (U32 col = 0; col < width; ++col)
|
||||
const U32 width = bmp->getWidth(mip);
|
||||
const U32 height = bmp->getHeight(mip);
|
||||
//map the staging resource
|
||||
D3D11_MAPPED_SUBRESOURCE mappedRes;
|
||||
const U32 subResource = D3D11CalcSubresource(mip, 0, mipLevels);
|
||||
hr = D3D11DEVICECONTEXT->Map(pStagingTexture, subResource, D3D11_MAP_READ, 0, &mappedRes);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
destPtr[0] = srcPtr[2]; // red
|
||||
destPtr[1] = srcPtr[1]; // green
|
||||
destPtr[2] = srcPtr[0]; // blue
|
||||
if (destBytesPerPixel == 4)
|
||||
destPtr[3] = srcPtr[3]; // alpha
|
||||
|
||||
// go to next pixel in src
|
||||
srcPtr += sourceBytesPerPixel;
|
||||
|
||||
// go to next pixel in dest
|
||||
destPtr += destBytesPerPixel;
|
||||
//cleanup
|
||||
SAFE_RELEASE(pStagingTexture);
|
||||
Con::errorf("GFXD3D11TextureObject::copyToBmp - Failed to map staging texture");
|
||||
return false;
|
||||
}
|
||||
// skip past the cache data for this row (if any)
|
||||
srcPtr += sourceCacheSize;
|
||||
|
||||
// set pointers
|
||||
const U8* srcPtr = (U8*)mappedRes.pData;
|
||||
U8* destPtr = bmp->getWritableBits(mip);
|
||||
|
||||
// we will want to skip over any D3D cache data in the source texture
|
||||
const S32 sourceCacheSize = mappedRes.RowPitch - width * sourceBytesPerPixel;
|
||||
AssertFatal(sourceCacheSize >= 0, "GFXD3D11TextureObject::copyToBmp - cache size is less than zero?");
|
||||
|
||||
// copy data into bitmap
|
||||
for (U32 row = 0; row < height; ++row)
|
||||
{
|
||||
for (U32 col = 0; col < width; ++col)
|
||||
{
|
||||
destPtr[0] = srcPtr[2]; // red
|
||||
destPtr[1] = srcPtr[1]; // green
|
||||
destPtr[2] = srcPtr[0]; // blue
|
||||
if (destBytesPerPixel == 4)
|
||||
destPtr[3] = srcPtr[3]; // alpha
|
||||
|
||||
// go to next pixel in src
|
||||
srcPtr += sourceBytesPerPixel;
|
||||
|
||||
// go to next pixel in dest
|
||||
destPtr += destBytesPerPixel;
|
||||
}
|
||||
// skip past the cache data for this row (if any)
|
||||
srcPtr += sourceCacheSize;
|
||||
}
|
||||
|
||||
// assert if we stomped or underran memory
|
||||
AssertFatal(U32(destPtr - bmp->getWritableBits(mip)) == width * height * destBytesPerPixel, "GFXD3D11TextureObject::copyToBmp - memory error");
|
||||
AssertFatal(U32(srcPtr - (U8*)mappedRes.pData) == height * mappedRes.RowPitch, "GFXD3D11TextureObject::copyToBmp - memory error");
|
||||
|
||||
D3D11DEVICECONTEXT->Unmap(pStagingTexture, subResource);
|
||||
}
|
||||
|
||||
// assert if we stomped or underran memory
|
||||
AssertFatal(U32(destPtr - bmp->getWritableBits()) == width * height * destBytesPerPixel, "GFXD3D11TextureObject::copyToBmp - memory error");
|
||||
AssertFatal(U32(srcPtr - (U8*)mappedRes.pData) == height * mappedRes.RowPitch, "GFXD3D11TextureObject::copyToBmp - memory error");
|
||||
|
||||
D3D11DEVICECONTEXT->Unmap(pStagingTexture, 0);
|
||||
|
||||
SAFE_RELEASE(pStagingTexture);
|
||||
PROFILE_END();
|
||||
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ public:
|
|||
|
||||
virtual GFXShader* createShader() { return NULL; };
|
||||
|
||||
|
||||
virtual void copyResource(GFXTextureObject *pDst, GFXCubemap *pSrc, const U32 face) { };
|
||||
virtual void clear( U32 flags, const LinearColorF& color, F32 z, U32 stencil ) { };
|
||||
virtual void clearColorAttachment(const U32 attachment, const LinearColorF& color) { };
|
||||
virtual bool beginSceneInternal() { return true; };
|
||||
|
|
|
|||
|
|
@ -32,29 +32,10 @@
|
|||
#include "math/mathUtils.h"
|
||||
#include "math/mTransform.h"
|
||||
|
||||
|
||||
namespace CubemapSaver
|
||||
{
|
||||
const U32 CubeFaces = 6;
|
||||
|
||||
void _setConstBuffer(GFXShaderConstHandle* handle, GFXShaderConstBuffer *cbuf, const VectorF &vLookatPt, const VectorF &vUpVec)
|
||||
{
|
||||
VectorF cross = mCross(vUpVec, vLookatPt);
|
||||
cross.normalizeSafe();
|
||||
|
||||
MatrixF matView(true);
|
||||
matView.setColumn(0, cross);
|
||||
matView.setColumn(1, vLookatPt);
|
||||
matView.setColumn(2, vUpVec);
|
||||
matView.setPosition(VectorF(0.0f, 0.0f, 1.0f));
|
||||
matView.inverse();
|
||||
|
||||
if (handle->isValid())
|
||||
cbuf->set(handle, matView);
|
||||
else
|
||||
Con::errorf("CubemapSaver: Failed to set a shader constant handle.");
|
||||
}
|
||||
|
||||
bool save(GFXCubemapHandle cubemap, const Torque::Path &path, GFXFormat compressionFormat)
|
||||
{
|
||||
if (!cubemap.isValid())
|
||||
|
|
@ -63,93 +44,40 @@ namespace CubemapSaver
|
|||
return false;
|
||||
}
|
||||
|
||||
// This can sometimes occur outside a begin/end scene.
|
||||
const bool sceneBegun = GFX->canCurrentlyRender();
|
||||
if (!sceneBegun)
|
||||
GFX->beginScene();
|
||||
|
||||
GFXCubemap *pCubemap = cubemap.getPointer();
|
||||
U32 faceSize = pCubemap->getSize();
|
||||
const U32 faceSize = pCubemap->getSize();
|
||||
const U32 mipLevels = pCubemap->getMipMapLevels();
|
||||
|
||||
ShaderData *shaderData = nullptr;
|
||||
GFXShaderRef shader = Sim::findObject("CubemapSaveShader", shaderData) ? shaderData->getShader() : nullptr;
|
||||
if (!shader)
|
||||
{
|
||||
Con::errorf("CubemapSaver::save - could not find CubemapSaveShader");
|
||||
return false;
|
||||
}
|
||||
|
||||
GFXShaderConstHandle *matHandles[CubeFaces];
|
||||
|
||||
matHandles[0] = shader->getShaderConstHandle("$matrix0");
|
||||
matHandles[1] = shader->getShaderConstHandle("$matrix1");
|
||||
matHandles[2] = shader->getShaderConstHandle("$matrix2");
|
||||
matHandles[3] = shader->getShaderConstHandle("$matrix3");
|
||||
matHandles[4] = shader->getShaderConstHandle("$matrix4");
|
||||
matHandles[5] = shader->getShaderConstHandle("$matrix5");
|
||||
|
||||
GFXShaderConstBufferRef cbuffer = shader->allocConstBuffer();
|
||||
|
||||
GFXTextureTarget *pTarget = GFX->allocRenderToTextureTarget();
|
||||
GFX->pushActiveRenderTarget();
|
||||
|
||||
GFXFormat renderTargetFmt = GFXFormatR8G8B8A8;
|
||||
GFXFormat targetFmt = pCubemap->getFormat();
|
||||
//setup render targets
|
||||
GFXTexHandle pTextures[CubeFaces];
|
||||
for (U32 i = 0; i < CubeFaces; i++)
|
||||
for (U32 face = 0; face < CubeFaces; face++)
|
||||
{
|
||||
pTextures[i].set(faceSize, faceSize, renderTargetFmt,
|
||||
&GFXRenderTargetProfile, avar("%s() - (line %d)", __FUNCTION__, __LINE__),
|
||||
1, GFXTextureManager::AA_MATCH_BACKBUFFER);
|
||||
pTextures[face].set(faceSize, faceSize, targetFmt,
|
||||
&GFXStaticTextureProfile, avar("%s() - (line %d)", __FUNCTION__, __LINE__),
|
||||
mipLevels, GFXTextureManager::AA_MATCH_BACKBUFFER);
|
||||
|
||||
pTarget->attachTexture(GFXTextureTarget::RenderSlot(GFXTextureTarget::Color0 + i), pTextures[i]);
|
||||
// yep t3d has funky z up, need to change the face order
|
||||
GFX->copyResource(pTextures[face], pCubemap, GFXCubemap::zUpFaceIndex(face) );
|
||||
}
|
||||
|
||||
//create stateblock
|
||||
GFXStateBlockDesc desc;
|
||||
desc.setZReadWrite(false, false);
|
||||
desc.samplersDefined = true;
|
||||
desc.samplers[0].addressModeU = GFXAddressClamp;
|
||||
desc.samplers[0].addressModeV = GFXAddressClamp;
|
||||
desc.samplers[0].addressModeW = GFXAddressClamp;
|
||||
desc.samplers[0].magFilter = GFXTextureFilterLinear;
|
||||
desc.samplers[0].minFilter = GFXTextureFilterLinear;
|
||||
desc.samplers[0].mipFilter = GFXTextureFilterLinear;
|
||||
|
||||
//yep funky order and rotations with t3d z up
|
||||
_setConstBuffer(matHandles[0], cbuffer, VectorF(0.0f, 1.0f, 0.0f), VectorF(-1.0f, 0.0f, 0.0f));
|
||||
_setConstBuffer(matHandles[1], cbuffer, VectorF(0.0f, 1.0f, 0.0f), VectorF(1.0f, 0.0f, 0.0f));
|
||||
_setConstBuffer(matHandles[2], cbuffer, VectorF(0.0f, 1.0f, 0.0f), VectorF(0.0f, 0.0f, -1.0f));
|
||||
_setConstBuffer(matHandles[3], cbuffer, VectorF(0.0f, 1.0f, 0.0f), VectorF(0.0f, 0.0f, 1.0f));
|
||||
_setConstBuffer(matHandles[4], cbuffer, VectorF(0.0f, 0.0f, -1.0f), VectorF(0.0f, -1.0f, 0.0f));
|
||||
_setConstBuffer(matHandles[5], cbuffer, VectorF(0.0f, 0.0f, 1.0f), VectorF(0.0f, 1.0f, 0.0f));
|
||||
|
||||
GFXTransformSaver saver;
|
||||
GFX->setActiveRenderTarget(pTarget);
|
||||
GFX->clear(GFXClearTarget, ColorI(0, 0, 0, 0), 1.0f, 0);
|
||||
GFX->setStateBlockByDesc(desc);
|
||||
GFX->setWorldMatrix(MatrixF::Identity);
|
||||
GFX->setProjectionMatrix(MatrixF::Identity);
|
||||
GFX->setCubeTexture(0, pCubemap);
|
||||
GFX->setShaderConstBuffer(cbuffer);
|
||||
GFX->setShader(shader);
|
||||
GFX->drawPrimitive(GFXTriangleList, 0, 3);
|
||||
pTarget->resolve();
|
||||
|
||||
GBitmap *pBitmaps[CubeFaces];
|
||||
bool error = false;
|
||||
const bool compressedFormat = ImageUtil::isCompressedFormat(compressionFormat);
|
||||
const bool hasMips = mipLevels > 1 ? true : false;
|
||||
for (U32 i = 0; i < CubeFaces; i++)
|
||||
{
|
||||
pBitmaps[i] = new GBitmap(faceSize, faceSize, false, renderTargetFmt);
|
||||
pBitmaps[i] = new GBitmap(faceSize, faceSize, hasMips, targetFmt);
|
||||
bool result = pTextures[i].copyToBmp(pBitmaps[i]);
|
||||
if (!result)
|
||||
{
|
||||
Con::errorf("CubemapSaver: cubemap number %u failed to copy", i);
|
||||
error = true;
|
||||
}
|
||||
//gen mip maps
|
||||
pBitmaps[i]->extrudeMipLevels();
|
||||
//gen mip maps if there are none
|
||||
if(!hasMips)
|
||||
pBitmaps[i]->extrudeMipLevels();
|
||||
}
|
||||
|
||||
if (!error)
|
||||
|
|
@ -176,20 +104,10 @@ namespace CubemapSaver
|
|||
}
|
||||
}
|
||||
|
||||
//cleanup
|
||||
for (U32 i = 0; i < CubeFaces; i++)
|
||||
SAFE_DELETE(pBitmaps[i]);
|
||||
|
||||
//cleaup
|
||||
GFX->popActiveRenderTarget();
|
||||
GFX->setTexture(0, NULL);
|
||||
GFX->setShader(NULL);
|
||||
GFX->setShaderConstBuffer(NULL);
|
||||
GFX->setVertexBuffer(NULL);
|
||||
|
||||
// End it if we begun it.
|
||||
if (!sceneBegun)
|
||||
GFX->endScene();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -202,135 +120,6 @@ namespace CubemapSaver
|
|||
return false;
|
||||
}
|
||||
|
||||
// This can sometimes occur outside a begin/end scene.
|
||||
const bool sceneBegun = GFX->canCurrentlyRender();
|
||||
if (!sceneBegun)
|
||||
GFX->beginScene();
|
||||
|
||||
GFXCubemap *pCubemap = cubemap.getPointer();
|
||||
U32 faceSize = pCubemap->getSize();
|
||||
|
||||
ShaderData *shaderData = nullptr;
|
||||
GFXShaderRef shader = Sim::findObject("CubemapSaveShader", shaderData) ? shaderData->getShader() : nullptr;
|
||||
if (!shader)
|
||||
{
|
||||
Con::errorf("CubemapSaver::save - could not find CubemapSaveShader");
|
||||
return false;
|
||||
}
|
||||
|
||||
GFXShaderConstHandle *matHandles[CubeFaces];
|
||||
|
||||
matHandles[0] = shader->getShaderConstHandle("$matrix0");
|
||||
matHandles[1] = shader->getShaderConstHandle("$matrix1");
|
||||
matHandles[2] = shader->getShaderConstHandle("$matrix2");
|
||||
matHandles[3] = shader->getShaderConstHandle("$matrix3");
|
||||
matHandles[4] = shader->getShaderConstHandle("$matrix4");
|
||||
matHandles[5] = shader->getShaderConstHandle("$matrix5");
|
||||
|
||||
GFXShaderConstBufferRef cbuffer = shader->allocConstBuffer();
|
||||
|
||||
GFXTextureTarget *pTarget = GFX->allocRenderToTextureTarget();
|
||||
GFX->pushActiveRenderTarget();
|
||||
|
||||
GFXFormat renderTargetFmt = GFXFormatR8G8B8A8;
|
||||
//setup render targets
|
||||
GFXTexHandle pTextures[CubeFaces];
|
||||
for (U32 i = 0; i < CubeFaces; i++)
|
||||
{
|
||||
pTextures[i].set(faceSize, faceSize, renderTargetFmt,
|
||||
&GFXRenderTargetProfile, avar("%s() - (line %d)", __FUNCTION__, __LINE__),
|
||||
1, GFXTextureManager::AA_MATCH_BACKBUFFER);
|
||||
|
||||
pTarget->attachTexture(GFXTextureTarget::RenderSlot(GFXTextureTarget::Color0 + i), pTextures[i]);
|
||||
}
|
||||
|
||||
//create stateblock
|
||||
GFXStateBlockDesc desc;
|
||||
desc.setZReadWrite(false, false);
|
||||
desc.samplersDefined = true;
|
||||
desc.samplers[0].addressModeU = GFXAddressClamp;
|
||||
desc.samplers[0].addressModeV = GFXAddressClamp;
|
||||
desc.samplers[0].addressModeW = GFXAddressClamp;
|
||||
desc.samplers[0].magFilter = GFXTextureFilterLinear;
|
||||
desc.samplers[0].minFilter = GFXTextureFilterLinear;
|
||||
desc.samplers[0].mipFilter = GFXTextureFilterLinear;
|
||||
|
||||
//yep funky order and rotations with t3d z up
|
||||
_setConstBuffer(matHandles[0], cbuffer, VectorF(0.0f, 1.0f, 0.0f), VectorF(-1.0f, 0.0f, 0.0f));
|
||||
_setConstBuffer(matHandles[1], cbuffer, VectorF(0.0f, 1.0f, 0.0f), VectorF(1.0f, 0.0f, 0.0f));
|
||||
_setConstBuffer(matHandles[2], cbuffer, VectorF(0.0f, 1.0f, 0.0f), VectorF(0.0f, 0.0f, -1.0f));
|
||||
_setConstBuffer(matHandles[3], cbuffer, VectorF(0.0f, 1.0f, 0.0f), VectorF(0.0f, 0.0f, 1.0f));
|
||||
_setConstBuffer(matHandles[4], cbuffer, VectorF(0.0f, 0.0f, -1.0f), VectorF(0.0f, -1.0f, 0.0f));
|
||||
_setConstBuffer(matHandles[5], cbuffer, VectorF(0.0f, 0.0f, 1.0f), VectorF(0.0f, 1.0f, 0.0f));
|
||||
|
||||
GFXTransformSaver saver;
|
||||
GFX->setActiveRenderTarget(pTarget);
|
||||
GFX->clear(GFXClearTarget, ColorI(0, 0, 0, 0), 1.0f, 0);
|
||||
GFX->setStateBlockByDesc(desc);
|
||||
GFX->setWorldMatrix(MatrixF::Identity);
|
||||
GFX->setProjectionMatrix(MatrixF::Identity);
|
||||
GFX->setCubeTexture(0, pCubemap);
|
||||
GFX->setShaderConstBuffer(cbuffer);
|
||||
GFX->setShader(shader);
|
||||
GFX->drawPrimitive(GFXTriangleList, 0, 3);
|
||||
pTarget->resolve();
|
||||
|
||||
bool error = false;
|
||||
const bool compressedFormat = ImageUtil::isCompressedFormat(compressionFormat);
|
||||
for (U32 i = 0; i < CubeFaces; i++)
|
||||
{
|
||||
//faceBitmaps[i] = new GBitmap(faceSize, faceSize, false, renderTargetFmt);
|
||||
bool result = pTextures[i].copyToBmp(faceBitmaps[i]);
|
||||
if (!result)
|
||||
{
|
||||
Con::errorf("CubemapSaver: cubemap number %u failed to copy", i);
|
||||
error = true;
|
||||
}
|
||||
//gen mip maps
|
||||
faceBitmaps[i]->extrudeMipLevels();
|
||||
}
|
||||
|
||||
/*if (!error)
|
||||
{
|
||||
DDSFile *pDds = DDSFile::createDDSCubemapFileFromGBitmaps(pBitmaps);
|
||||
if (pDds)
|
||||
{
|
||||
// non compressed format needs swizzling
|
||||
if (!compressedFormat)
|
||||
ImageUtil::swizzleDDS(pDds, Swizzles::bgra);
|
||||
|
||||
if (compressedFormat)
|
||||
ImageUtil::ddsCompress(pDds, compressionFormat);
|
||||
|
||||
FileStream stream;
|
||||
stream.open(path, Torque::FS::File::Write);
|
||||
|
||||
if (stream.getStatus() == Stream::Ok)
|
||||
pDds->write(stream);
|
||||
else
|
||||
Con::errorf("CubemapSaver: failed to open file stream for file %s", path.getFullPath().c_str());
|
||||
|
||||
SAFE_DELETE(pDds);
|
||||
}
|
||||
}
|
||||
|
||||
for (U32 i = 0; i < CubeFaces; i++)
|
||||
SAFE_DELETE(pBitmaps[i]);*/
|
||||
|
||||
//cleaup
|
||||
GFX->popActiveRenderTarget();
|
||||
GFX->setTexture(0, NULL);
|
||||
GFX->setShader(NULL);
|
||||
GFX->setShaderConstBuffer(NULL);
|
||||
GFX->setVertexBuffer(NULL);
|
||||
|
||||
// End it if we begun it.
|
||||
if (!sceneBegun)
|
||||
GFX->endScene();
|
||||
|
||||
if (error)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ GFXCubemap::~GFXCubemap()
|
|||
TEXMGR->releaseCubemap( this );
|
||||
}
|
||||
|
||||
U32 GFXCubemap::_zUpFaceIndex(const U32 index)
|
||||
U32 GFXCubemap::zUpFaceIndex(const U32 index)
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -47,8 +47,6 @@ protected:
|
|||
/// Sets the cubemap file path.
|
||||
void _setPath( const String &path ) { mPath = path; }
|
||||
|
||||
/// Get Z up face index of the cubemap. DDS files will be stored Y up
|
||||
U32 _zUpFaceIndex(const U32 index);
|
||||
|
||||
U32 mMipMapLevels;
|
||||
public:
|
||||
|
|
@ -81,6 +79,9 @@ public:
|
|||
|
||||
/// Get the number of mip maps
|
||||
const U32 getMipMapLevels() const { return mMipMapLevels; }
|
||||
|
||||
/// Get Z up face index of the cubemap. DDS files will be stored Y up
|
||||
static U32 zUpFaceIndex(const U32 index);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -826,6 +826,13 @@ public:
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/// @name Copying methods
|
||||
/// @{
|
||||
|
||||
virtual void copyResource(GFXTextureObject *pDst, GFXCubemap *pSrc, const U32 face) = 0;
|
||||
|
||||
/// @}
|
||||
|
||||
/// @name Rendering methods
|
||||
/// @{
|
||||
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ void GFXGLCubemap::initStatic( DDSFile *dds )
|
|||
}
|
||||
|
||||
// convert to Z up
|
||||
const U32 faceIndex = _zUpFaceIndex(i);
|
||||
const U32 faceIndex = zUpFaceIndex(i);
|
||||
|
||||
// Now loop thru the mip levels!
|
||||
for (U32 mip = 0; mip < mMipMapLevels; ++mip)
|
||||
|
|
|
|||
|
|
@ -116,7 +116,8 @@ public:
|
|||
virtual U32 getNumRenderTargets() const;
|
||||
|
||||
virtual GFXShader* createShader();
|
||||
|
||||
//TODO: implement me!
|
||||
virtual void copyResource(GFXTextureObject *pDst, GFXCubemap *pSrc, const U32 face) {};
|
||||
virtual void clear( U32 flags, const LinearColorF& color, F32 z, U32 stencil );
|
||||
virtual void clearColorAttachment(const U32 attachment, const LinearColorF& color);
|
||||
virtual bool beginSceneInternal();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue