Expose function for mapping GL cubemap face to tcu::CubeFace
authorMika Isojärvi <misojarvi@google.com>
Thu, 8 Jan 2015 23:20:07 +0000 (15:20 -0800)
committerMika Isojärvi <misojarvi@google.com>
Thu, 8 Jan 2015 23:20:07 +0000 (15:20 -0800)
Expose and rename function to map GL cubemap face target to tcu::CubeFace.

Change-Id: Ie2a3220c496255dfde18968128edaf20c90d22a1

framework/opengl/gluTexture.cpp
framework/opengl/gluTextureUtil.cpp
framework/opengl/gluTextureUtil.hpp

index c402a50..344a514 100644 (file)
@@ -343,22 +343,6 @@ TextureCube::~TextureCube (void)
                m_context.getFunctions().deleteTextures(1, &m_glTexture);
 }
 
-static deUint32 cubeFaceToGLFace (tcu::CubeFace face)
-{
-       switch (face)
-       {
-               case tcu::CUBEFACE_NEGATIVE_X: return GL_TEXTURE_CUBE_MAP_NEGATIVE_X;
-               case tcu::CUBEFACE_POSITIVE_X: return GL_TEXTURE_CUBE_MAP_POSITIVE_X;
-               case tcu::CUBEFACE_NEGATIVE_Y: return GL_TEXTURE_CUBE_MAP_NEGATIVE_Y;
-               case tcu::CUBEFACE_POSITIVE_Y: return GL_TEXTURE_CUBE_MAP_POSITIVE_Y;
-               case tcu::CUBEFACE_NEGATIVE_Z: return GL_TEXTURE_CUBE_MAP_NEGATIVE_Z;
-               case tcu::CUBEFACE_POSITIVE_Z: return GL_TEXTURE_CUBE_MAP_POSITIVE_Z;
-               default:
-                       DE_ASSERT(DE_FALSE);
-                       return GL_NONE;
-       }
-}
-
 void TextureCube::upload (void)
 {
        const glw::Functions& gl = m_context.getFunctions();
@@ -381,7 +365,7 @@ void TextureCube::upload (void)
 
                        tcu::ConstPixelBufferAccess access = m_refTexture.getLevelFace(levelNdx, (tcu::CubeFace)face);
                        DE_ASSERT(access.getRowPitch() == access.getFormat().getPixelSize()*access.getWidth());
-                       gl.texImage2D(cubeFaceToGLFace((tcu::CubeFace)face), levelNdx, m_format, access.getWidth(), access.getHeight(), 0 /* border */, transferFormat.format, transferFormat.dataType, access.getDataPtr());
+                       gl.texImage2D(getGLCubeFace((tcu::CubeFace)face), levelNdx, m_format, access.getWidth(), access.getHeight(), 0 /* border */, transferFormat.format, transferFormat.dataType, access.getDataPtr());
                }
        }
 
@@ -410,7 +394,7 @@ void TextureCube::loadCompressed (int numLevels, const tcu::CompressedTexture* l
                        level.decompress(refLevelAccess, decompressionParams);
 
                        // Upload to GL texture in compressed form.
-                       gl.compressedTexImage2D(cubeFaceToGLFace((tcu::CubeFace)face), levelNdx, compressedFormat,
+                       gl.compressedTexImage2D(getGLCubeFace((tcu::CubeFace)face), levelNdx, compressedFormat,
                                                                        level.getWidth(), level.getHeight(), 0 /* border */, level.getDataSize(), level.getData());
                }
        }
index e26ab54..ff81272 100644 (file)
@@ -696,6 +696,21 @@ deUint32 getGLCubeFace (tcu::CubeFace face)
        }
 }
 
+tcu::CubeFace getCubeFaceFromGL (deUint32 face)
+{
+       switch (face)
+       {
+               case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:    return tcu::CUBEFACE_NEGATIVE_X;
+               case GL_TEXTURE_CUBE_MAP_POSITIVE_X:    return tcu::CUBEFACE_POSITIVE_X;
+               case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:    return tcu::CUBEFACE_NEGATIVE_Y;
+               case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:    return tcu::CUBEFACE_POSITIVE_Y;
+               case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:    return tcu::CUBEFACE_NEGATIVE_Z;
+               case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:    return tcu::CUBEFACE_POSITIVE_Z;
+               default:
+                       throw tcu::InternalError("Can't map cube face");
+       }
+}
+
 /*--------------------------------------------------------------------*//*!
  * \brief Get GLSL sampler type for texture format.
  *
index 6ba71df..2ea448f 100644 (file)
@@ -73,6 +73,7 @@ deUint32                                              getGLFilterMode                                         (tcu::Sampler::FilterMode filterMode);
 deUint32                                               getGLCompareFunc                                        (tcu::Sampler::CompareMode compareMode);
 
 deUint32                                               getGLCubeFace                                           (tcu::CubeFace face);
+tcu::CubeFace                                  getCubeFaceFromGL                                       (deUint32 face);
 
 DataType                                               getSampler1DType                                        (tcu::TextureFormat format);
 DataType                                               getSampler2DType                                        (tcu::TextureFormat format);