|
public class TextureSizeNPOT extends TextureSize
{
protected int ixSize;
public TextureSizeNPOT(int maxSize)
{
super(maxSize);
}
public static int STEP_SIZE = 64;
public void inc()
{
// if (height > width && ixSize % 1 == 0)
// {
// int temp = height;
// height = width;
// width = temp;
// }
if (height > width)
width += STEP_SIZE;
else
height += STEP_SIZE;
// ixSize++;
checkMax();
}
public void dec()
{
if (height < width)
width -= STEP_SIZE;
else
height -= STEP_SIZE;
// ixSize++;
checkMin();
}
public void getNextSizeFits(int pixelsReq, int maxWidth, int maxHeight)
{
// some of the smaller images fit into the other textures
// so deliberly choose smaller size
ixSize = 0;
int size = (int)Math.round(Math.sqrt(pixelsReq));
if (size < 32) size = 32;
if (maxWidth > size)
{
width = maxWidth;
height = (int)pixelsReq / width+1;
}
else
{
width = size;
}
if (maxHeight > size)
{
height = maxHeight;
width = (int)pixelsReq / height+1;
}
else
{
height = size;
}
checkMax();
}
public boolean isNPOT() { return true; }
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
After working in the software industry for many years, I've started my own
games company that specialises in strategy games for mobile platforms.