I've written the following function to load textures through OpenIL en mass, but when I run it I get a runtime error: "Stack around variable texid corrupted".
Here's the function:
I'm not sure I've gotten the hang of textures yet - glBindImage etc confuses me - if someone could explain it better (as well as help me with my problemCode:#define TEXTURES_COUNT 2 // texture list - used to index textures array #define TEX_STONE 1 #define TEX_BLUE 2 // names of textures used to load texture files char *textureNames[TEXTURES_COUNT] = { "data\\stone.tga", "data\\blue.tga" }; GLuint uiTextures[TEXTURES_COUNT]; // Holds all game textures bool LoadTextures () { int i; ILuint texid; ILboolean bLoad; // Check OpenIL version first if (ilGetInteger (IL_VERSION_NUM) < IL_VERSION) { MessageBox (0, "Invalid OpenIL Version", "Jemmings", MB_OK | MB_ICONERROR); return false; } ilInit (); ilGenImages (TEXTURES_COUNT, &texid); // Loop through and load all textures using textureNames for (i = 0; i < TEXTURES_COUNT - 1; i++) { ilBindImage (texid); bLoad = ilLoadImage (textureNames[i]); if (bLoad) { bLoad = ilConvertImage (IL_RGBA, IL_UNSIGNED_BYTE); if (! bLoad) { MessageBox (0, "Unable to convert texture[s]", "Jemmings", MB_OK | MB_ICONERROR); ilDeleteImages (TEXTURES_COUNT + 1, &texid); return false; } glGenTextures (TEXTURES_COUNT, &uiTextures[i]); glBindTexture (GL_TEXTURE_2D, uiTextures[i]); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexImage2D (GL_TEXTURE_2D, 0, ilGetInteger (IL_IMAGE_BPP), ilGetInteger (IL_IMAGE_WIDTH), ilGetInteger (IL_IMAGE_HEIGHT), 0, ilGetInteger (IL_IMAGE_FORMAT), GL_UNSIGNED_BYTE, ilGetData ()); } else { MessageBox (0, "Unable to load texture", "Jemmings", MB_OK | MB_ICONERROR); ilDeleteImages (TEXTURES_COUNT + 1, &texid); return false; } } ilDeleteImages (TEXTURES_COUNT, &texid); return true; }) I'd be grateful.



LinkBack URL
About LinkBacks
) I'd be grateful. 


