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; }
@Override public void dispose () { delete(); }
@Override public void consumeCustomData (int target) { for(int i=0; i < mips.length; ++i){ GLTexture.uploadImageData(target, mips[i], i); } }
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; }
@Override public int hashCode () { long result = (texture == null ? 0 : texture.glTarget); result = 811 * result + (texture == null ? 0 : texture.getTextureObjectHandle()); result = 811 * result + (minFilter == null ? 0 : minFilter.getGLEnum()); result = 811 * result + (magFilter == null ? 0 : magFilter.getGLEnum()); result = 811 * result + (uWrap == null ? 0 : uWrap.getGLEnum()); result = 811 * result + (vWrap == null ? 0 : vWrap.getGLEnum()); return (int)(result ^ (result >> 32)); }
/** Sets the {@link TextureFilter} for this texture for minification and magnification. Assumes the texture is bound and active! * @param minFilter the minification filter * @param magFilter the magnification filter */ public void unsafeSetFilter (TextureFilter minFilter, TextureFilter magFilter) { unsafeSetFilter(minFilter, magFilter, false); }
/** Sets the {@link TextureWrap} for this texture on the u and v axis. Assumes the texture is bound and active! * @param u the u wrap * @param v the v wrap */ public void unsafeSetWrap (TextureWrap u, TextureWrap v) { unsafeSetWrap(u, v, false); }
set(u_shadowMapProjViewTrans, lights.shadowMap.getProjViewTrans()); set(u_shadowTexture, lights.shadowMap.getDepthMap()); set(u_shadowPCFOffset, 1.f / (2f * lights.shadowMap.getDepthMap().texture.getWidth()));
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; }
@Override public int hashCode () { long result = (texture == null ? 0 : texture.glTarget); result = 811 * result + (texture == null ? 0 : texture.getTextureObjectHandle()); result = 811 * result + (minFilter == null ? 0 : minFilter.getGLEnum()); result = 811 * result + (magFilter == null ? 0 : magFilter.getGLEnum()); result = 811 * result + (uWrap == null ? 0 : uWrap.getGLEnum()); result = 811 * result + (vWrap == null ? 0 : vWrap.getGLEnum()); return (int)(result ^ (result >> 32)); }
/** Sets the {@link TextureFilter} for this texture for minification and magnification. Assumes the texture is bound and active! * @param minFilter the minification filter * @param magFilter the magnification filter */ public void unsafeSetFilter (TextureFilter minFilter, TextureFilter magFilter) { unsafeSetFilter(minFilter, magFilter, false); }
/** Sets the {@link TextureWrap} for this texture on the u and v axis. Assumes the texture is bound and active! * @param u the u wrap * @param v the v wrap */ public void unsafeSetWrap (TextureWrap u, TextureWrap v) { unsafeSetWrap(u, v, false); }
set(u_shadowMapProjViewTrans, lights.shadowMap.getProjViewTrans()); set(u_shadowTexture, lights.shadowMap.getDepthMap()); set(u_shadowPCFOffset, 1.f / (2f * lights.shadowMap.getDepthMap().texture.getWidth()));
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; }
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; }
@Override public int compareTo (TextureDescriptor<T> o) { if (o == this) return 0; int t1 = texture == null ? 0 : texture.glTarget; int t2 = o.texture == null ? 0 : o.texture.glTarget; if (t1 != t2) return t1 - t2; int h1 = texture == null ? 0 : texture.getTextureObjectHandle(); int h2 = o.texture == null ? 0 : o.texture.getTextureObjectHandle(); if (h1 != h2) return h1 - h2; if (minFilter != o.minFilter) return (minFilter == null ? 0 : minFilter.getGLEnum()) - (o.minFilter == null ? 0 : o.minFilter.getGLEnum()); if (magFilter != o.magFilter) return (magFilter == null ? 0 : magFilter.getGLEnum()) - (o.magFilter == null ? 0 : o.magFilter.getGLEnum()); if (uWrap != o.uWrap) return (uWrap == null ? 0 : uWrap.getGLEnum()) - (o.uWrap == null ? 0 : o.uWrap.getGLEnum()); if (vWrap != o.vWrap) return (vWrap == null ? 0 : vWrap.getGLEnum()) - (o.vWrap == null ? 0 : o.vWrap.getGLEnum()); return 0; } }
@Override public void consumeCustomData (int target) { for(int i=0; i < mips.length; ++i){ GLTexture.uploadImageData(target, mips[i], i); } }
/** Sets the {@link TextureFilter} for this texture for minification and magnification. Assumes the texture is bound and active! * @param minFilter the minification filter * @param magFilter the magnification filter */ public void unsafeSetFilter (TextureFilter minFilter, TextureFilter magFilter) { unsafeSetFilter(minFilter, magFilter, false); }
@Override public void dispose () { delete(); }
/** Sets the {@link TextureWrap} for this texture on the u and v axis. Assumes the texture is bound and active! * @param u the u wrap * @param v the v wrap */ public void unsafeSetWrap (TextureWrap u, TextureWrap v) { unsafeSetWrap(u, v, false); }