Example #1
0
  private final int bindTexture(final TextureDescriptor textureDesc, final boolean rebind) {
    final int idx, result;
    final GLTexture texture = textureDesc.texture;
    reused = false;

    switch (method) {
      case ROUNDROBIN:
        result = offset + (idx = bindTextureRoundRobin(texture));
        break;
      case WEIGHTED:
        result = offset + (idx = bindTextureWeighted(texture));
        break;
      default:
        return -1;
    }

    if (reused) {
      reuseCount++;
      if (rebind) texture.bind(result);
      else Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0 + result);
    } else bindCount++;
    texture.unsafeSetWrap(textureDesc.uWrap, textureDesc.vWrap);
    texture.unsafeSetFilter(textureDesc.minFilter, textureDesc.magFilter);
    return result;
  }
Example #2
0
 private final int bindTextureRoundRobin(final GLTexture texture) {
   for (int i = 0; i < count; i++) {
     final int idx = (currentTexture + i) % count;
     if (textures[idx] == texture) {
       reused = true;
       return idx;
     }
   }
   currentTexture = (currentTexture + 1) % count;
   textures[currentTexture] = texture;
   texture.bind(offset + currentTexture);
   return currentTexture;
 }
Example #3
0
 private final int bindTextureWeighted(final GLTexture texture) {
   int result = -1;
   int weight = weights[0];
   int windex = 0;
   for (int i = 0; i < count; i++) {
     if (textures[i] == texture) {
       result = i;
       weights[i] += reuseWeight;
     } else if (weights[i] < 0 || --weights[i] < weight) {
       weight = weights[i];
       windex = i;
     }
   }
   if (result < 0) {
     textures[windex] = texture;
     weights[windex] = 100;
     texture.bind(offset + (result = windex));
   } else reused = true;
   return result;
 }