@Override public boolean isRenderable() { for (Texture texture : textureMap.valueCollection()) { if (!texture.isLoaded()) { return false; } } return true; }
public void beginRenderOverlay() { if (effectsTexture == null || !effectsTexture.isLoaded()) { return; } defaultTextured.activateFeature(ShaderProgramFeature.FEATURE_ALPHA_REJECT); defaultTextured.enable(); glBindTexture(GL11.GL_TEXTURE_2D, effectsTexture.getId()); glEnable(GL11.GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); }
/** * Creates a new entity for the block damage particle effect. * * If the terrain texture of the damaged block is available, the particles will have the block texture. Otherwise, * the default sprite (smoke) is used. * * @param family the {@link BlockFamily} of the damaged block * @param location the location of the damaged block */ private void createBlockParticleEffect(BlockFamily family, Vector3f location) { EntityBuilder builder = entityManager.newBuilder("core:defaultBlockParticles"); builder.getComponent(LocationComponent.class).setWorldPosition(location); Optional<Texture> terrainTexture = Assets.getTexture("engine:terrain"); if (terrainTexture.isPresent() && terrainTexture.get().isLoaded()) { final BlockAppearance blockAppearance = family.getArchetypeBlock().getPrimaryAppearance(); final float relativeTileSize = worldAtlas.getRelativeTileSize(); final float particleScale = 0.25f; final float spriteSize = relativeTileSize * particleScale; ParticleDataSpriteComponent spriteComponent = builder.getComponent(ParticleDataSpriteComponent.class); spriteComponent.texture = terrainTexture.get(); spriteComponent.textureSize.set(spriteSize, spriteSize); final List<Vector2f> offsets = computeOffsets(blockAppearance, particleScale); TextureOffsetGeneratorComponent textureOffsetGeneratorComponent = builder.getComponent(TextureOffsetGeneratorComponent.class); textureOffsetGeneratorComponent.validOffsets.addAll(offsets); } builder.build(); }
@Override public void drawTexture(TextureRegion texture, Color color, ScaleMode mode, Rect2i absoluteRegion, float ux, float uy, float uw, float uh, float alpha) { if (!texture.getTexture().isLoaded()) { return;
@Override public void drawTextureBordered(TextureRegion texture, Rect2i region, Border border, boolean tile, float ux, float uy, float uw, float uh, float alpha) { if (!texture.getTexture().isLoaded()) { return;