Just want to share my suckyness with you all. This morning I wanted a way to dynamicly assign images runtime, and along the way completely forgot everything I learnt about pointers. I blame it on everything being called int in verge. Anyway how about this for a way of doing exactly what is already being done by verge?
(Oh and vec - I understand why you can't automatically set the handle to 0 on FreeImage() now. Looked at this bit of code and it made some kinda sense. Took me a while, but I got there in the end. FreeImage(3) - third image assigned, is just as valid as freeing a specific one - therefore me need to manual 0 stuff...)
#define MAX_IMAGES 16
int extraimages[MAX_IMAGES];
int GetImageHandle()
// Gets an empty image handle
{
for (x = 0; x < MAX_IMAGES; x++)
{
if (!extraimages[x])
{
return x;
}
}
exit("No free images to assign")
}
void FreeAllImageHandles()
// Frees all images
{
for (x = 0; x < MAX_IMAGES; x++)
{
if (extraimages[x])
{
FreeImage(extraimages[x]);
extraimages[x] = 0;
}
}
}
void FreeImageHandle(int fih_num)
// Frees image at specified index
{
if (extraimages[fih_num])
{
FreeImage(extraimages[fih_num]);
extraimages[fih_num] = 0;
}
else MessageBox("No image to free #: "+str(fih_num));
}
[Edit: Slight reduction of idiocy]