浏览代码

1) bumped bytesPerTexel on up to 8 and got rid of the explicit fillin
2) fed glTexSubImage3D GL_RGBA instead of a second GFXGLTextureType[mFormat]. this tells it what order colors come in, not what size
3)for safeties sake, skipped out on updatetexture if the fed cubemap isn't initialized yet

AzaezelX 6 年之前
父节点
当前提交
d766348867
共有 1 个文件被更改,包括 6 次插入13 次删除
  1. 6 13
      Engine/source/gfx/gl/gfxGLCubemap.cpp

+ 6 - 13
Engine/source/gfx/gl/gfxGLCubemap.cpp

@@ -290,24 +290,19 @@ U8* GFXGLCubemap::getTextureData(U32 face, U32 mip)
 {
    AssertFatal(mMipMapLevels, "");
    mip = (mip < mMipMapLevels) ? mip : 0;
-   const U32 bytesPerTexel = 4; //TODO make work with more formats!!!!!
+   const U32 bytesPerTexel = 8; //TODO make work with more formats!!!!!
    const U32 dataSize = ImageUtil::isCompressedFormat(mFaceFormat)
       ? getCompressedSurfaceSize(mFaceFormat, mWidth, mHeight, mip)
       : (mWidth >> mip) * (mHeight >> mip) * bytesPerTexel;
 
    U8* data = new U8[dataSize];
-
-   for (U32 i = 0; i < dataSize; i++)
-   {
-      data[i] = 1;
-   }
-   /*PRESERVE_TEXTURE(GL_TEXTURE_CUBE_MAP);
+   PRESERVE_TEXTURE(GL_TEXTURE_CUBE_MAP);
    glBindTexture(GL_TEXTURE_CUBE_MAP, mCubemap);
 
    if (ImageUtil::isCompressedFormat(mFaceFormat))
       glGetCompressedTexImage(faceList[face], mip, data);
    else
-      glGetTexImage(faceList[face], mip, GFXGLTextureFormat[mFaceFormat], GFXGLTextureType[mFaceFormat], data);*/
+      glGetTexImage(faceList[face], mip, GFXGLTextureFormat[mFaceFormat], GFXGLTextureType[mFaceFormat], data);
 
    return data;
 }
@@ -367,7 +362,7 @@ void GFXGLCubemapArray::init(GFXCubemapHandle *cubemaps, const U32 cubemapCount)
             }
             else
             {*/                                                      //TODO figure out xyzOffsets
-            glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, currentMip, 0, 0, 0, mipSize, mipSize, i * face, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], pixelData);
+            glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, currentMip, 0, 0, 0, mipSize, mipSize, i * face, GL_RGBA, GFXGLTextureType[mFormat], pixelData);
             //}
             delete[] pixelData;
          }
@@ -432,7 +427,8 @@ void GFXGLCubemapArray::init(const U32 cubemapCount, const U32 cubemapFaceSize,
 void GFXGLCubemapArray::updateTexture(const GFXCubemapHandle &cubemap, const U32 slot)
 {
    AssertFatal(slot <= mNumCubemaps, "GFXD3D11CubemapArray::updateTexture - trying to update a cubemap texture that is out of bounds!");
-
+   if (!cubemap->isInitialized())
+      return;
    const bool isCompressed = ImageUtil::isCompressedFormat(mFormat);
 
     GFXGLCubemap* glTex = static_cast<GFXGLCubemap*>(cubemap.getPointer());
@@ -456,9 +452,6 @@ void GFXGLCubemapArray::updateTexture(const GFXCubemapHandle &cubemap, const U32
          delete[] pixelData;
       }
    }
-
-   bool tmp = true;
-   bool asdf = true;
 }
 
 void GFXGLCubemapArray::copyTo(GFXCubemapArray *pDstCubemap)