Here is the BIG problem with my project:
I like the tutorials on the NeHe website, and Windows XP does a great job with programs. However, when I reformatted my computer, changed the OS to Windows Vista and reinstalled my Dev-C ++ compiler, and then I tried to open any C ++ program that used textures, the program crashed.
I realized that my glaux.h was missing. I found the file on the Internet and recompiled my project, but it still crashed. Everything went well when I excluded the texture features.
Where is the problem and what can I do to solve it?
I thought one of them was the culprit: Windows Vista, my graphics card, glaux.h and libraries (I know it's listening), OpenGL.
.
Update: I have identified the source of the problem.
This piece of code caused my program to crash:
if (TextureImage[0]) {
if (TextureImage[0]->data) {
free(TextureImage[0]->data);
}
free(TextureImage[0]);
}
For some reason, my program is always reset whenever I order it to free up memory. When I commented on this section, my program works fine, except that all the colors have darkened (I think about it because of the colors of my raster file). Any tips?
.
The answer to the question: Matias Valdenero
Well, this was from the NeHe6 lesson, which worked great when I was still using Windows XP. Nothing really changed when I switched to Windows Vista.
Just so you know, here is the whole function:
#define NoOfTextures 3
GLuint texture[NoOfTextures];
int LoadGLTextures()
{
int Status=FALSE;
AUX_RGBImageRec *TextureImage[NoOfTextures];
memset(TextureImage,0,sizeof(void *)*1);
if (TextureImage[0]=LoadBMP("Data/Bitmaps/texture.bmp"))
{
Status=TRUE;
glGenTextures(1, &texture[0]);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
if (TextureImage[0] != NULL) {
if (TextureImage[0]->data != NULL) {
free(TextureImage[0]->data);
}
free(TextureImage[0]);
}
}
return Status;
}
.
Additional Information:
I often rebuild my project, and LoadBMP () is part of the same header file. This is the function LoadBMP ():
AUX_RGBImageRec *LoadBMP(char *Filename)
{
FILE *File=NULL;
if (!Filename)
{
return NULL;
}
File=fopen(Filename,"r");
if (File)
{
fclose(File);
return auxDIBImageLoad(Filename);
}
return NULL;
}
I think this is pretty clear.