Texturing-Nehe problem
I am using the followin method to apply textures
GLuint texture[6];
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
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;
}
int LoadGLTextures(){
AUX_RGBImageRec *TextureImage[6];
memset(TextureImage,0,sizeof(void *)*1);
TextureImage[0] = LoadBMP("Files/1.bmp");
TextureImage[1] = LoadBMP("Files/2.bmp");
TextureImage[2] = LoadBMP("Files/3.bmp");
TextureImage[3] = LoadBMP("Files/4.bmp");
TextureImage[4] = LoadBMP("Files/5.bmp");
TextureImage[5] = LoadBMP("Files/6.bmp");
glGenTextures(6, &texture[0]);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX,TextureImage[0]->sizeY, 0, GL_RGB,GL_UNSIGNED_BYTE, TextureImage[0]->data);
glBindTexture(GL_TEXTURE_2D, texture[1]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[1]->sizeX,TextureImage[1]->sizeY, 0, GL_RGB,GL_UNSIGNED_BYTE, TextureImage[1]->data);
glBindTexture(GL_TEXTURE_2D, texture[2]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[2]->sizeX,TextureImage[2]->sizeY, 0, GL_RGB,GL_UNSIGNED_BYTE, TextureImage[2]->data);
glBindTexture(GL_TEXTURE_2D, texture[3]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[3]->sizeX,TextureImage[3]->sizeY, 0, GL_RGB,GL_UNSIGNED_BYTE, TextureImage[3]->data);
glBindTexture(GL_TEXTURE_2D, texture[4]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[4]->sizeX,TextureImage[4]->sizeY, 0, GL_RGB,GL_UNSIGNED_BYTE, TextureImage[4]->data);
glBindTexture(GL_TEXTURE_2D, texture[5]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[5]->sizeX,TextureImage[5]->sizeY, 0, GL_RGB,GL_UNSIGNED_BYTE, TextureImage[5]->data);
for (int t = 0; t < 6; t++) {
if (TextureImage[t]){
if (TextureImage[t]->data){
free(TextureImage[t]->data); }
free(TextureImage[t]); }
}
return 1;
}
when i continue trying to use one more texture(6+1) the apllication will hang and the computer will not respond!!!
Some help please!!!!!! It is really urgent.
quote:
memset(TextureImage,0,sizeof(void *)*1);
It could be that you are only clearing space for one texture.. try changing it to
memset(TextureImage,0,sizeof(void *)*6);
Disclaimer: "I am in no way qualified to present advice on any topic concerning anything and can not be held responsible for any damages that my advice may incurr (due to neither my negligence nor yours)"
I tried it ,but i am afraid i still have the same problem.Thank you anyway.Don''t you people have the same problem or it is just happening to me?
Here are some things to check out...
Do you make your texture array bigger? Do you increase the number in glGenTextures? Do you load the texture properly? Do you bind the texture properly?
Why you shouldn''t use iostream.h - ever! | A Good free online C++ book
Do you make your texture array bigger? Do you increase the number in glGenTextures? Do you load the texture properly? Do you bind the texture properly?
Why you shouldn''t use iostream.h - ever! | A Good free online C++ book
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement