Aha, now we have it! (Sorry if I was a bit of an a-hole.)
This line in main:
Code:
timeline oTimeline;
fires off a bunch of default ctors for all the textures in the timeline class before the code for the timeline ctor executes. Those default texture ctors do not actually aquire textures and therefore do not increment the count or set any flags to false. All that happens is that the first invocation calls initList() (which of course sets all the flags to true).
But then in the code of the timeline ctor all the textures are replaced by statements like this
Code:
blockHighlight = texture( tempSurf);
The above will call the dtor for blockHighlight before replacing it with the new texture object. That's the problem. They are calling the dtor which decrements the count and sets index glTexture to true (glTexture presumably being 0 all the time). And that's done AFTER the ctor for the new texture fires!
One solution is to make them all pointers so they don't fire off the texture ctor before the code in the timeline ctor gets to do it's thing.
Then you'd have lines like
Code:
blockHighlight = new texture( tempSurf);
and you'd have to delete them all in timelines dtor.
Here's a mini example of the problem:
Code:
#include <iostream>
using std::cout;
class A {
public:
static int n;
A() {}
A(int x) { ++n; }
~A() { --n; }
static void show() { cout << n << "\n"; }
};
int A::n = 0;
class B {
public:
A a1, a2, a3;
B() {
a1 = A(1);
a2 = A(2);
a3 = A(3);
}
};
int main() {
B b;
A::show();
}
You might think that A::show() should print 3, but it will print 0.