c++ Corrupt stack ? when function ends ?
VB Code:
int LoadSceneTextures(char *fname, int ArraySpace) // Load Bitmaps And Convert To Textures
{
int Status=FALSE; // Status Indicator
AUX_RGBImageRec *TextureImage[1]; // Create Storage Space For The Texture
memset(TextureImage,0,sizeof(void *)*1); // Set The Pointer To NULL
char OpenThis[256];
strcat(OpenThis,"Textures/");
strcat(OpenThis, fname);
// Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
if (TextureImage[0]=LoadBMP(OpenThis))
{
Status=TRUE; // Set The Status To TRUE
glGenTextures(ArraySpace, &SceneTextures[ArraySpace]); // Create One Texture
// Create Linear Filtered Texture
glBindTexture(GL_TEXTURE_2D, SceneTextures[ArraySpace]);
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, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
}
if (TextureImage[0]) // If Texture Exists
{
if (TextureImage[0]->data) // If Texture Image Exists
{
free(TextureImage[0]->data); // Free The Texture Image Memory
}
free(TextureImage[0]); // Free The Image Structure
}
return Status; // Return The Status
}
im trying to load a texture to a gl array and this keeps returning stack around OpenThis was corrupt ?? how can i stop this from happening ?
The function seems to work but crashes when its finished ??
any ideas ?
Re: c++ Corrupt stack ? when function ends ?
replaced this
VB Code:
char OpenThis[256];
strcat(OpenThis,"Textures/");
strcat(OpenThis, fname);
with this and it now works ;)
VB Code:
char OpenThis[256];
strcpy(OpenThis,"");
strcat(OpenThis,"Textures/");
strcat(OpenThis, fname);
Re: c++ Corrupt stack ? when function ends ?
even better:
Code:
char OpenThis[256];
strcpy(OpenThis,"Textures/");
strcat(OpenThis, fname);