🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

beginner open gl problem

Started by
1 comment, last by hello_there 22 years, 6 months ago
when ever i try to load textures and display them they just come out white. i can''t get it to work. i used nehe''s way and it didn''t work. AUX_RGBImageRec *LoadBMP(char *Filename) // Loads A Bitmap Image { FILE *File=NULL; // File Handle if (!Filename) // Make Sure A Filename Was Given { return NULL; // If Not Return NULL } File=fopen(Filename,"r"); // Check To See If The File Exists if (File) // Does The File Exist? { fclose(File); // Close The Handle return auxDIBImageLoad(Filename); // Load The Bitmap And Return A Pointer } return NULL; // If Load Failed Return NULL } int LoadGLTextures() // Load Bitmaps And Convert To Textures { AUX_RGBImageRec *TextureImage[2]; memset(TextureImage,0,sizeof(void *)*1); TextureImage[0] = LoadBMP("64grass.bmp"); TextureImage[1] = LoadBMP("64wall.bmp"); glGenTextures(2, &texture[0]); // We are generating two textures 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); 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); glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[1]->sizeX, TextureImage[1]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[1]->data); for (int t = 0; t < 2; t++) { if (TextureImage[t]) { if (TextureImage[t]->data) { free(TextureImage[t]->data); } free(TextureImage[t]); } } return(1); } that''s nehe''s code i put that into my programe along with the nehe init function and try load load my texture to my square but it didn''t work please help.
____________________________________________________________How could hell be worse?
Advertisement
Hey,

Post the section where you make the quad and texture it so i can have a look at that too. You problem might be there.

Also look at this



if (File) // Does The File Exist?
{
fclose(File); // Close The Handle
return auxDIBImageLoad(Filename); // Load The Bitmap And Return A Pointer
}

return NULL; // If Load Failed Return NULL
}



you might want to make that this


if (File) // Does The File Exist?
{
fclose(File); // Close The Handle
return auxDIBImageLoad(Filename); // Load The Bitmap And Return A Pointer
}
else
{
return NULL; // If Load Failed Return NULL
}




Edited by - TheBlackJester on December 9, 2001 6:39:40 PM

"With my feet upon the ground I lose myself between the sounds and open wide to suck it in, I feel it move across my skin. I'm reaching up and reaching out. I'm reaching for the random or what ever will bewilder me, what ever will bewilder me. And following our will and wind we may just go where no one's been. We'll ride the spiral to the end and may just go where no one's been." - Maynard James Keenan Name: [email=darkswordtbj@hotmail.com]TheBlackJester[/email]Team: Wildfire Games
Projects O A.D.The Last Alliance

I don''t know if it''s your problem but since you are using 2 textures memset(TextureImage,0,sizeof(void *)*1);
should be: memset(TextureImage,0,sizeof(void *)*2);

Romance is dead,it was bougth by Disney and Hallmark and sold to the public in small portions.

This topic is closed to new replies.

Advertisement