Source/ThirdParty/ANGLE/src/libGLESv2/Texture.cpp
bool TextureCubeMap::redefineTexture(GLint level, GLenum internalFormat, GLsizei width)
{
    // Are these settings compatible with level 0?
    bool sizeOkay = (mImageArray[0][0].width >> level == width);

    bool textureOkay = (sizeOkay && internalFormat == mImageArray[0][0].format);

    if (!textureOkay)
    {
        TRACE("Redefining cube texture (%d, 0x%04X, %d => 0x%04X, %d).", level,
              mImageArray[0][0].format, mImageArray[0][0].width,
              internalFormat, width);

        // Purge all the levels and the texture.
        for (int i = 0; i < IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
        {
            for (int f = 0; f < 6; f++)
            {
                if (mImageArray[f][i].surface != NULL)
                {
                    mImageArray[f][i].dirty = false;

                    mImageArray[f][i].surface->Release();
                    mImageArray[f][i].surface = NULL;
                }
            }
        }

        if (mTexture != NULL)
        {
            mTexture->Release();
            mTexture = NULL;
            dropTexture();
        }

        mWidth = width << level;
        mImageArray[0][0].width = width << level;
        mHeight = width << level;
        mImageArray[0][0].height = width << level;

        mImageArray[0][0].format = internalFormat;
    }

    return !textureOkay;
}
// While OpenGL doesn't check texture consistency until draw-time, D3D9 requires a complete texture
// for render-to-texture (such as CopyTexImage). We have no way of keeping individual inconsistent levels & faces.
// Call this when a particular level of the texture must be defined with a specific format, width and height.
//
// Returns true if the existing texture was unsuitable had to be destroyed. If so, it will also set
// a new size for the texture by working backwards from the given size.
While OpenGL doesn't check texture consistency until draw-time, D3D9 requires a complete texture
for render-to-texture (such as CopyTexImage). We have no way of keeping individual inconsistent levels & faces.
Call this when a particular level of the texture must be defined with a specific format, width and height.

Returns true if the existing texture was unsuitable had to be destroyed. If so, it will also set
a new size for the texture by working backwards from the given size.
While OpenGL doesn ' t check texture consistency until draw - time D3D9 requires a complete texture for render - to - texture ( such as CopyTexImage ) . We have no way of keeping individual inconsistent levels & faces . Call this when a particular level of the texture must be defined with a specific format width and height . Returns true if the existing texture was unsuitable had to be destroyed . If so it will also set a new size for the texture by working backwards from the given size .
bool TextureCubeMap::redefineTexture(GLint level, GLenum internalFormat, GLsizei width)
{
    bool sizeOkay = (mImageArray[0][0].width >> level == width);
    bool textureOkay = (sizeOkay && internalFormat == mImageArray[0][0].format);
    if (!textureOkay)
    {
        TRACE("Redefining cube texture (%d, 0x%04X, %d => 0x%04X, %d).", level,
              mImageArray[0][0].format, mImageArray[0][0].width,
              internalFormat, width);
        for (int i = 0; i < IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
        {
            for (int f = 0; f < 6; f++)
            {
                if (mImageArray[f][i].surface != NULL)
                {
                    mImageArray[f][i].dirty = false;
                    mImageArray[f][i].surface->Release();
                    mImageArray[f][i].surface = NULL;
                }
            }
        }
        if (mTexture != NULL)
        {
            mTexture->Release();
            mTexture = NULL;
            dropTexture();
        }
        mWidth = width << level;
        mImageArray[0][0].width = width << level;
        mHeight = width << level;
        mImageArray[0][0].height = width << level;
        mImageArray[0][0].format = internalFormat;
    }
    return !textureOkay;
}
bool TextureCubeMap :: redefineTexture ( GLint level , GLenum internalFormat , GLsizei width ) { bool sizeOkay = ( mImageArray [ 0 ] [ 0 ] . width >> level == width ) ; bool textureOkay = ( sizeOkay && internalFormat == mImageArray [ 0 ] [ 0 ] . format ) ; if ( ! textureOkay ) { TRACE ( " " , level , mImageArray [ 0 ] [ 0 ] . format , mImageArray [ 0 ] [ 0 ] . width , internalFormat , width ) ; for ( int i = 0 ; i < IMPLEMENTATION_MAX_TEXTURE_LEVELS ; i ++ ) { for ( int f = 0 ; f < 6 ; f ++ ) { if ( mImageArray [ f ] [ i ] . surface != NULL ) { mImageArray [ f ] [ i ] . dirty = false ; mImageArray [ f ] [ i ] . surface -> Release ( ) ; mImageArray [ f ] [ i ] . surface = NULL ; } } } if ( mTexture != NULL ) { mTexture -> Release ( ) ; mTexture = NULL ; dropTexture ( ) ; } mWidth = width << level ; mImageArray [ 0 ] [ 0 ] . width = width << level ; mHeight = width << level ; mImageArray [ 0 ] [ 0 ] . height = width << level ; mImageArray [ 0 ] [ 0 ] . format = internalFormat ; } return ! textureOkay ; }
While OpenGL doesn't check texture consistency until draw-time, D3D9 requires a complete texture
for render-to-texture (such as CopyTexImage).
While OpenGL doesn ' t check texture consistency until draw - time D3D9 requires a complete texture for render - to - texture ( such as CopyTexImage ) .
// Are these settings compatible with level 0? // Purge all the levels and the texture.