public Texture renderText(String text) { if (text != null && text.length() > 0) { Bitmap bitmap = this.drawText(text); return new Texture(bitmap); } else { return null; } }
protected Texture createTexture(ImageSource imageSource, ImageOptions options, Bitmap bitmap) { Texture texture = new Texture(bitmap); if (options != null && options.resamplingMode == WorldWind.NEAREST_NEIGHBOR) { texture.setTexParameter(GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST); texture.setTexParameter(GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST); } if (options != null && options.wrapMode == WorldWind.REPEAT) { texture.setTexParameter(GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_REPEAT); texture.setTexParameter(GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_REPEAT); } return texture; }
/** * Returns an OpenGL framebuffer object suitable for offscreen drawing. The framebuffer has a 32-bit color buffer * and a 32-bit depth buffer, both attached as OpenGL texture 2D objects. * <p> * The framebuffer may be used by any drawable and for any purpose. However, the draw context makes no guarantees * about the framebuffer's contents. Drawables must clear the framebuffer before use, and must assume its contents * may be modified by another drawable, either during the current frame or in a subsequent frame. * <p> * The OpenGL framebuffer object is created on first use and cached. Subsequent calls to this method return the * cached buffer object. * * @return the draw context's scratch OpenGL framebuffer object */ public Framebuffer scratchFramebuffer() { if (this.scratchFramebuffer != null) { return this.scratchFramebuffer; } Framebuffer framebuffer = new Framebuffer(); Texture colorAttachment = new Texture(1024, 1024, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE); Texture depthAttachment = new Texture(1024, 1024, GLES20.GL_DEPTH_COMPONENT, GLES20.GL_UNSIGNED_SHORT); // TODO consider modifying Texture's tex parameter behavior in order to make this unnecessary depthAttachment.setTexParameter(GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST); depthAttachment.setTexParameter(GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST); framebuffer.attachTexture(this, colorAttachment, GLES20.GL_COLOR_ATTACHMENT0); framebuffer.attachTexture(this, depthAttachment, GLES20.GL_DEPTH_ATTACHMENT); return (this.scratchFramebuffer = framebuffer); }