- if( mNativeImage )
- {
- if( mNativeImage->GlExtensionCreate() )
- {
- NativeImageInterface::Extension* extension = mNativeImage->GetExtension();
- if( extension )
- {
- mTarget = extension->GetEglImageTextureTarget();
- }
-
- context.GenTextures( 1, &mId );
- context.BindTexture( mTarget, mId );
- context.PixelStorei( GL_UNPACK_ALIGNMENT, 1 ); // We always use tightly packed data
-
- //Apply default sampling parameters
- context.TexParameteri( mTarget, GL_TEXTURE_MIN_FILTER, DALI_MINIFY_DEFAULT );
- context.TexParameteri( mTarget, GL_TEXTURE_MAG_FILTER, DALI_MAGNIFY_DEFAULT );
- context.TexParameteri( mTarget, GL_TEXTURE_WRAP_S, GL_WRAP_DEFAULT );
- context.TexParameteri( mTarget, GL_TEXTURE_WRAP_T, GL_WRAP_DEFAULT );
-
- // platform specific implementation decides on what GL extension to use
- if( mNativeImage->TargetTexture() != 0u )
- {
- context.DeleteTextures( 1, &mId );
- mNativeImage->GlExtensionDestroy();
- mId = 0u;
- }
- }
- }
- else
- {
- //Create the texture and reserve memory for the first mipmap level.
- context.GenTextures( 1, &mId );
- context.BindTexture( mTarget, mId );
- context.PixelStorei( GL_UNPACK_ALIGNMENT, 1 ); // We always use tightly packed data
-
- //Apply default sampling parameters
- context.TexParameteri( mTarget, GL_TEXTURE_MIN_FILTER, DALI_MINIFY_DEFAULT );
- context.TexParameteri( mTarget, GL_TEXTURE_MAG_FILTER, DALI_MAGNIFY_DEFAULT );
- context.TexParameteri( mTarget, GL_TEXTURE_WRAP_S, GL_WRAP_DEFAULT );
- context.TexParameteri( mTarget, GL_TEXTURE_WRAP_T, GL_WRAP_DEFAULT );
-
- if( mType == TextureType::TEXTURE_2D )
- {
- 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 );
- }
- }
- else if( mType == TextureType::TEXTURE_CUBE )
- {
- 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
- {
- for( unsigned int i(0); i<6; ++i )
- {
- context.CompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, mInternalFormat, mWidth, mHeight, 0, 0, 0 );
- }
- }
- context.TexParameteri( mTarget, GL_TEXTURE_WRAP_R, GL_WRAP_DEFAULT );
- }
- }