rVal.setAnisotropicFilterPercent(_anisotropicFilterPercent); rVal.setApply(_apply); rVal.setConstantColor(_constantColor); rVal.setBorderColor(_borderColor); rVal.setCombineFuncAlpha(_combineFuncAlpha); rVal.setCombineFuncRGB(_combineFuncRGB); rVal.setCombineOp0Alpha(_combineOp0Alpha); rVal.setCombineOp0RGB(_combineOp0RGB); rVal.setCombineOp1Alpha(_combineOp1Alpha); rVal.setCombineOp1RGB(_combineOp1RGB); rVal.setCombineOp2Alpha(_combineOp2Alpha); rVal.setCombineOp2RGB(_combineOp2RGB); rVal.setCombineScaleAlpha(_combineScaleAlpha); rVal.setCombineScaleRGB(_combineScaleRGB); rVal.setCombineSrc0Alpha(_combineSrc0Alpha); rVal.setCombineSrc0RGB(_combineSrc0RGB); rVal.setCombineSrc1Alpha(_combineSrc1Alpha); rVal.setCombineSrc1RGB(_combineSrc1RGB); rVal.setCombineSrc2Alpha(_combineSrc2Alpha); rVal.setCombineSrc2RGB(_combineSrc2RGB); rVal.setDepthCompareFunc(_depthCompareFunc); rVal.setDepthCompareMode(_depthCompareMode); rVal.setDepthMode(_depthMode); rVal.setEnvironmentalMapMode(_envMapMode); rVal.setEnvPlaneS(_envPlaneS); rVal.setEnvPlaneT(_envPlaneT); rVal.setEnvPlaneR(_envPlaneR); rVal.setEnvPlaneQ(_envPlaneQ); rVal.setHasBorder(_hasBorder);
if (getImage() != null && !getImage().equals(that.getImage())) { return false; if (getImage() == null && that.getImage() != null) { return false; if (getAnisotropicFilterPercent() != that.getAnisotropicFilterPercent()) { return false; if (getApply() != that.getApply()) { return false; if (getCombineFuncAlpha() != that.getCombineFuncAlpha()) { return false; if (getCombineFuncRGB() != that.getCombineFuncRGB()) { return false; if (getCombineOp0Alpha() != that.getCombineOp0Alpha()) { return false; if (getCombineOp1RGB() != that.getCombineOp1RGB()) { return false; if (getCombineOp2Alpha() != that.getCombineOp2Alpha()) { return false; if (getCombineOp2RGB() != that.getCombineOp2RGB()) { return false;
@Override public Texture createSimpleClone(final Texture rVal) { rVal.setWrap(WrapAxis.S, _wrapS); rVal.setWrap(WrapAxis.T, _wrapT); rVal.setWrap(WrapAxis.R, _wrapR); return super.createSimpleClone(rVal); }
/** * Retrieve a basic clone of this Texture (ie, clone everything but the image data, which is shared) * * @return Texture */ public Texture createSimpleClone(final Texture rVal) { rVal.setAnisotropicFilterPercent(_anisotropicFilterPercent); rVal.setBorderColor(_borderColor); rVal.setDepthCompareFunc(_depthCompareFunc); rVal.setDepthCompareMode(_depthCompareMode); rVal.setHasBorder(_hasBorder); rVal.setTextureStoreFormat(_storeFormat); rVal.setRenderedTexturePixelDataType(_rttPixelDataType); rVal.setImage(_image); // NOT CLONED. rVal.setLodBias(_lodBias); rVal.setMinificationFilter(_minificationFilter); rVal.setMagnificationFilter(_magnificationFilter); rVal.setStoreImage(_storeImage); if (getTextureKey() != null) { rVal.setTextureKey(getTextureKey()); } return rVal; }
@Override public boolean equals(final Object other) { if (other == this) { return true; } if (!(other instanceof Texture)) { return false; } final Texture that = (Texture) other; if (getImage() != null && !getImage().equals(that.getImage())) { return false; } if (getImage() == null && that.getImage() != null) { return false; } if (getAnisotropicFilterPercent() != that.getAnisotropicFilterPercent()) { return false; } if (getMagnificationFilter() != that.getMagnificationFilter()) { return false; } if (getMinificationFilter() != that.getMinificationFilter()) { return false; } if (!_borderColor.equals(that._borderColor)) { return false; } return true; }
if (tex.getType() != Type.TwoDimensional) { throw new IllegalArgumentException("Unsupported type: " + tex.getType()); if (tex.getTextureKey() == null) { tex.setTextureKey(TextureKey.getRTTKey(tex.getMinificationFilter())); } else if (tex.getTextureIdForContext(context.getGlContextRep()) != 0) { throw new Ardor3dException("Texture is already setup and has id."); GL11.glGenTextures(ibuf); final int textureId = ibuf.get(0); tex.setTextureIdForContext(context.getGlContextRep(), textureId); final int internalFormat = LwjglTextureUtil.getGLInternalFormat(tex.getTextureStoreFormat()); final int dataFormat = LwjglTextureUtil.getGLPixelFormatFromStoreFormat(tex.getTextureStoreFormat()); final int pixelDataType = LwjglTextureUtil.getGLPixelDataType(tex.getRenderedTexturePixelDataType()); final TextureRecord texRecord = record.getTextureRecord(textureId, tex.getType()); LwjglTextureStateUtil.applyFilter(tex, texRecord, 0, record, context.getCapabilities()); LwjglTextureStateUtil.applyWrap(tex, texRecord, 0, record, context.getCapabilities());
texture.getTextureKey().markClean(context); final Texture.Type type = texture.getType(); final Image image = texture.getImage(); final boolean hasBorder = texture.hasBorder(); if (image == null) { logger.warning("Image data for texture is null."); if (!texture.getMinificationFilter().usesMipMapLevels() && !texture.getTextureStoreFormat().isCompressed()) { switch (texture.getType()) { case TwoDimensional: Lwjgl3TextureUtils.getGLInternalFormat(texture.getTextureStoreFormat()), image.getWidth(), image.getHeight(), hasBorder ? 1 : 0, Lwjgl3TextureUtils.getGLPixelFormat(image.getDataFormat()), Lwjgl3TextureUtils.getGLInternalFormat(texture.getTextureStoreFormat()), image.getWidth(), hasBorder ? 1 : 0, Lwjgl3TextureUtils.getGLPixelFormat(image.getDataFormat()), Lwjgl3TextureUtils.getGLInternalFormat(texture.getTextureStoreFormat()), image.getWidth(), image.getHeight(), image.getDepth(), hasBorder ? 1 : 0, Lwjgl3TextureUtils.getGLPixelFormat(image.getDataFormat()), Lwjgl3TextureUtils.getGLInternalFormat(texture.getTextureStoreFormat()), image.getWidth(), image.getWidth(), hasBorder ? 1 : 0,
int textureId = texture != null ? texture.getTextureIdForContext(context) : 0; if (texture == null || (texture != null && textureId == 0 && texture.getImage() == null)) { continue; type = texture.getType(); textureId = texture.getTextureIdForContext(context); if (textureId == 0) { continue; } else if (texture.isDirty(context)) { update(texture, i); textureId = texture.getTextureIdForContext(context); if (textureId == 0) { continue; final Integer textureIdInteger = texture.getTextureIdForContextAsInteger(context); texRecord = record.getTextureRecord(textureIdInteger, texture.getType()); state._keyCache[i] = texture.getTextureKey();
result = cache.createSimpleClone(); if (result.getTextureKey() == null) { result.setTextureKey(tkey); cache.createSimpleClone(result); return result; result.setTextureKey(tkey); result.setImage(img); result.setMinificationFilter(tkey.getMinificationFilter()); result.setTextureStoreFormat(ImageUtils.getTextureStoreFormat(tkey.getFormat(), result.getImage()));
@MainThread public static void preloadCache(final Renderer r) { for (final Texture t : _tCache.values()) { if (t == null) { continue; } if (t.getTextureKey().getSource() != null) { r.loadTexture(t, 0); } } }
public static Image getDefaultTextureImage() { return _defaultTexture != null ? _defaultTexture.getImage() : null; }
final Type type = texture.getType(); final int magFilter = Lwjgl3TextureUtils.getGLMagFilter(texture.getMagnificationFilter()); final int minFilter = Lwjgl3TextureUtils.getGLMinFilter(texture.getMinificationFilter()); float aniso = texture.getAnisotropicFilterPercent() * (caps.getMaxAnisotropic() - 1.0f); aniso += 1.0f; if (!texRecord.isValid() || (texRecord.anisoLevel - aniso > MathUtils.ZERO_TOLERANCE)) {
if (destination.getTextureIdForContext(ContextManager.getCurrentContext()) == 0) { logger.warning("Attempting to update a texture that is not currently on the card."); return; if (destination.getImage() != null) { pixelFormat = Lwjgl3TextureUtils.getGLPixelFormat(destination.getImage().getDataFormat()); } else { pixelFormat = Lwjgl3TextureUtils.getGLPixelFormatFromStoreFormat(destination.getTextureStoreFormat()); switch (destination.getType()) { case TwoDimensional: GL11C.glTexSubImage2D(GL11C.GL_TEXTURE_2D, 0, dstOffsetX, dstOffsetY, dstWidth, dstHeight, break; default: throw new Ardor3dException("Unsupported type for updateTextureSubImage: " + destination.getType());
for (int i = 0; i < texs.size(); i++) { final Texture tex = texs.get(i); if (tex.getTextureStoreFormat().isDepthFormat()) { depths.add(tex); } else { while (colorsAdded < maxDrawBuffers && !colors.isEmpty()) { final Texture tex = colors.removeFirst(); if (tex.getType() == Type.TwoDimensional) { GL30C.glFramebufferTexture2D(GL30C.GL_FRAMEBUFFER, GL30C.GL_COLOR_ATTACHMENT0 + colorsAdded, GL11C.GL_TEXTURE_2D, tex.getTextureIdForContext(context), tex.getTexRenderMipLevel()); } else if (tex.getType() == Type.CubeMap) { GL30C.glFramebufferTexture2D(GL30C.GL_FRAMEBUFFER, GL30C.GL_COLOR_ATTACHMENT0 + colorsAdded, Lwjgl3TextureStateUtil.getGLCubeMapFace(((TextureCubeMap) tex).getCurrentRTTFace()), tex.getTextureIdForContext(context), tex.getTexRenderMipLevel()); } else { throw new IllegalArgumentException("Invalid texture type: " + tex.getType()); if (tex.getType() == Type.TwoDimensional) { GL30C.glFramebufferTexture2D(GL30C.GL_FRAMEBUFFER, GL30C.GL_DEPTH_ATTACHMENT, GL11C.GL_TEXTURE_2D, tex.getTextureIdForContext(context), tex.getTexRenderMipLevel()); } else if (tex.getType() == Type.CubeMap) { GL30C.glFramebufferTexture2D(GL30C.GL_FRAMEBUFFER, GL30C.GL_DEPTH_ATTACHMENT, Lwjgl3TextureStateUtil.getGLCubeMapFace(((TextureCubeMap) tex).getCurrentRTTFace()), tex.getTextureIdForContext(context), tex.getTexRenderMipLevel()); } else { throw new IllegalArgumentException("Invalid texture type: " + tex.getType()); if (texs.get(x).getMinificationFilter().usesMipMapLevels()) {
final Texture cached = TextureManager.findCachedTexture(texture.getTextureKey()); final int textureId = cached.getTextureIdForContext(context); if (textureId != 0) { doTextureBind(cached, unit, false); texture.setTextureIdForContext(context, textureId);
/** * Add a given texture to the cache * * @param texture * our texture */ public static void addToCache(final Texture texture) { if (TextureState.getDefaultTexture() == null || (texture != TextureState.getDefaultTexture() && texture.getImage() != TextureState.getDefaultTextureImage())) { _tCache.put(texture.getTextureKey(), texture); } }
@Override protected void takedownForSingleTexDraw(final Texture tex) { if (isEnableMipGeneration()) { // automatically generate mipmaps for our texture, if supported. if (tex.getMinificationFilter().usesMipMapLevels()) { Lwjgl3TextureStateUtil.doTextureBind(tex, 0, true); GL30C.glGenerateMipmap(Lwjgl3TextureStateUtil.getGLType(tex.getType())); } } tex.getTextureKey().markClean(ContextManager.getCurrentContext()); }
for (int i = 0; i < texs.size(); i++) { final Texture tex = texs.get(i); if (tex.getTextureStoreFormat().isDepthFormat()) { depths.add(tex); } else { while (colorsAdded < maxDrawBuffers && !colors.isEmpty()) { final Texture tex = colors.removeFirst(); if (tex.getType() == Type.TwoDimensional) { EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT + colorsAdded, GL11.GL_TEXTURE_2D, tex.getTextureIdForContext(context.getGlContextRep()), 0); } else if (tex.getType() == Type.CubeMap) { EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT + colorsAdded, LwjglTextureStateUtil.getGLCubeMapFace(((TextureCubeMap) tex).getCurrentRTTFace()), tex.getTextureIdForContext(context.getGlContextRep()), 0); } else { throw new IllegalArgumentException("Invalid texture type: " + tex.getType()); if (tex.getType() == Type.TwoDimensional) { EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, GL11.GL_TEXTURE_2D, tex.getTextureIdForContext(context.getGlContextRep()), 0); } else if (tex.getType() == Type.CubeMap) { EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, LwjglTextureStateUtil.getGLCubeMapFace(((TextureCubeMap) tex).getCurrentRTTFace()), tex.getTextureIdForContext(context.getGlContextRep()), 0);
private void applySampler(final Element sampler, final Texture texture) { if (sampler.getChild("minfilter") != null) { final String minfilter = sampler.getChild("minfilter").getText(); texture.setMinificationFilter(Enum.valueOf(SamplerTypes.MinFilterType.class, minfilter).getArdor3dFilter()); } if (sampler.getChild("magfilter") != null) { final String magfilter = sampler.getChild("magfilter").getText(); texture.setMagnificationFilter( Enum.valueOf(SamplerTypes.MagFilterType.class, magfilter).getArdor3dFilter()); } if (sampler.getChild("wrap_s") != null) { final String wrapS = sampler.getChild("wrap_s").getText(); texture.setWrap(Texture.WrapAxis.S, Enum.valueOf(SamplerTypes.WrapModeType.class, wrapS).getArdor3dWrapMode()); } if (sampler.getChild("wrap_t") != null) { final String wrapT = sampler.getChild("wrap_t").getText(); texture.setWrap(Texture.WrapAxis.T, Enum.valueOf(SamplerTypes.WrapModeType.class, wrapT).getArdor3dWrapMode()); } if (sampler.getChild("border_color") != null) { texture.setBorderColor(_colladaDOMUtil.getColor(sampler.getChild("border_color").getText())); } }
public ColorReplaceEffect(final Texture colorRampTexture) { _colorRampTexture = colorRampTexture; _colorRampTexture.setWrap(WrapMode.EdgeClamp); }