I am trying to do a fairly straight forward 2D, rectangular mipmap’d texture, and failing spectacularly.
First off, I don’t know whether what I want is allowed. I have 4 images, all black and white rendered text. The full scale is, well, full scale. Then I also generated 2 smaller images: one where each character maps to a single pixel, so 80x100 line file renders to 80x100 px, and an even smaller one where each line maps to a single pixel, so an 80x100 line file becomes a 1x100 px image.
So, in general, can mipmap’ing be made to work with this kind of data? I haven’t found a definitive answer as to whether you have to do the pure geometricly-sized sequence thing.
Second, when trying exactly this code, I got this error:
Required 9240 remaining bytes in buffer, only had 465
After digging around through the various source layers, I found that Texture.updateSubImageImpl() ultimately seems to choose the buffer from the array; but there is something screwy here – 465 bytes matches up with the smallest image, and 9240 matches up with the next size up. So if it gets the right expected size, why would it get the wrong buffer?
My code is based off another JGO post: http://www.java-gaming.org/index.php/topic,18507.msg154256.html#msg154256
// load all mipmaps levels
ArrayList<TextureData> mmLevels = new ArrayList<TextureData>(4);
for (int i = 0; i < imgs.size(); i++) {
try {
ByteArrayInputStream is = new ByteArrayInputStream(imgs.get(i));
TextureData mmLevel = TextureIO.newTextureData(is, false, "png");
mmLevels.add(mmLevel);
}
catch (IOException e) {
assert false; // NOTREACHED
}
}
// collect buffers
Buffer[] buffers = new Buffer[mmLevels.size()];
int level = 0;
for (TextureData mmLevel : mmLevels) {
buffers[level] = mmLevel.getBuffer();
level++;
}
// create the texture
TextureData top = mmLevels.get(0);
TextureData textureData = new TextureData(top.getInternalFormat(),
top.getWidth(), top.getHeight(), 0, top.getPixelFormat(),
top.getPixelType(), false, false, buffers, null);
return TextureIO.newTexture(textureData);
Any ideas? Am I misunderstanding something, or just missing some obvious bug in my code?
Thanks!
ben