@Override public Cubemap loadSync (AssetManager manager, String fileName, FileHandle file, CubemapParameter parameter) { if (info == null) return null; Cubemap cubemap = info.cubemap; if (cubemap != null) { cubemap.load(info.data); } else { cubemap = new Cubemap(info.data); } if (parameter != null) { cubemap.setFilter(parameter.minFilter, parameter.magFilter); cubemap.setWrap(parameter.wrapU, parameter.wrapV); } return cubemap; }
@Override protected void disposeColorTexture (Cubemap colorTexture) { colorTexture.dispose(); }
/** Sets the sides of this cubemap to the specified {@link CubemapData}. */ public void load (CubemapData data) { if (!data.isPrepared()) data.prepare(); bind(); unsafeSetFilter(minFilter, magFilter, true); unsafeSetWrap(uWrap, vWrap, true); data.consumeCubemapData(); Gdx.gl.glBindTexture(glTarget, 0); }
@Override protected Cubemap createTexture (FrameBufferTextureAttachmentSpec attachmentSpec) { GLOnlyTextureData data = new GLOnlyTextureData(bufferBuilder.width, bufferBuilder.height, 0, attachmentSpec.internalFormat, attachmentSpec.format, attachmentSpec.type); Cubemap result = new Cubemap(data, data, data, data, data, data); result.setFilter(TextureFilter.Linear, TextureFilter.Linear); result.setWrap(TextureWrap.ClampToEdge, TextureWrap.ClampToEdge); return result; }
public void setEnvironment (String name) { if (name == null) return; if (cubemap != null) { cubemap.dispose(); cubemap = null; } if (name.equals("<none>")) { if (environment.has(CubemapAttribute.EnvironmentMap)) { environment.remove(CubemapAttribute.EnvironmentMap); shaderProvider.clear(); } } else { FileHandle root = Gdx.files.internal("data/g3d/environment"); FacedCubemapData faces = new FacedCubemapData(root.child(name + "_PX.png"), root.child(name+"_NX.png"), root.child(name + "_PY.png"), root.child(name + "_NY.png"), root.child(name + "_PZ.png"), root.child(name + "_NZ.png"), false); // FIXME mipmapping on desktop cubemap = new Cubemap(faces); faces.load(CubemapSide.NegativeX, root.child(name + "_NX.png")); cubemap.load(faces); if (!environment.has(CubemapAttribute.EnvironmentMap)) shaderProvider.clear(); environment.set(new CubemapAttribute(CubemapAttribute.EnvironmentMap, cubemap)); } }
for (int i = 0; i < managedCubemapArray.size; i++) { Cubemap cubemap = managedCubemapArray.get(i); cubemap.reload(); String fileName = assetManager.getAssetFileName(cubemap); if (fileName == null) { cubemap.reload(); } else { params.cubemapData = cubemap.getCubemapData(); params.minFilter = cubemap.getMinFilter(); params.magFilter = cubemap.getMagFilter(); params.wrapU = cubemap.getUWrap(); params.wrapV = cubemap.getVWrap();
/** Construct a Cubemap based on the given CubemapData. */ public Cubemap (CubemapData data) { super(GL20.GL_TEXTURE_CUBE_MAP); this.data = data; load(data); }
public void set(FileHandle positiveX, FileHandle negativeX, FileHandle positiveY, FileHandle negativeY, FileHandle positiveZ, FileHandle negativeZ) { if (cubemap != null) { cubemap.dispose(); } cubemap = new Cubemap(positiveX, negativeX, positiveY, negativeY, positiveZ, negativeZ); this.positiveX = positiveX; this.negativeX = negativeX; this.positiveY = positiveY; this.negativeY = negativeY; this.positiveZ = positiveZ; this.negativeZ = negativeZ; }
/** Disposes all resources associated with the cubemap */ @Override public void dispose () { // this is a hack. reason: we have to set the glHandle to 0 for textures that are // reloaded through the asset manager as we first remove (and thus dispose) the texture // and then reload it. the glHandle is set to 0 in invalidateAllTextures prior to // removal from the asset manager. if (glHandle == 0) return; delete(); if (data.isManaged()) if (managedCubemaps.get(Gdx.app) != null) managedCubemaps.get(Gdx.app).removeValue(this, true); }
public void clearManagedCaches () { Mesh.clearAllMeshes(app); Texture.clearAllTextures(app); Cubemap.clearAllCubemaps(app); TextureArray.clearAllTextureArrays(app); ShaderProgram.clearAllShaderPrograms(app); FrameBuffer.clearAllFrameBuffers(app); logManagedCachesStatus(); }
@Override protected Cubemap createTexture (FrameBufferTextureAttachmentSpec attachmentSpec) { GLOnlyTextureData data = new GLOnlyTextureData(bufferBuilder.width, bufferBuilder.height, 0, attachmentSpec.internalFormat, attachmentSpec.format, attachmentSpec.type); Cubemap result = new Cubemap(data, data, data, data, data, data); result.setFilter(TextureFilter.Linear, TextureFilter.Linear); result.setWrap(TextureWrap.ClampToEdge, TextureWrap.ClampToEdge); return result; }
for (int i = 0; i < managedCubemapArray.size; i++) { Cubemap cubemap = managedCubemapArray.get(i); cubemap.reload(); String fileName = assetManager.getAssetFileName(cubemap); if (fileName == null) { cubemap.reload(); } else { params.cubemapData = cubemap.getCubemapData(); params.minFilter = cubemap.getMinFilter(); params.magFilter = cubemap.getMagFilter(); params.wrapU = cubemap.getUWrap(); params.wrapV = cubemap.getVWrap();
/** Construct a Cubemap based on the given CubemapData. */ public Cubemap (CubemapData data) { super(GL20.GL_TEXTURE_CUBE_MAP); this.data = data; load(data); }
/** Disposes all resources associated with the cubemap */ @Override public void dispose () { // this is a hack. reason: we have to set the glHandle to 0 for textures that are // reloaded through the asset manager as we first remove (and thus dispose) the texture // and then reload it. the glHandle is set to 0 in invalidateAllTextures prior to // removal from the asset manager. if (glHandle == 0) return; delete(); if (data.isManaged()) if (managedCubemaps.get(Gdx.app) != null) managedCubemaps.get(Gdx.app).removeValue(this, true); }
public void clearManagedCaches () { Mesh.clearAllMeshes(app); Texture.clearAllTextures(app); Cubemap.clearAllCubemaps(app); TextureArray.clearAllTextureArrays(app); ShaderProgram.clearAllShaderPrograms(app); FrameBuffer.clearAllFrameBuffers(app); logManagedCachesStatus(); }
@Override public Cubemap loadSync (AssetManager manager, String fileName, FileHandle file, CubemapParameter parameter) { if (info == null) return null; Cubemap cubemap = info.cubemap; if (cubemap != null) { cubemap.load(info.data); } else { cubemap = new Cubemap(info.data); } if (parameter != null) { cubemap.setFilter(parameter.minFilter, parameter.magFilter); cubemap.setWrap(parameter.wrapU, parameter.wrapV); } return cubemap; }
@Override protected Cubemap createTexture (FrameBufferTextureAttachmentSpec attachmentSpec) { GLOnlyTextureData data = new GLOnlyTextureData(bufferBuilder.width, bufferBuilder.height, 0, attachmentSpec.internalFormat, attachmentSpec.format, attachmentSpec.type); Cubemap result = new Cubemap(data, data, data, data, data, data); result.setFilter(TextureFilter.Linear, TextureFilter.Linear); result.setWrap(TextureWrap.ClampToEdge, TextureWrap.ClampToEdge); return result; }