I did a quick search and couldn't find this - but I'm new to these boards so apologies if this has already been covered. I'm using libnds source version 1.3.3.
glTexImage2D uses a dynamic array to track the association between texture name allocation and physical memory addresses. However, it appears to assume that the contents of the dynamic array are set to 0 after resizing - which is not guaranteed and can cause the routine to copy texture data to random memory (as occurred in my application).
DynamicArraySet (in dyanmicArray.h):
Code: Select all
void DynamicArraySet(DynamicArray *v, int index, void* item)
{
if(index >= v->cur_size)
{
v->cur_size *= 2;
v->data = (void**)realloc(v->data, sizeof(void*) * v->cur_size);
}
v->data[index] = item;
}
Code: Select all
void DynamicArraySet(DynamicArray *v, int index, void* item)
{
if(index >= v->cur_size)
{
v->data = (void**)realloc(v->data, sizeof(void*) * v->cur_size * 2);
memset(v->data + v->cur_size, 0, sizeof(void*) * v->cur_size);
v->cur_size *= 2;
}
v->data[index] = item;
}
If there's a better way of reporting things such as this then please let me know - I'm pretty new to the platform and very new to this forum.