From 093f50bd9dc3729fb31264ea40f032affbf2847c Mon Sep 17 00:00:00 2001 From: Areloch Date: Sat, 27 Apr 2019 03:09:01 -0500 Subject: [PATCH] Make the gl cubemap array init that takes a pointer list of cubemaps actually have parity to the updateTexture gl calls(aka, actually works). --- Engine/source/gfx/gl/gfxGLCubemap.cpp | 53 ++++++++------------------- 1 file changed, 15 insertions(+), 38 deletions(-) diff --git a/Engine/source/gfx/gl/gfxGLCubemap.cpp b/Engine/source/gfx/gl/gfxGLCubemap.cpp index 1ab76fd88..94ec2421f 100644 --- a/Engine/source/gfx/gl/gfxGLCubemap.cpp +++ b/Engine/source/gfx/gl/gfxGLCubemap.cpp @@ -343,27 +343,28 @@ void GFXGLCubemapArray::init(GFXCubemapHandle *cubemaps, const U32 cubemapCount) glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); - glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GFXGLTextureInternalFormat[mFormat], mSize, mSize, cubemapCount * 6, 0, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], NULL); - for (U32 i = 0; i < cubemapCount; i++) { GFXGLCubemap* glTex = static_cast(cubemaps[i].getPointer()); for (U32 face = 0; face < 6; face++) { for (U32 currentMip = 0; currentMip < mMipMapLevels; currentMip++) - //U32 currentMip = 0; { U8 *pixelData = glTex->getTextureData(face, currentMip); + + glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, mCubemap); const U32 mipSize = getMax(U32(1), mSize >> currentMip); /*if (isCompressed) { const U32 mipDataSize = getCompressedSurfaceSize(mFormat, mSize, mSize, currentMip); - glCompressedTexImage2D(faceList[face], currentMip, GFXGLTextureInternalFormat[mFormat], mipSize, mipSize, 0, mipDataSize, pixelData); + glCompressedTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, currentMip, GFXGLTextureInternalFormat[mFormat], mipSize, mipSize, 0, mipDataSize, pixelData); } else - {*/ //TODO figure out xyzOffsets - glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, currentMip, 0, 0, 0, mipSize, mipSize, i * face, GL_RGBA, GFXGLTextureType[mFormat], pixelData); + {*/ + glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, currentMip, 0, 0, i * 6 + face, mipSize, mipSize, 1, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], pixelData); //} + glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, 0); + delete[] pixelData; } } @@ -396,32 +397,6 @@ void GFXGLCubemapArray::init(const U32 cubemapCount, const U32 cubemapFaceSize, glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); - - - - /*for (U32 i = 0; i < cubemapCount; i++) - { - GFXGLCubemap* glTex = static_cast(cubemaps[i].getPointer()); - for (U32 face = 0; face < 6; face++) - { - for (U32 currentMip = 0; currentMip < mMipMapLevels; currentMip++) - { - U8 *pixelData = glTex->getTextureData(face, currentMip); - const U32 mipSize = getMax(U32(1), mSize >> currentMip); - if (isCompressed) - { - const U32 mipDataSize = getCompressedSurfaceSize(mFormat, mSize, mSize, currentMip); - glCompressedTexImage2D(faceList[face], currentMip, GFXGLTextureInternalFormat[mFormat], mipSize, mipSize, 0, mipDataSize, pixelData); - } - else - { - glTexImage2D(faceList[face], currentMip, GFXGLTextureInternalFormat[mFormat], mipSize, mipSize, - 0, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], pixelData); - } - delete[] pixelData; - } - } - }*/ } void GFXGLCubemapArray::updateTexture(const GFXCubemapHandle &cubemap, const U32 slot) @@ -431,24 +406,26 @@ void GFXGLCubemapArray::updateTexture(const GFXCubemapHandle &cubemap, const U32 return; const bool isCompressed = ImageUtil::isCompressedFormat(mFormat); - GFXGLCubemap* glTex = static_cast(cubemap.getPointer()); + GFXGLCubemap* glTex = static_cast(cubemap.getPointer()); for (U32 face = 0; face < 6; face++) { for (U32 currentMip = 0; currentMip < mMipMapLevels; currentMip++) { U8 *pixelData = glTex->getTextureData(face, currentMip); + + glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, mCubemap); const U32 mipSize = getMax(U32(1), mSize >> currentMip); /*if (isCompressed) { const U32 mipDataSize = getCompressedSurfaceSize(mFormat, mSize, mSize, currentMip); - glCompressedTexImage2D(faceList[face], currentMip, GFXGLTextureInternalFormat[mFormat], mipSize, mipSize, 0, mipDataSize, pixelData); + glCompressedTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, currentMip, GFXGLTextureInternalFormat[mFormat], mipSize, mipSize, 0, mipDataSize, pixelData); } else - {*/ //TODO figure out xyzOffsets - glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, mCubemap); - glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, currentMip, 0, 0, slot * 6 + face, mipSize, mipSize, 1, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], pixelData); - glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, 0); + {*/ + glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, currentMip, 0, 0, slot * 6 + face, mipSize, mipSize, 1, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], pixelData); //} + glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, 0); + delete[] pixelData; } }