/** * Make a duplicate of this cube Map. That means that it's another instant * od TextureCubeMap, but the underlying buffers are duplicates of the * original ones. see {@link ByteBuffer#duplicate()} * * Use this if you need to read from the map from multiple threads, it * should garanty the thread safety. Note that if you want to write to the * cube map you have to make sure that the different thread do not write to * the same area of the buffer. The position, limit and mark are not an * issue. * * @param sourceMap * @return */ public static TextureCubeMap duplicateCubeMap(TextureCubeMap sourceMap) { Image srcImg = sourceMap.getImage(); Image cubeImage = new Image(srcImg.getFormat(), srcImg.getWidth(), srcImg.getHeight(), null, srcImg.getColorSpace()); for (ByteBuffer d : srcImg.getData()) { cubeImage.addData(d.duplicate()); } cubeImage.setMipMapSizes(srcImg.getMipMapSizes()); TextureCubeMap cubeMap = new TextureCubeMap(cubeImage); cubeMap.setAnisotropicFilter(sourceMap.getAnisotropicFilter()); cubeMap.setMagFilter(sourceMap.getMagFilter()); cubeMap.setMinFilter(sourceMap.getMinFilter()); cubeMap.setWrap(sourceMap.getWrap(Texture.WrapAxis.S)); return cubeMap; }
/** * Make a duplicate of this cube Map. That means that it's another instant * od TextureCubeMap, but the underlying buffers are duplicates of the * original ones. see {@link ByteBuffer#duplicate()} * * Use this if you need to read from the map from multiple threads, it * should garanty the thread safety. Note that if you want to write to the * cube map you have to make sure that the different thread do not write to * the same area of the buffer. The position, limit and mark are not an * issue. * * @param sourceMap * @return */ public static TextureCubeMap duplicateCubeMap(TextureCubeMap sourceMap) { Image srcImg = sourceMap.getImage(); Image cubeImage = new Image(srcImg.getFormat(), srcImg.getWidth(), srcImg.getHeight(), null, srcImg.getColorSpace()); for (ByteBuffer d : srcImg.getData()) { cubeImage.addData(d.duplicate()); } cubeImage.setMipMapSizes(srcImg.getMipMapSizes()); TextureCubeMap cubeMap = new TextureCubeMap(cubeImage); cubeMap.setAnisotropicFilter(sourceMap.getAnisotropicFilter()); cubeMap.setMagFilter(sourceMap.getMagFilter()); cubeMap.setMinFilter(sourceMap.getMinFilter()); cubeMap.setWrap(sourceMap.getWrap(Texture.WrapAxis.S)); return cubeMap; }