// Path: openCVTutorial1CameraPreview/src/main/java/aruco/min3d/Min3d.java
// public class Min3d 
// {
// 	public static final String TAG = "Min3D";
// 	
// 	/*
// 	 * Project homepage: 	http://code.google.com/p/min3d
// 	 * License:				MIT
// 	 * 
// 	 * Author: 				Lee Felarca
// 	 * Website:				http://www.zeropointnine.com/blog
// 	 *
// 	 * Author: 				Dennis Ippel
// 	 * Author blog:			http://www.rozengain.com/blog/
// 	 */
// }
// 
// Path: openCVTutorial1CameraPreview/src/main/java/aruco/min3d/Shared.java
// public class Shared 
// {
// 	private static Context _context;
// 	private static MyRenderer _renderer;
// 	private static TextureManager _textureManager;
// 
// 	
// 	public static Context context()
// 	{
// 		return _context;
// 	}
// 	public static void context(Context $c)
// 	{
// 		_context = $c;
// 	}
// 
// 	public static MyRenderer renderer()
// 	{
// 		return _renderer;
// 	}
// 	public static void renderer(MyRenderer $r)
// 	{
// 		_renderer = $r;
// 	}
// 	
// 	/**
// 	 * You must access the TextureManager instance through this accessor
// 	 */
// 	public static TextureManager textureManager()
// 	{
// 		return _textureManager;
// 	}
// 	public static void textureManager(TextureManager $bm)
// 	{
// 		_textureManager = $bm;
// 	}
// }


import java.util.HashMap;
import java.util.Set;
import android.graphics.Bitmap;
import android.util.Log;
import aruco.min3d.Min3d;
import aruco.min3d.Shared;
package min3d.core;



/**
 * TextureManager is responsible for managing textures for the whole environment. 
 * It maintains a list of id's that are mapped to the GL texture names (id's).
 * 
 * You add a Bitmap to the TextureManager, which adds a textureId to its list.
 * Then, you assign one or more TextureVo's to your Object3d's using id's that 
 * exist in the TextureManager.
 * 
 * Note that the _idToTextureName and _idToHasMipMap HashMaps used below
 * don't test for exceptions. 
 */
public class TextureManager 
{
	private HashMap<String, Integer> _idToTextureName;
	private HashMap<String, Boolean> _idToHasMipMap;
	private static int _counter = 1000001;
	private static int _atlasId = 0;
	
	
	public TextureManager()
	{
		reset();
	}

	public void reset()
	{
		// Delete any extant textures

		if (_idToTextureName != null) 
		{
			Set<String> s = _idToTextureName.keySet();
			Object[] a = s.toArray(); 
			for (int i = 0; i < a.length; i++) {
				int glId = getGlTextureId((String)a[i]);
// Path: openCVTutorial1CameraPreview/src/main/java/aruco/min3d/Min3d.java
// public class Min3d 
// {
// 	public static final String TAG = "Min3D";
// 	
// 	/*
// 	 * Project homepage: 	http://code.google.com/p/min3d
// 	 * License:				MIT
// 	 * 
// 	 * Author: 				Lee Felarca
// 	 * Website:				http://www.zeropointnine.com/blog
// 	 *
// 	 * Author: 				Dennis Ippel
// 	 * Author blog:			http://www.rozengain.com/blog/
// 	 */
// }
// 
// Path: openCVTutorial1CameraPreview/src/main/java/aruco/min3d/Shared.java
// public class Shared 
// {
// 	private static Context _context;
// 	private static MyRenderer _renderer;
// 	private static TextureManager _textureManager;
// 
// 	
// 	public static Context context()
// 	{
// 		return _context;
// 	}
// 	public static void context(Context $c)
// 	{
// 		_context = $c;
// 	}
// 
// 	public static MyRenderer renderer()
// 	{
// 		return _renderer;
// 	}
// 	public static void renderer(MyRenderer $r)
// 	{
// 		_renderer = $r;
// 	}
// 	
// 	/**
// 	 * You must access the TextureManager instance through this accessor
// 	 */
// 	public static TextureManager textureManager()
// 	{
// 		return _textureManager;
// 	}
// 	public static void textureManager(TextureManager $bm)
// 	{
// 		_textureManager = $bm;
// 	}
// }


// Path: openCVTutorial1CameraPreview/src/main/java/min3d/core/TextureManager.java
import java.util.HashMap;
import java.util.Set;
import android.graphics.Bitmap;
import android.util.Log;
import aruco.min3d.Min3d;
import aruco.min3d.Shared;

package min3d.core;



/**
 * TextureManager is responsible for managing textures for the whole environment. 
 * It maintains a list of id's that are mapped to the GL texture names (id's).
 * 
 * You add a Bitmap to the TextureManager, which adds a textureId to its list.
 * Then, you assign one or more TextureVo's to your Object3d's using id's that 
 * exist in the TextureManager.
 * 
 * Note that the _idToTextureName and _idToHasMipMap HashMaps used below
 * don't test for exceptions. 
 */
public class TextureManager 
{
	private HashMap<String, Integer> _idToTextureName;
	private HashMap<String, Boolean> _idToHasMipMap;
	private static int _counter = 1000001;
	private static int _atlasId = 0;
	
	
	public TextureManager()
	{
		reset();
	}

	public void reset()
	{
		// Delete any extant textures

		if (_idToTextureName != null) 
		{
			Set<String> s = _idToTextureName.keySet();
			Object[] a = s.toArray(); 
			for (int i = 0; i < a.length; i++) {
				int glId = getGlTextureId((String)a[i]);
				Shared.renderer().deleteTexture(glId);