/** * DONT use Only for test!! * * @throws IOException * * @depricated */ public void setTexture(String pName, Texture pImg) { this.addTexture(pName, pImg, this.filter); }
/** * Set texture filter. * * @param pEnabled * enabled */ public void setTextureFilter(boolean pEnabled) { if (this.filter != pEnabled) { this.filter = pEnabled; this.clear(); } }
/** * Get texture from cache or load it to cache. * * @param pName * file name from: <br> * 1. directory {PLUGIN_DIR_NAME}/ <br> * 2. from resources from jar in dir {PLUGIN_JAR}/ <br> * @return texture */ @Override public Texture getTexture(GL gl, String pName) { return this.get(gl, pName); }
@Provides @Singleton TextureCacheService provideTextureCacheService(ResourceService pUrlReciverService) { TextureCacheServiceImpl textureCacheService = new TextureCacheServiceImpl(); textureCacheService.setFileUrlReciverService(pUrlReciverService); textureCacheService.addTextureBuilder(new ColorTextureBuilder()); textureCacheService.addTextureBuilder(new BwFileTextureBuilder(pUrlReciverService)); return textureCacheService; }
/** * {@inheritDoc} * * @see kendzi.buildings.example.BaseJoglFrame#init(com.jogamp.opengl.GLAutoDrawable) */ @Override public void init(GLAutoDrawable drawable) { super.init(drawable); /* * This is required only for textures file finding. Renderer use it to * load files with textures. If textures are not used but only colored * materials it is not required. */ ResourceService resourceService = new LocalResourceReciver(); // cache for textures files. TextureCacheServiceImpl textureCacheService = new TextureCacheServiceImpl(); textureCacheService.setFilter(true); // Manual injection of dependencies. textureCacheService.setFileUrlReciverService(resourceService); textureLibraryStorageService = new TextureLibraryService(resourceService); // Set up of my model renderer to display my model modelRender = new ModelRender(); // Manual injection of dependencies. modelRender.setTextureCacheService(textureCacheService); // Create model mesh. model = createRoofModel(); }
@Provides @Singleton TextureCacheService provideTextureCacheService() { ResourceService resourceService = new LocalResourceReciver(); TextureCacheServiceImpl service = new TextureCacheServiceImpl(); service.setFileUrlReciverService(resourceService); return service; }
/** * Try to get texture. If it isn't laded it well be loaded from:<br> * 1. directory {PLUGIN_DIR_NAME}/textures <br> * 2. from resources from jar in dir {PLUGIN_JAR}/textures <br> * * @param pName * @return */ public Texture get(GL gl, String pName) { Texture texture = this.cache.get(pName); if (texture == null) { texture = loadTexture(gl, pName); if (texture == null) { texture = loadTexture(gl, TEXTURES_UNDEFINED_PNG); } if (texture == null) { log.error("no texture to load!!" + " texture url: " + pName); } else { setupFilter(gl, texture); } this.cache.put(pName, texture); } return texture; }
/** * Get texture image from. * * @param pName * file name from: <br> * 1. directory {PLUGIN_DIR_NAME}/ <br> * 2. from resources from jar in dir {PLUGIN_JAR}/ <br> * @return texture */ @Override public BufferedImage getImage(String pName) { return loadImage(pName); }
return loadTextureFile(pName, this.filter); } catch (Exception e) { log.error("can't load texture", e);
/** * DONT use Only for test!! * * @throws IOException * * @depricated */ public void setTexture(GL gl, String pName, BufferedImage pImg) throws IOException { this.addTexture(gl, pName, pImg, this.filter); }