/** * Creates and populates a texture for use as our power-of-two texture. This is used when our * main image data is already power-of-two-sized. */ protected int createPow2RepTex(int width, int height, boolean repeatX, boolean repeatY, boolean mipmapped) { int powtex = ctx.createTexture(width, height, repeatX, repeatY, mipmapped); updateTexture(powtex); return powtex; }
/** * Creates and populates a (not necessarily power of two) texture for use as our main texture. */ protected int createMainTex() { // the mipmaps flag is always false here because we only ever generate mipmaps for our // power-of-two textures; scaleTexture will use tex to create the POT texture, so tex should // not have mipmaps enabled, or it will hose up that process int tex = ctx.createTexture(false, false, false); updateTexture(tex); return tex; }
protected void createTexture() { tex = ctx.createTexture(texWidth, texHeight, false, false, false); fbuf = ctx.createFramebuffer(tex); ctx.bindFramebuffer(fbuf, texWidth, texHeight); ctx.clear(0, 0, 0, 0); }
protected static int convertToRepTex(GLContext ctx, int tex, int width, int height, boolean repeatX, boolean repeatY, boolean mipmapped) { int reptex = ctx.createTexture(width, height, repeatX, repeatY, mipmapped); int fbuf = ctx.createFramebuffer(reptex); ctx.pushFramebuffer(fbuf, width, height); try { // render the non-repeated texture into the framebuffer properly scaled ctx.clear(0, 0, 0, 0); GLShader shader = ctx.quadShader(null).prepareTexture(tex, Tint.NOOP_TINT); shader.addQuad(ctx.createTransform(), 0, height, width, 0, 0, 0, 1, 1); shader.flush(); // if we're mipmapped, we can now generate our mipmaps if (mipmapped) ctx.generateMipmap(reptex); return reptex; } finally { // we no longer need this framebuffer; rebind the previous framebuffer and delete ours ctx.popFramebuffer(); ctx.deleteFramebuffer(fbuf); } } }
int reptex = ctx.createTexture(width, height, repeatX, repeatY, mipmapped); int fbuf = ctx.createFramebuffer(reptex); ctx.pushFramebuffer(fbuf, width, height);