for (int i=0; i<261; i++) glGentextures(i, sTexData.numTexture);
You won’t have a chance to create 261 textures at once with id pointing to a pointer within a struct. Moreover you should also pay some attention at the way you are allocating the memory for the texture data (i.e. the *Texture pointer)
CeccOman, that code would crash. The “numTextures” member isn’t even the right variable type, let alone a pointer. On top of that, I never heard of glGenTextures() working like a ‘realloc()’ function, so if I call it on a previously allocated block of memory, it’ll either crash or create a new location for memory while the old one now has no pointer and floats around, unable to be freed. There’s a way to alocate more than 261 textures, I mean look at Unreal II or UT2003! Both have GL support and both load a ton of textures on certain maps, now I need to figure out how, IF that’s my problem.
glGenTextures fills a previously allocated block of unsigned ints with texture object names, that’s all.
If you haven’t allocated the memory which is pointed to by sTexData.Texture you should get a crash immediately when calling glGenTextures.
If not I guess you’re “More” loop is exceeding the number of allocated textures.
Repeating what CeccOman also pointed out,
valid code could look like this:
sTexData.Texture = (unsigned int *) malloc(261 * sizeof(unsigned int));
if (sTexData.Texture != NULL)
{
glGentextures(261, sTexData.Texture);
sTexData.numTextures = 261;
for (i = 0; i < sTexData.numTextures; i++)
{
glBindTexture(GL_TEXTURE_2D, sTexData.Texture[i]);
// do stuff
}
}