|
-
Apr 4th, 2006, 08:05 PM
#1
Thread Starter
Lively Member
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 ?
-
Apr 4th, 2006, 08:14 PM
#2
Thread Starter
Lively Member
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);
-
Apr 6th, 2006, 01:48 AM
#3
Frenzied Member
Re: c++ Corrupt stack ? when function ends ?
even better:
Code:
char OpenThis[256];
strcpy(OpenThis,"Textures/");
strcat(OpenThis, fname);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|