private int scaleTexture() {
int scaledWidth = scale.scaledCeil(width());
int scaledHeight = scale.scaledCeil(height());
int width = GLUtil.nextPowerOfTwo(scaledWidth), height = GLUtil.nextPowerOfTwo(scaledHeight);
if ((width == 0) && (height == 0)) {
int reptex = createPow2RepTex(scaledWidth, scaledHeight, repeatX, repeatY, mipmapped);
if (mipmapped) ctx.generateMipmap(reptex);
return reptex;
}
int tex = createMainTex();
if (width == 0)
width = scaledWidth;
if (height == 0)
height = scaledHeight;
try {
return convertToRepTex(ctx, tex, width, height, repeatX, repeatY, mipmapped);
} finally {
ctx.destroyTexture(tex);
}
}