DentonW / DevIL

Developer's Image Library (DevIL) is a cross-platform image library utilizing a simple syntax to load, save, convert, manipulate, filter, and display a variety of images with ease. It is highly portable and has been ported to several platforms.
http://openil.sourceforge.net/
GNU Lesser General Public License v2.1
446 stars 138 forks source link

bug in IL_NUM_IMAGES for animations #13

Open WilbertD opened 9 years ago

WilbertD commented 9 years ago

There seems to be some issues with IL_NUM_IMAGES:

bcampbell commented 7 years ago

See also #34.

The current implementation of IL_NUM_IMAGES returns the number of images after the currently-bound image. So the result returned depends upon which frame you're currently on (eg if you're on the first frame of a 10 frame animation, IL_NUM_IMAGES will return 9. If you're on frame 2, it'll return 8. And so on.).

The animation support is really fuzzy. I'm planning to do some cleanup to clarify how it all works. Basically, I think that:

The obvious loop is:

num_frames = ilGetInteger(IL_NUM_IMAGES);
for(n=0;n<num_frames; ++n) {
    ilActiveImage(n);
    ... do stuff with frame n...
}

But this doesn't work with the current code. I think it should.

Most of these same issues also apply to Mipmaps, Layers and Cubemap faces. And obviously, it gets even more complicated when you want to deal with, say, animated cubemaps with mipmap levels ;-) So I think my planned changes will break the API... but then I feel it's not too big a deal because the API is already pretty broken in this respect. Feedback welcome!