unsigned int bufferSize = width*height*Pixel::GetBytesPerPixel( pixelFormat );
unsigned char* buffer = new unsigned char [ bufferSize ];
- return PixelData::New( buffer, width, height, pixelFormat, PixelData::DELETE_ARRAY );
+ return PixelData::New( buffer, bufferSize, width, height, pixelFormat, PixelData::DELETE_ARRAY );
}
}
unsigned int bufferSize = width*height*Pixel::GetBytesPerPixel( Pixel::RGB888 );
unsigned char* buffer= reinterpret_cast<unsigned char*>( malloc( bufferSize ) );
- PixelData pixelData = PixelData::New( buffer, width, height, Pixel::RGB888, PixelData::FREE );
+ PixelData pixelData = PixelData::New( buffer, bufferSize, width, height, Pixel::RGB888, PixelData::FREE );
DALI_TEST_CHECK( pixelData );
DALI_TEST_CHECK( pixelData.GetWidth() == width );
unsigned char* buffer = new unsigned char [ bufferSize ];
buffer[0] = 'a';
- PixelData pixelData = PixelData::New( buffer, width, height, Pixel::L8, PixelData::DELETE_ARRAY );
+ PixelData pixelData = PixelData::New( buffer, bufferSize, width, height, Pixel::L8, PixelData::DELETE_ARRAY );
DALI_TEST_CHECK( pixelData);
DALI_TEST_CHECK( pixelData.GetWidth() == width );
unsigned int height = 10u;
unsigned int bufferSize = width*height*Pixel::GetBytesPerPixel( Pixel::L8 );
unsigned char* buffer = new unsigned char [ bufferSize ];
- PixelData pixelData = PixelData::New( buffer, width, height, Pixel::L8, PixelData::DELETE_ARRAY );
+ PixelData pixelData = PixelData::New( buffer, bufferSize, width, height, Pixel::L8, PixelData::DELETE_ARRAY );
PixelData pixelDataCopy(pixelData);
unsigned int height = 10u;
unsigned int bufferSize = width*height*Pixel::GetBytesPerPixel( Pixel::L8 );
unsigned char* buffer = new unsigned char [ bufferSize ];
- PixelData pixelData = PixelData::New( buffer, width, height, Pixel::L8, PixelData::DELETE_ARRAY );
+ PixelData pixelData = PixelData::New( buffer, bufferSize, width, height, Pixel::L8, PixelData::DELETE_ARRAY );
PixelData pixelData2;
DALI_TEST_EQUALS( (bool)pixelData2, false, TEST_LOCATION );
//Upload data to the texture
callStack.Reset();
- unsigned char* buffer= reinterpret_cast<unsigned char*>( malloc( width * height * 4 ) );
- PixelData pixelData = PixelData::New( buffer, width, height, Pixel::RGBA8888, PixelData::FREE );
+ unsigned int bufferSize( width * height * 4 );
+ unsigned char* buffer= reinterpret_cast<unsigned char*>( malloc( bufferSize ) );
+ PixelData pixelData = PixelData::New( buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE );
texture.Upload( pixelData );
application.SendNotification();
application.Render();
//Upload part of the texture
callStack.Reset();
- buffer = reinterpret_cast<unsigned char*>( malloc( width * height * 2 ) );
- PixelData pixelDataSubImage = PixelData::New( buffer, width, height, Pixel::RGBA8888, PixelData::FREE );
+ bufferSize = width * height * 2;
+ buffer = reinterpret_cast<unsigned char*>( malloc( bufferSize ) );
+ PixelData pixelDataSubImage = PixelData::New( buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE );
texture.Upload( pixelDataSubImage, 0u, 0u, width/2, height/2, width/2, height/2 );
application.SendNotification();
application.Render();
DALI_TEST_CHECK( callStack.FindMethodAndParams("TexImage2D", out.str().c_str() ) );
}
- unsigned char* buffer= reinterpret_cast<unsigned char*>( malloc( width * height * 4 ) );
- PixelData pixelData = PixelData::New( buffer, width, height, Pixel::RGBA8888, PixelData::FREE );
+ unsigned int bufferSize( width * height * 4 );
+ unsigned char* buffer= reinterpret_cast<unsigned char*>( malloc( bufferSize ) );
+ PixelData pixelData = PixelData::New( buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE );
//Upload data to the POSITIVE_X face of the texture
{
//Upload data to the texture mipmap 0 and mipmap 1
callStack.Reset();
- unsigned char* buffer= reinterpret_cast<unsigned char*>( malloc( width * height * 4 ) );
- PixelData pixelData = PixelData::New( buffer, width, height, Pixel::RGBA8888, PixelData::FREE );
+
+ unsigned int bufferSize( width * height * 4 );
+ unsigned char* buffer= reinterpret_cast<unsigned char*>( malloc( bufferSize ) );
+ PixelData pixelData = PixelData::New( buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE );
texture.Upload( pixelData, 0u, 0u, 0u, 0u, width, height );
- buffer = reinterpret_cast<unsigned char*>( malloc( widthMipmap1 * heightMipmap1 * 4 ) );
- PixelData pixelDataMipmap1 = PixelData::New( buffer, width, height, Pixel::RGBA8888, PixelData::FREE );
+ bufferSize = widthMipmap1 * heightMipmap1 * 4;
+ buffer = reinterpret_cast<unsigned char*>( malloc( bufferSize ) );
+ PixelData pixelDataMipmap1 = PixelData::New( buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE );
texture.Upload( pixelDataMipmap1, 0u, 1u, 0u, 0u, widthMipmap1, heightMipmap1 );
application.SendNotification();
application.Render();
TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
//Upload data to the NEGATIVE_X face mipmap 0 and mipmap 1
- unsigned char* buffer= reinterpret_cast<unsigned char*>( malloc( width * height * 4 ) );
- PixelData pixelData = PixelData::New( buffer, width, height, Pixel::RGBA8888, PixelData::FREE );
+ unsigned int bufferSize( width * height * 4 );
+ unsigned char* buffer= reinterpret_cast<unsigned char*>( malloc( bufferSize ) );
+ PixelData pixelData = PixelData::New( buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE );
texture.Upload( pixelData, CubeMap::NEGATIVE_X, 0u, 0u, 0u, width, height );
- buffer= reinterpret_cast<unsigned char*>( malloc( widthMipmap1 * heightMipmap1 * 4 ) );
- PixelData pixelDataMipmap1 = PixelData::New( buffer, width, height, Pixel::RGBA8888, PixelData::FREE );
+ bufferSize = widthMipmap1 * heightMipmap1 * 4;
+ buffer = reinterpret_cast<unsigned char*>( malloc( bufferSize ) );
+ PixelData pixelDataMipmap1 = PixelData::New( buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE );
texture.Upload( pixelDataMipmap1, CubeMap::NEGATIVE_X, 1u, 0u, 0u, widthMipmap1, heightMipmap1 );
application.SendNotification();
application.Render();
END_TEST;
}
+int UtcDaliTextureUpload05(void)
+{
+ TestApplication application;
+
+ //Create a texture with a compressed format
+ unsigned int width(64);
+ unsigned int height(64);
+ Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::COMPRESSED_RGBA_ASTC_4x4_KHR, width, height );
+
+ application.GetGlAbstraction().EnableTextureCallTrace(true);
+
+ application.SendNotification();
+ application.Render();
+
+ TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
+
+ //CompressedTexImage2D should be called with a null pointer to reserve storage for the texture in the gpu
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_2D <<", "<< 0u << ", " << width <<", "<< height;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("CompressedTexImage2D", out.str().c_str() ) );
+ }
+
+ //Upload data to the texture
+ callStack.Reset();
+
+ unsigned int bufferSize( width * height * 4 );
+ unsigned char* buffer= reinterpret_cast<unsigned char*>( malloc( bufferSize ) );
+ PixelData pixelData = PixelData::New( buffer, bufferSize, width, height, Pixel::COMPRESSED_RGBA_ASTC_4x4_KHR, PixelData::FREE );
+ texture.Upload( pixelData );
+ application.SendNotification();
+ application.Render();
+
+ //CompressedTexImage2D should be called to upload the data
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_2D <<", "<< 0u << ", " << width <<", "<< height;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("CompressedTexImage2D", out.str().c_str() ) );
+ }
+
+ //Upload part of the texture
+ callStack.Reset();
+ bufferSize = width * height * 2;
+ buffer = reinterpret_cast<unsigned char*>( malloc( bufferSize ) );
+ PixelData pixelDataSubImage = PixelData::New( buffer, bufferSize, width, height, Pixel::COMPRESSED_RGBA_ASTC_4x4_KHR, PixelData::FREE );
+ texture.Upload( pixelDataSubImage, 0u, 0u, width/2, height/2, width/2, height/2 );
+ application.SendNotification();
+ application.Render();
+
+ //CompressedTexSubImage2D should be called to upload the data
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_2D <<", "<< 0u << ", " << width/2 << ", " << height/2 << ", " << width/2 << ", " << height/2;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("CompressedTexSubImage2D", out.str().c_str() ) );
+ }
+
+
+ END_TEST;
+}
+
int UtcDaliTextureGenerateMipmaps(void)
{
TestApplication application;
inline void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
{
+ std::stringstream out;
+ out << target<<", "<<level<<", "<<width << ", " << height;
+
+ TraceCallStack::NamedParams namedParams;
+ namedParams["target"] = ToString(target);
+ namedParams["level"] = ToString(level);
+ namedParams["internalformat"] = ToString(internalformat);
+ namedParams["width"] = ToString(width);
+ namedParams["height"] = ToString(height);
+ namedParams["border"] = ToString(border);
+ namedParams["size"] = ToString(imageSize);
+
+ mTextureTrace.PushCall("CompressedTexImage2D", out.str(), namedParams);
}
inline void CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
{
+ std::stringstream out;
+ out << target << ", "<<level <<", " << xoffset << ", " << yoffset << ", " << width << ", " << height;
+
+ TraceCallStack::NamedParams namedParams;
+ namedParams["target"] = ToString(target);
+ namedParams["level"] = ToString(level);
+ namedParams["xoffset"] = ToString(xoffset);
+ namedParams["yoffset"] = ToString(yoffset);
+ namedParams["width"] = ToString(width);
+ namedParams["height"] = ToString(height);
+ mTextureTrace.PushCall("CompressedTexSubImage2D", out.str(), namedParams);
}
inline void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
{
PixelData PixelData::New(unsigned char* buffer,
+ unsigned int bufferSize,
unsigned int width,
unsigned int height,
Pixel::Format pixelFormat,
ReleaseFunction releaseFunction)
{
- IntrusivePtr<Internal::PixelData> internal = Internal::PixelData::New( buffer, width, height, pixelFormat, releaseFunction );
+ IntrusivePtr<Internal::PixelData> internal = Internal::PixelData::New( buffer, bufferSize, width, height, pixelFormat, releaseFunction );
return PixelData( internal.Get() );
}
* @brief Create a PixelData object.
*
* @param [in] buffer The raw pixel data.
+ * @param [in] bufferSize The size of the buffer in bytes
* @param [in] width Buffer width in pixels
* @param [in] height Buffer height in pixels
* @param [in] pixelFormat The pixel format
* @param [in] releaseFunction The function used to release the memory.
*/
static PixelData New( unsigned char* buffer,
+ unsigned int bufferSize,
unsigned int width,
unsigned int height,
Pixel::Format pixelFormat,
{
PixelData::PixelData( unsigned char* buffer,
+ unsigned int bufferSize,
unsigned int width,
unsigned int height,
Pixel::Format pixelFormat,
Dali::PixelData::ReleaseFunction releaseFunction )
: mBuffer( buffer ),
+ mBufferSize( bufferSize ),
mWidth( width ),
mHeight( height ),
mPixelFormat( pixelFormat ),
}
PixelDataPtr PixelData::New(unsigned char* buffer,
+ unsigned int bufferSize,
unsigned int width,
unsigned int height,
Pixel::Format pixelFormat,
Dali::PixelData::ReleaseFunction releaseFunction)
{
- return new PixelData( buffer, width, height, pixelFormat, releaseFunction );
+ return new PixelData( buffer, bufferSize, width, height, pixelFormat, releaseFunction );
}
unsigned int PixelData::GetWidth() const
return mBuffer;
}
+unsigned int PixelData::GetBufferSize() const
+{
+ return mBufferSize;
+}
+
}// namespace Internal
}// namespace Dali
* @brief Create a PixelData object.
*
* @param [in] buffer The raw pixel data.
+ * @param [in] bufferSize The size of the buffer in bytes
* @param [in] width Buffer width in pixels
* @param [in] height Buffer height in pixels
* @param [in] pixelFormat The pixel format
* @param [in] releaseFunction The function used to release the memory.
*/
static PixelDataPtr New( unsigned char* buffer,
+ unsigned int bufferSize,
unsigned int width,
unsigned int height,
Pixel::Format pixelFormat,
* @brief Constructor.
*
* @param [in] buffer The raw pixel data.
+ * @param [in] bufferSize The size of the buffer in bytes
* @param [in] width Buffer width in pixels
* @param [in] height Buffer height in pixels
* @param [in] pixelFormat The pixel format
* @param [in] releaseFunction The function used to release the memory.
*/
PixelData( unsigned char* buffer,
+ unsigned int bufferSize,
unsigned int width,
unsigned int height,
Pixel::Format pixelFormat,
*/
unsigned char* GetBuffer() const;
+ /**
+ * Get the size of the buffer in bytes
+ * @return The size of the buffer
+ */
+ unsigned int GetBufferSize() const;
+
private:
/*
private:
- unsigned char* mBuffer; ///< The raw pixel data.
- unsigned int mWidth; ///< Buffer width in pixels.
- unsigned int mHeight; ///< Buffer height in pixels.
+ unsigned char* mBuffer; ///< The raw pixel data
+ unsigned int mBufferSize; ///< Buffer sized in bytes
+ unsigned int mWidth; ///< Buffer width in pixels
+ unsigned int mHeight; ///< Buffer height in pixels
Pixel::Format mPixelFormat; ///< Pixel format
Dali::PixelData::ReleaseFunction mReleaseFunction; ///< Function for releasing memory
};
{
DALI_LOG_ERROR( "Pixel data of an incorrect size when trying to update texture");
}
- else if( ( xOffset + width > static_cast<unsigned int>( mWidth / (1<<mipmap ))) ||
- ( yOffset + height > static_cast<unsigned int>( mHeight / (1<<mipmap ))))
+ else if( ( xOffset + width > ( mWidth / (1<<mipmap) ) ) ||
+ ( yOffset + height > ( mHeight / (1<<mipmap) ) ) )
{
DALI_LOG_ERROR( "Texture update area out of bounds");
}
}
}
+/**
+ * @brief Whether specified pixel format is compressed.
+ *
+ * @param [in] pixelformat Pixel format
+ * @return true if format is compressed, false otherwise
+ */
+bool IsCompressedFormat(Pixel::Format pixelFormat)
+{
+ switch (pixelFormat)
+ {
+ case Pixel::L8:
+ case Pixel::A8:
+ case Pixel::LA88:
+ case Pixel::RGB565:
+ case Pixel::RGBA4444:
+ case Pixel::RGBA5551:
+ case Pixel::BGR565:
+ case Pixel::BGRA4444:
+ case Pixel::BGRA5551:
+ case Pixel::RGB888:
+ case Pixel::RGB8888:
+ case Pixel::BGR8888:
+ case Pixel::RGBA8888:
+ case Pixel::BGRA8888:
+ case Pixel::INVALID:
+ {
+ return false;
+ }
+
+ case Pixel::COMPRESSED_R11_EAC:
+ case Pixel::COMPRESSED_SIGNED_R11_EAC:
+ case Pixel::COMPRESSED_RG11_EAC:
+ case Pixel::COMPRESSED_SIGNED_RG11_EAC:
+ case Pixel::COMPRESSED_RGB8_ETC2:
+ case Pixel::COMPRESSED_SRGB8_ETC2:
+ case Pixel::COMPRESSED_RGB8_ETC1:
+ case Pixel::COMPRESSED_RGB_PVRTC_4BPPV1:
+ case Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+ case Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+ case Pixel::COMPRESSED_RGBA8_ETC2_EAC:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
+ case Pixel::COMPRESSED_RGBA_ASTC_4x4_KHR:
+ case Pixel::COMPRESSED_RGBA_ASTC_5x4_KHR:
+ case Pixel::COMPRESSED_RGBA_ASTC_5x5_KHR:
+ case Pixel::COMPRESSED_RGBA_ASTC_6x5_KHR:
+ case Pixel::COMPRESSED_RGBA_ASTC_6x6_KHR:
+ case Pixel::COMPRESSED_RGBA_ASTC_8x5_KHR:
+ case Pixel::COMPRESSED_RGBA_ASTC_8x6_KHR:
+ case Pixel::COMPRESSED_RGBA_ASTC_8x8_KHR:
+ case Pixel::COMPRESSED_RGBA_ASTC_10x5_KHR:
+ case Pixel::COMPRESSED_RGBA_ASTC_10x6_KHR:
+ case Pixel::COMPRESSED_RGBA_ASTC_10x8_KHR:
+ case Pixel::COMPRESSED_RGBA_ASTC_10x10_KHR:
+ case Pixel::COMPRESSED_RGBA_ASTC_12x10_KHR:
+ case Pixel::COMPRESSED_RGBA_ASTC_12x12_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:
+ case Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
} //Unnamed namespace
mPixelDataType(GL_UNSIGNED_BYTE),
mWidth( width ),
mHeight( height ),
- mHasAlpha( HasAlpha( format ) )
+ mHasAlpha( HasAlpha( format ) ),
+ mIsCompressed( IsCompressedFormat( format ) )
{
PixelFormatToGl( format, mPixelDataType, mInternalFormat );
}
mPixelDataType(GL_UNSIGNED_BYTE),
mWidth( nativeImageInterface->GetWidth() ),
mHeight( nativeImageInterface->GetHeight() ),
- mHasAlpha( nativeImageInterface->RequiresBlending() )
+ mHasAlpha( nativeImageInterface->RequiresBlending() ),
+ mIsCompressed( false )
{
}
{
//Creates the texture and reserves memory for the first mipmap level.
context.Bind2dTexture( mId );
- context.TexImage2D(GL_TEXTURE_2D, 0, mInternalFormat, mWidth, mHeight, 0, mInternalFormat, mPixelDataType, 0 );
+
+ if( !mIsCompressed )
+ {
+ context.TexImage2D(GL_TEXTURE_2D, 0, mInternalFormat, mWidth, mHeight, 0, mInternalFormat, mPixelDataType, 0 );
+ }
+ else
+ {
+ context.CompressedTexImage2D(GL_TEXTURE_2D, 0, mInternalFormat, mWidth, mHeight, 0, 0, 0 );
+ }
//Apply default sampling parameters
context.TexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, DALI_MINIFY_DEFAULT );
{
//Creates the texture and reserves memory for the first mipmap level.
context.BindCubeMapTexture( mId );
- for( unsigned int i(0); i<6; ++i )
+
+ if( !mIsCompressed )
+ {
+ for( unsigned int i(0); i<6; ++i )
+ {
+ context.TexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, mInternalFormat, mWidth, mHeight, 0, mInternalFormat, mPixelDataType, 0 );
+ }
+ }
+ else
{
- context.TexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, mInternalFormat, mWidth, mHeight, 0, mInternalFormat, mPixelDataType, 0 );
+ for( unsigned int i(0); i<6; ++i )
+ {
+ context.CompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, mInternalFormat, mWidth, mHeight, 0, 0, 0 );
+ }
}
//Apply default sampling parameters
#endif
//Upload data to the texture
+ GLenum target( GL_NONE );
if( mType == TextureType::TEXTURE_2D )
{
context.Bind2dTexture( mId );
- context.PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
+ target = GL_TEXTURE_2D;
+ }
+ else if( mType == TextureType::TEXTURE_CUBE )
+ {
+ context.BindCubeMapTexture( mId );
+ target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + params.layer;
+ }
- if( params.xOffset == 0 && params.yOffset == 0 &&
- params.width == static_cast<unsigned int>(mWidth / (1<<params.mipmap)) &&
- params.height == static_cast<unsigned int>(mHeight / (1<<params.mipmap)) )
+ context.PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
+
+ if( params.xOffset == 0 && params.yOffset == 0 &&
+ params.width == ( mWidth / (1<<params.mipmap) ) &&
+ params.height == ( mHeight / (1<<params.mipmap) ) )
+ {
+ //Specifying the whole image for the mipmap. We cannot assume that storage for that mipmap has been created so we need to use TexImage2D
+ if( !mIsCompressed )
{
- //Specifying the whole image for the mipmap. We cannot assume that storage for that mipmap has been created so we need to use TexImage2D
- context.TexImage2D(GL_TEXTURE_2D, params.mipmap, mInternalFormat, params.width, params.height, 0, pixelDataFormat, pixelDataElementType, buffer );
+ context.TexImage2D( target, params.mipmap, mInternalFormat, params.width, params.height, 0, pixelDataFormat, pixelDataElementType, buffer );
}
else
{
- //Specifying part of the image for the mipmap
- context.TexSubImage2D( GL_TEXTURE_2D, params.mipmap, params.xOffset, params.yOffset, params.width, params.height, pixelDataFormat, pixelDataElementType, buffer );
+ context.CompressedTexImage2D( target, params.mipmap, mInternalFormat, params.width, params.height, 0, pixelData->GetBufferSize(), buffer );
}
}
- else if( mType == TextureType::TEXTURE_CUBE )
+ else
{
- context.BindCubeMapTexture( mId );
- context.PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
-
- if( params.xOffset == 0 && params.yOffset == 0 &&
- params.width == static_cast<unsigned int>(mWidth / (1<<params.mipmap)) &&
- params.height == static_cast<unsigned int>(mHeight / (1<<params.mipmap)) )
+ //Specifying part of the image for the mipmap
+ if( !mIsCompressed )
{
- //Specifying the whole image for the mipmap. We cannot assume that storage for that mipmap has been created so we need to use TexImage2D
- context.TexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + params.layer, params.mipmap, mInternalFormat,
- params.width, params.height, 0,
- pixelDataFormat, pixelDataElementType, buffer );
+ context.TexSubImage2D( target, params.mipmap,
+ params.xOffset, params.yOffset, params.width, params.height,
+ pixelDataFormat, pixelDataElementType, buffer );
}
else
{
- //Specifying part of the image for the mipmap
- context.TexSubImage2D( GL_TEXTURE_CUBE_MAP_POSITIVE_X + params.layer, params.mipmap,
- params.xOffset, params.yOffset, params.width, params.height,
- pixelDataFormat, pixelDataElementType, buffer );
+ context.CompressedTexSubImage2D( target, params.mipmap,
+ params.xOffset, params.yOffset, params.width, params.height,
+ pixelDataFormat, pixelData->GetBufferSize(), buffer );
}
}
+
//Destroy temp buffer used for conversion RGB->RGBA
delete[] tempBuffer;
}
unsigned int mWidth; ///<Widht of the texture
unsigned int mHeight; ///<Height of the texture
bool mHasAlpha : 1; ///<Whether the format has an alpha channel
+ bool mIsCompressed : 1; ///<Whether the format is compressed
};