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 {
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 (mipmapped) ctx.generateMipmap(reptex);
return reptex;
} finally {
ctx.popFramebuffer();
ctx.deleteFramebuffer(fbuf);
}
}
}