+// Texture indices are constants.
+enum TextureIndex
+{
+ DIFFUSE_TEXTURE_INDEX,
+ NORMAL_TEXTURE_INDEX,
+ GLOSS_TEXTURE_INDEX
+};
+
+/**
+ * @brief Loads a texture from a file.
+ * @param[in] imageUrl The URL of the file
+ * @return A texture if loading succeeds, an empty handle otherwise
+ */
+Texture LoadTexture( const char* imageUrl )
+{
+ 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 );
+ texture.GenerateMipmaps();
+ }
+
+ return texture;
+}
+