/** * DONT use Only for test!! * * @throws IOException * * @depricated */ public void setTexture(String pName, Texture pImg) { this.addTexture(pName, pImg, this.filter); }
private Texture getTexture(GL gl, String file) { if (file != null) { return textureCacheService.getTexture(gl, file); } return textureCacheService.getTexture(gl, "/textures/undefined.png"); }
/** * Set texture filter. * * @param pEnabled * enabled */ public void setTextureFilter(boolean pEnabled) { if (this.filter != pEnabled) { this.filter = pEnabled; this.clear(); } }
public void draw(GL2 gl, Point3d cameraPosition) { gl.glEnable(GL2.GL_LIGHTING); gl.glEnable(GL2.GL_TEXTURE_2D); TextureData td = this.textureLibraryStorageService.getTextureDefault("ground.unknown"); Texture texture = this.textureCacheService.getTexture(gl, td.getTex0()); texture.enable(gl); texture.bind(gl); gl.glBegin(GL2.GL_POLYGON); gl.glColor3f((float) 123 / 256, (float) 111 / 256, (float) 100 / 255); double groundSize = 1500.0; Point3d c = cameraPosition; // gl.glTexCoord2d(tc.left(), tc.bottom()); double xRight = c.x + groundSize; double xLeft = c.x - groundSize; double zButtom = c.z + groundSize; double zTop = c.z - groundSize; gl.glNormal3d(0, 1, 0); gl.glTexCoord2d(xRight * td.getWidth(), zButtom * td.getHeight()); gl.glVertex3d(xRight, -0.01, zButtom); gl.glTexCoord2d(xLeft * td.getWidth(), zButtom * td.getHeight()); gl.glVertex3d(xLeft, -0.01, zButtom); gl.glTexCoord2d(xLeft * td.getWidth(), zTop * td.getHeight()); gl.glVertex3d(xLeft, -0.01, zTop); gl.glTexCoord2d(xRight * td.getWidth(), zTop * td.getHeight()); gl.glVertex3d(xRight, -0.01, zTop); gl.glEnd(); texture.disable(gl); gl.glDisable(GL2.GL_TEXTURE_2D); }
@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; }
if (!textureCacheService.isTexture(textName)) { if (titleFrameCount == 0) { ((TextureCacheServiceImpl) textureCacheService).setTexture(textName, texture); texture = textureCacheService.getTexture(gl, TextureCacheService.TEXTURES_UNDEFINED_PNG); texture = textureCacheService.getTexture(gl, textName);
private BufferedImage loadImage(String pName) { BufferedImage texture = null; if (pName != null && this.textureBuilderList != null) { // builders for (TextureBuilder tb : this.textureBuilderList) { if (pName.startsWith(tb.getBuilderPrefix())) { texture = tb.buildImage(pName); if (texture != null) { return texture; } } } try { return loadTextureImageFile(pName); } catch (Exception e) { log.error("can't load texture", e); return null; } } return null; }
if (pName.startsWith(tb.getBuilderPrefix())) { try { texture = tb.buildTexture(pName); } catch (Exception e) { return loadTextureFile(pName, this.filter); } catch (Exception e) { log.error("can't load texture", e);
/** * @param pEnable * enable filter */ private void setTextureFilter(boolean pEnable) { if (textureCacheService instanceof TextureCacheServiceImpl) { ((TextureCacheServiceImpl) textureCacheService).setTextureFilter(pEnable); textureCacheService.clear(); } else { throw new RuntimeException("unsupported textureCacheService"); } } }
/** * 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 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); }
/** * 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); }
@Override protected void onOpenWindow() { dataConsumersMonitor.addDataConsumer(); /* * OpenGl context is stored per window, if we open new one we need to * clean up old textures. */ textureCacheService.clear(); /* * Data updates ware turn off after window closes. We need to rebuild * whole dataset. */ dataEventListener.add(new NewDataEvent()); }
TextureCoords tc = new TextureCoords(0, 0, 1, 1); if (textureName != null) { Texture texture = textureCacheService.getTexture(gl, textureName); Texture t = textureCacheService.getTexture(gl, textureName); if (t != null) { t.disable(gl);
/** * 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); }
double maxy = miny + size; Texture texture = textureCacheService.getTexture(gl, icon); if (texture == null) { return;