Code example for SparseIntArray

Methods: getindexOfKey

     * @param repeat Specified to allow the texture to repeat in both directions. Ex: GLES20.GL_REPEAT 
     * @return OpenGL texture handle. 
    public int makeAndRegisterDrawable(GL10 glUnused, int id, int repeat) {
        //Fetch texture ID from cache if possible 
        if(cache.indexOfKey(id)>=0) return cache.get(id);
        //Fetch from resources, bind/upload to GPU. 
        Bitmap bitmap = BitmapFactory.decodeResource(res,id);
        int result = registerBitmapInGl(bitmap, repeat, GLES20.GL_NEAREST);
        // Delete bitmap from local memory. 
        return result;
     * Takes a text string, draws it onto a Bitmap, and loads it into OpenGL memory. 
     * Please do not call this often, as it is expensive. 
     * @param glUnused Unused object to ensure method is called from GL thread. 
     * @param text Text to write to texture