diff options
Diffstat (limited to 'indra/llrender')
| -rw-r--r-- | indra/llrender/llcubemaparray.cpp | 32 | ||||
| -rw-r--r-- | indra/llrender/llcubemaparray.h | 2 | 
2 files changed, 34 insertions, 0 deletions
| diff --git a/indra/llrender/llcubemaparray.cpp b/indra/llrender/llcubemaparray.cpp index d0a97dc2c6..998b57217d 100644 --- a/indra/llrender/llcubemaparray.cpp +++ b/indra/llrender/llcubemaparray.cpp @@ -105,6 +105,36 @@ LLCubeMapArray::LLCubeMapArray()  } +LLCubeMapArray::LLCubeMapArray(LLCubeMapArray& lhs, U32 width, U32 count) : mTextureStage(0) +{ +    mWidth = width; +    mCount = count; + +    // Allocate a new cubemap array with the same criteria as the incoming cubemap array +    allocate(mWidth, lhs.mImage->getComponents(), count, lhs.mImage->getUseMipMaps(), lhs.mHDR); + +    // Copy each cubemap from the incoming array to the new array +    U32 min_count = std::min(count, lhs.mCount); +    for (U32 i = 0; i < min_count * 6; ++i) +    { +        U32 src_resolution = lhs.mWidth; +        U32 dst_resolution = mWidth; +        { +            GLint components = GL_RGB; +            if (mImage->getComponents() == 4) +                components = GL_RGBA; +            GLint format = GL_RGB; + +            // Handle different resolutions by scaling the image +            LLPointer<LLImageRaw> src_image = new LLImageRaw(lhs.mWidth, lhs.mWidth, lhs.mImage->getComponents()); +            glGetTexImage(GL_TEXTURE_CUBE_MAP_ARRAY, 0, components, GL_UNSIGNED_BYTE, src_image->getData()); + +            LLPointer<LLImageRaw> scaled_image = src_image->scaled(mWidth, mWidth); +            glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, 0, 0, i, mWidth, mWidth, 1, components, GL_UNSIGNED_BYTE, scaled_image->getData()); +        } +    } +} +  LLCubeMapArray::~LLCubeMapArray()  {  } @@ -115,6 +145,8 @@ void LLCubeMapArray::allocate(U32 resolution, U32 components, U32 count, bool us      mWidth = resolution;      mCount = count; +    mHDR = hdr; +      LLImageGL::generateTextures(1, &texname);      mImage = new LLImageGL(resolution, resolution, components, use_mips); diff --git a/indra/llrender/llcubemaparray.h b/indra/llrender/llcubemaparray.h index bfc72a321d..6b4288cb23 100644 --- a/indra/llrender/llcubemaparray.h +++ b/indra/llrender/llcubemaparray.h @@ -36,6 +36,7 @@ class LLCubeMapArray : public LLRefCount  {  public:      LLCubeMapArray(); +    LLCubeMapArray(LLCubeMapArray& lhs, U32 width, U32 count);      static GLenum sTargets[6]; @@ -73,4 +74,5 @@ protected:      U32 mWidth = 0;      U32 mCount = 0;      S32 mTextureStage; +    bool mHDR;  }; | 
