source/Irrlicht/COGLES2Texture.cpp
//! lock function
/** TODO: support miplevel */
lock function
TODO: support miplevel
lock function TODO : support miplevel
void* COGLES2Texture::lock(E_TEXTURE_LOCK_MODE mode, u32 mipmapLevel)
	{
		ReadOnlyLock |= (mode==ETLM_READ_ONLY);
		if ( !Image )
			Image = new CImage( ECF_A8R8G8B8, ImageSize );
		if (mode != ETLM_WRITE_ONLY)
		{
			u8* pPixels = static_cast<u8*>( Image->lock() );
			if ( !pPixels )
			{
				return 0;
			}
			GLint tmpTexture;
			glGetIntegerv( GL_TEXTURE_BINDING_2D, &tmpTexture );
			{char msg[512]; sprintf(msg, "test %s %d", __FILE__, __LINE__); os::Printer::print(msg);};
			glBindTexture( GL_TEXTURE_2D, TextureName );
			const u32 pitch = Image->getPitch();
			u8* p2 = pPixels + ( ImageSize.Height - 1 ) * pitch;
			u8* tmpBuffer = new u8[pitch];
			for ( u32 i = 0; i < ImageSize.Height; i += 2 )
			{
				memcpy( tmpBuffer, pPixels, pitch );
				memcpy( pPixels, p2, pitch );
				memcpy( p2, tmpBuffer, pitch );
				pPixels += pitch;
				p2 -= pitch;
			}
			delete [] tmpBuffer;
			Image->unlock();
			{char msg[512]; sprintf(msg, "test %s %d", __FILE__, __LINE__); os::Printer::print(msg);};
			glBindTexture( GL_TEXTURE_2D, tmpTexture );
		}
		return Image->lock();
	}
void * COGLES2Texture :: lock ( E_TEXTURE_LOCK_MODE mode , u32 mipmapLevel ) { ReadOnlyLock |= ( mode == ETLM_READ_ONLY ) ; if ( ! Image ) Image = new CImage ( ECF_A8R8G8B8 , ImageSize ) ; if ( mode != ETLM_WRITE_ONLY ) { u8 * pPixels = static_cast < u8 * > ( Image -> lock ( ) ) ; if ( ! pPixels ) { return 0 ; } GLint tmpTexture ; glGetIntegerv ( GL_TEXTURE_BINDING_2D , & tmpTexture ) ; { char msg [ 512 ] ; sprintf ( msg , " " , __FILE__ , __LINE__ ) ; os :: Printer :: print ( msg ) ; } ; glBindTexture ( GL_TEXTURE_2D , TextureName ) ; const u32 pitch = Image -> getPitch ( ) ; u8 * p2 = pPixels + ( ImageSize . Height - 1 ) * pitch ; u8 * tmpBuffer = new u8 [ pitch ] ; for ( u32 i = 0 ; i < ImageSize . Height ; i += 2 ) { memcpy ( tmpBuffer , pPixels , pitch ) ; memcpy ( pPixels , p2 , pitch ) ; memcpy ( p2 , tmpBuffer , pitch ) ; pPixels += pitch ; p2 -= pitch ; } delete [ ] tmpBuffer ; Image -> unlock ( ) ; { char msg [ 512 ] ; sprintf ( msg , " " , __FILE__ , __LINE__ ) ; os :: Printer :: print ( msg ) ; } ; glBindTexture ( GL_TEXTURE_2D , tmpTexture ) ; } return Image -> lock ( ) ; }
lock function
TODO: support miplevel
lock function TODO : support miplevel
// we need to keep the correct texture bound...
 // TODO ogl-es
 // glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_BYTE, pPixels);
 // opengl images are horizontally flipped, so we have to fix that here.
 //reset old bound texture
