+namespace
+{
+ /**
+ * @brief Loads a texture from a file
+ * @param[in] imageUrl The url of the file
+ * @param[in] generateMipmaps Indicates whether to generate mipmaps for the texture
+ * @return A texture if loading succeeds, an empty handle otherwise
+ */
+ Texture LoadTexture( const char* imageUrl, bool generateMipmaps )
+ {
+ Texture texture;
+ Dali::BitmapLoader loader = Dali::BitmapLoader::New( imageUrl );
+ loader.Load();
+ PixelData pixelData = loader.GetPixelData();
+ if( pixelData )
+ {
+ texture = Texture::New( TextureType::TEXTURE_2D, pixelData.GetPixelFormat(), pixelData.GetWidth(), pixelData.GetHeight() );
+ texture.Upload( pixelData );
+
+ if( generateMipmaps )
+ {
+ texture.GenerateMipmaps();
+ }
+ }
+
+ return texture;
+ }
+}// unnamed namespace
+